Skip to content

Commit d236bcb

Browse files
feature: add isTranslationExceptionSupported method
Related-To: NEO-7782 Signed-off-by: Rafal Maziejuk <[email protected]>
1 parent 45038ac commit d236bcb

File tree

13 files changed

+112
-91
lines changed

13 files changed

+112
-91
lines changed

opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp

Lines changed: 42 additions & 57 deletions
Large diffs are not rendered by default.

shared/source/command_stream/stream_properties.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void StateComputeModeProperties::setThreadArbitrationProperty(int32_t threadArbi
125125
void StateComputeModeProperties::initSupport(const RootDeviceEnvironment &rootDeviceEnvironment) {
126126
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
127127
productHelper.fillScmPropertiesSupportStructure(this->scmPropertiesSupport);
128+
productHelper.fillScmPropertiesSupportStructureExtra(this->scmPropertiesSupport, rootDeviceEnvironment);
128129

129130
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
130131
this->defaultThreadArbitrationPolicy = gfxCoreHelper.getDefaultThreadArbitrationPolicy();

shared/source/os_interface/product_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class ProductHelper {
169169
virtual bool isDummyBlitWaRequired() const = 0;
170170
virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor) const = 0;
171171
virtual bool isLinearStoragePreferred(bool isSharedContext, bool isImage1d, bool forceLinearStorage) const = 0;
172+
virtual bool isTranslationExceptionSupported() const = 0;
172173

173174
virtual bool getFrontEndPropertyScratchSizeSupport() const = 0;
174175
virtual bool getFrontEndPropertyPrivateScratchSizeSupport() const = 0;
@@ -195,6 +196,7 @@ class ProductHelper {
195196
virtual bool getPipelineSelectPropertySystolicModeSupport() const = 0;
196197

197198
virtual void fillScmPropertiesSupportStructure(StateComputeModePropertiesSupport &propertiesSupport) const = 0;
199+
virtual void fillScmPropertiesSupportStructureExtra(StateComputeModePropertiesSupport &propertiesSupport, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0;
198200
virtual void fillFrontEndPropertiesSupportStructure(FrontEndPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) const = 0;
199201
virtual void fillPipelineSelectPropertiesSupportStructure(PipelineSelectPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) const = 0;
200202
virtual void fillStateBaseAddressPropertiesSupportStructure(StateBaseAddressPropertiesSupport &propertiesSupport) const = 0;

shared/source/os_interface/product_helper.inl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@ void ProductHelperHw<gfxProduct>::fillScmPropertiesSupportStructure(StateCompute
604604
fillScmPropertiesSupportStructureBase(propertiesSupport);
605605
}
606606

607+
template <PRODUCT_FAMILY gfxProduct>
608+
void ProductHelperHw<gfxProduct>::fillScmPropertiesSupportStructureExtra(StateComputeModePropertiesSupport &propertiesSupport, const RootDeviceEnvironment &rootDeviceEnvironment) const {}
609+
607610
template <PRODUCT_FAMILY gfxProduct>
608611
bool ProductHelperHw<gfxProduct>::getScmPropertyThreadArbitrationPolicySupport() const {
609612
using GfxProduct = typename HwMapper<gfxProduct>::GfxProduct;
@@ -775,4 +778,10 @@ bool ProductHelperHw<gfxProduct>::isLinearStoragePreferred(bool isSharedContext,
775778
}
776779
return false;
777780
}
781+
782+
template <PRODUCT_FAMILY gfxProduct>
783+
bool ProductHelperHw<gfxProduct>::isTranslationExceptionSupported() const {
784+
return false;
785+
}
786+
778787
} // namespace NEO

shared/source/os_interface/product_helper_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class ProductHelperHw : public ProductHelper {
123123
bool isDummyBlitWaRequired() const override;
124124
bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor) const override;
125125
bool isLinearStoragePreferred(bool isSharedContext, bool isImage1d, bool forceLinearStorage) const override;
126+
bool isTranslationExceptionSupported() const override;
126127

127128
bool getFrontEndPropertyScratchSizeSupport() const override;
128129
bool getFrontEndPropertyPrivateScratchSizeSupport() const override;
@@ -149,6 +150,7 @@ class ProductHelperHw : public ProductHelper {
149150
bool getPipelineSelectPropertySystolicModeSupport() const override;
150151

151152
void fillScmPropertiesSupportStructure(StateComputeModePropertiesSupport &propertiesSupport) const override;
153+
void fillScmPropertiesSupportStructureExtra(StateComputeModePropertiesSupport &propertiesSupport, const RootDeviceEnvironment &rootDeviceEnvironment) const override;
152154
void fillFrontEndPropertiesSupportStructure(FrontEndPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) const override;
153155
void fillPipelineSelectPropertiesSupportStructure(PipelineSelectPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) const override;
154156
void fillStateBaseAddressPropertiesSupportStructure(StateBaseAddressPropertiesSupport &propertiesSupport) const override;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "shared/test/common/libult/source_level_debugger_library.h"
11+
12+
namespace NEO {
13+
14+
class DebuggerLibraryRestore {
15+
public:
16+
DebuggerLibraryRestore() {
17+
restoreActiveState = DebuggerLibrary::getDebuggerActive();
18+
restoreAvailableState = DebuggerLibrary::getLibraryAvailable();
19+
}
20+
~DebuggerLibraryRestore() {
21+
DebuggerLibrary::clearDebuggerLibraryInterceptor();
22+
DebuggerLibrary::setDebuggerActive(restoreActiveState);
23+
DebuggerLibrary::setLibraryAvailable(restoreAvailableState);
24+
}
25+
26+
bool restoreActiveState = false;
27+
bool restoreAvailableState = false;
28+
};
29+
30+
} // namespace NEO

shared/test/common/helpers/unit_test_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct UnitTestHelper {
6262
static uint32_t getTdCtlRegisterOffset();
6363
static uint32_t getTdCtlRegisterValue();
6464

65+
static uint32_t getMiLoadRegisterImmProgrammedCmdsCount(bool debuggingEnabled);
66+
6567
static const uint32_t smallestTestableSimdSize;
6668

6769
static const AuxTranslationMode requiredAuxTranslationMode;

shared/test/common/helpers/unit_test_helper.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,9 @@ uint32_t UnitTestHelper<GfxFamily>::getProgrammedGrfValue(CommandStreamReceiver
108108
return 0u;
109109
}
110110

111+
template <typename GfxFamily>
112+
uint32_t UnitTestHelper<GfxFamily>::getMiLoadRegisterImmProgrammedCmdsCount(bool debuggingEnabled) {
113+
return (debuggingEnabled ? 2u : 0u);
114+
}
115+
111116
} // namespace NEO

shared/test/unit_test/command_stream/stream_properties_tests_common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ HWTEST2_F(StreamPropertiesTests, whenSettingStateComputeModePropertiesThenCorrec
123123
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
124124
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
125125
productHelper.fillScmPropertiesSupportStructure(scmPropertiesSupport);
126+
productHelper.fillScmPropertiesSupportStructureExtra(scmPropertiesSupport, rootDeviceEnvironment);
126127

127128
int32_t threadArbitrationPolicyValues[] = {
128129
ThreadArbitrationPolicy::AgeBased, ThreadArbitrationPolicy::RoundRobin,

shared/test/unit_test/gen11/test_preamble_gen11.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "shared/source/helpers/gfx_core_helper.h"
1313
#include "shared/test/common/fixtures/preamble_fixture.h"
1414
#include "shared/test/common/helpers/debug_manager_state_restore.h"
15+
#include "shared/test/common/helpers/unit_test_helper.h"
1516
#include "shared/test/common/mocks/mock_execution_environment.h"
1617
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
1718

@@ -194,7 +195,8 @@ GEN11TEST_F(PreambleFixtureGen11, whenKernelDebuggingCommandsAreProgrammedThenCo
194195
hwParser.parseCommands<FamilyType>(stream);
195196
auto cmdList = hwParser.getCommandsList<MI_LOAD_REGISTER_IMM>();
196197

197-
ASSERT_EQ(2u, cmdList.size());
198+
auto expectedProgrammedCmdsCount = UnitTestHelper<FamilyType>::getMiLoadRegisterImmProgrammedCmdsCount(true);
199+
ASSERT_EQ(expectedProgrammedCmdsCount, cmdList.size());
198200

199201
auto it = cmdList.begin();
200202

shared/test/unit_test/os_interface/product_helper_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,3 +747,7 @@ HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenChecking
747747
EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor));
748748
}
749749
}
750+
751+
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckingIsTranslationExceptionSupportedThenReturnFalse) {
752+
EXPECT_FALSE(productHelper->isTranslationExceptionSupported());
753+
}

shared/test/unit_test/preamble/preamble_tests.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, givenMidThreadPreemptionWhenPreambleIs
9797
}
9898

9999
HWTEST_F(PreambleTest, givenActiveKernelDebuggingWhenPreambleKernelDebuggingCommandsSizeIsQueriedThenCorrectSizeIsReturned) {
100-
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
100+
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
101+
101102
auto size = PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(true);
102-
auto sizeExpected = 2 * sizeof(MI_LOAD_REGISTER_IMM);
103-
EXPECT_EQ(sizeExpected, size);
103+
auto expectedProgrammedCmdsCount = UnitTestHelper<FamilyType>::getMiLoadRegisterImmProgrammedCmdsCount(true);
104+
auto expectedSize = expectedProgrammedCmdsCount * sizeof(MI_LOAD_REGISTER_IMM);
105+
EXPECT_EQ(expectedSize, size);
104106
}
105107

106108
HWTEST_F(PreambleTest, givenInactiveKernelDebuggingWhenPreambleKernelDebuggingCommandsSizeIsQueriedThenZeroIsReturned) {
@@ -121,7 +123,8 @@ HWTEST_F(PreambleTest, whenKernelDebuggingCommandsAreProgrammedThenCorrectComman
121123
hwParser.parseCommands<FamilyType>(stream);
122124
auto cmdList = hwParser.getCommandsList<MI_LOAD_REGISTER_IMM>();
123125

124-
ASSERT_EQ(2u, cmdList.size());
126+
auto expectedProgrammedCmdsCount = UnitTestHelper<FamilyType>::getMiLoadRegisterImmProgrammedCmdsCount(true);
127+
ASSERT_EQ(expectedProgrammedCmdsCount, cmdList.size());
125128

126129
auto it = cmdList.begin();
127130

@@ -165,8 +168,9 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenPro
165168
cmdList = hwParser2.getCommandsList<MI_LOAD_REGISTER_IMM>();
166169

167170
auto miLoadRegImmCountWithDebugging = cmdList.size();
171+
auto expectedProgrammedCmdsCount = UnitTestHelper<FamilyType>::getMiLoadRegisterImmProgrammedCmdsCount(true);
168172
ASSERT_LT(miLoadRegImmCountWithoutDebugging, miLoadRegImmCountWithDebugging);
169-
EXPECT_EQ(2u, miLoadRegImmCountWithDebugging - miLoadRegImmCountWithoutDebugging);
173+
EXPECT_EQ(expectedProgrammedCmdsCount, miLoadRegImmCountWithDebugging - miLoadRegImmCountWithoutDebugging);
170174
}
171175

172176
HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreAdded) {
@@ -180,7 +184,8 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAd
180184
EXPECT_LT(withoutDebugging, withDebugging);
181185

182186
size_t diff = withDebugging - withoutDebugging;
183-
size_t sizeExpected = 2 * sizeof(typename FamilyType::MI_LOAD_REGISTER_IMM);
187+
auto expectedProgrammedCmdsCount = UnitTestHelper<FamilyType>::getMiLoadRegisterImmProgrammedCmdsCount(true);
188+
size_t sizeExpected = expectedProgrammedCmdsCount * sizeof(typename FamilyType::MI_LOAD_REGISTER_IMM);
184189
EXPECT_EQ(sizeExpected, diff);
185190
}
186191

shared/test/unit_test/preamble/test_preamble_xe_hpg_core.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,6 @@ using PreambleTest = ::testing::Test;
2020

2121
using namespace NEO;
2222

23-
HWTEST2_F(PreambleTest, whenKernelDebuggingCommandsAreProgrammedThenCorrectCommandsArePlacedIntoStream, IsXeHpgCore) {
24-
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
25-
26-
auto bufferSize = PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(true);
27-
auto buffer = std::unique_ptr<char[]>(new char[bufferSize]);
28-
29-
LinearStream stream(buffer.get(), bufferSize);
30-
PreambleHelper<FamilyType>::programKernelDebugging(&stream);
31-
32-
HardwareParse hwParser;
33-
hwParser.parseCommands<FamilyType>(stream);
34-
auto cmdList = hwParser.getCommandsList<MI_LOAD_REGISTER_IMM>();
35-
36-
ASSERT_EQ(2u, cmdList.size());
37-
38-
auto it = cmdList.begin();
39-
40-
MI_LOAD_REGISTER_IMM *pCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
41-
EXPECT_EQ(0x20d8u, pCmd->getRegisterOffset());
42-
EXPECT_EQ((1u << 5) | (1u << 21), pCmd->getDataDword());
43-
it++;
44-
45-
pCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
46-
EXPECT_EQ(0xe400u, pCmd->getRegisterOffset());
47-
EXPECT_EQ((1u << 7) | (1u << 4) | (1u << 2) | (1u << 0), pCmd->getDataDword());
48-
}
49-
5023
HWTEST2_F(PreambleTest, givenDisableEUFusionWhenProgramVFEStateThenFusedEUDispatchIsSetCorrectly, IsXeHpgCore) {
5124
typedef typename FamilyType::CFE_STATE CFE_STATE;
5225

0 commit comments

Comments
 (0)