Skip to content

Commit 24621e8

Browse files
Add test for getMaxParameterSizeFromIGC
Test is using MockCompilerInterface Related-To: NEO-4851 Signed-off-by: Dominik Dabek <[email protected]>
1 parent 5be9d2d commit 24621e8

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

shared/source/compiler_interface/compiler_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class CompilerInterface {
136136
MOCKABLE_VIRTUAL TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector<char> &retBinary,
137137
std::vector<char> &stateSaveAreaHeader);
138138

139-
CIF::RAII::UPtr_t<IGC::IgcFeaturesAndWorkaroundsTagOCL> getIgcFeaturesAndWorkarounds(const NEO::Device &device);
139+
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::IgcFeaturesAndWorkaroundsTagOCL> getIgcFeaturesAndWorkarounds(const NEO::Device &device);
140140

141141
protected:
142142
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl);

shared/test/common/mocks/mock_compiler_interface.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,20 @@ class MockCompilerInterface : public CompilerInterface {
133133
}
134134
}
135135

136+
CIF::RAII::UPtr_t<IGC::IgcFeaturesAndWorkaroundsTagOCL> getIgcFeaturesAndWorkarounds(const NEO::Device &device) override {
137+
if (nullptr != igcFeaturesAndWorkaroundsTagOCL) {
138+
return CIF::RAII::RetainAndPack<IGC::IgcFeaturesAndWorkaroundsTagOCL>(igcFeaturesAndWorkaroundsTagOCL);
139+
} else {
140+
return CompilerInterface::getIgcFeaturesAndWorkarounds(device);
141+
}
142+
};
143+
136144
static std::vector<char> getDummyGenBinary();
137145
static void releaseDummyGenBinary();
138146

139147
void (*lockListener)(MockCompilerInterface &compInt) = nullptr;
140148
void *lockListenerData = nullptr;
149+
IGC::IgcFeaturesAndWorkaroundsTagOCL *igcFeaturesAndWorkaroundsTagOCL = nullptr;
141150
bool failCreateFclTranslationCtx = false;
142151
bool failCreateIgcTranslationCtx = false;
143152
bool failLoadFcl = false;

shared/test/common/mocks/mock_compilers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ struct MockGTSystemInfo : MockCIF<IGC::GTSystemInfoTagOCL> {
120120
};
121121

122122
struct MockIgcFeaturesAndWorkarounds : MockCIF<IGC::IgcFeaturesAndWorkaroundsTagOCL> {
123+
uint32_t GetMaxOCLParamSize() const override {
124+
return this->maxOCLParamSize;
125+
};
126+
127+
uint32_t maxOCLParamSize = 0;
123128
};
124129

125130
struct MockIgcOclTranslationCtx : MockCIF<IGC::IgcOclTranslationCtxTagOCL> {

shared/test/common/mocks/mock_device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class MockDevice : public RootDevice {
9696
}
9797

9898
size_t getMaxParameterSizeFromIGC() const override {
99+
if (callBaseGetMaxParameterSizeFromIGC) {
100+
return Device::getMaxParameterSizeFromIGC();
101+
}
99102
return maxParameterSizeFromIGC;
100103
}
101104

@@ -180,6 +183,7 @@ class MockDevice : public RootDevice {
180183
bool isDebuggerActiveParentCall = true;
181184
bool isDebuggerActiveReturn = false;
182185
bool rtDispatchGlobalsForceAllocation = false;
186+
bool callBaseGetMaxParameterSizeFromIGC = false;
183187
size_t maxParameterSizeFromIGC = 0u;
184188
};
185189

shared/test/unit_test/device/neo_device_tests.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "shared/test/common/fixtures/device_fixture.h"
1010
#include "shared/test/common/helpers/default_hw_info.h"
1111
#include "shared/test/common/helpers/variable_backup.h"
12+
#include "shared/test/common/mocks/mock_compiler_interface.h"
13+
#include "shared/test/common/mocks/mock_compilers.h"
1214
#include "shared/test/common/mocks/mock_device.h"
1315
#include "shared/test/common/mocks/ult_device_factory.h"
1416
#include "shared/test/common/test_macros/test.h"
@@ -81,8 +83,19 @@ TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithZeroSizeAndMockAllocatorT
8183

8284
using DeviceGetCapsTest = Test<DeviceFixture>;
8385

84-
TEST_F(DeviceGetCapsTest, givenNonZeroMaxParameterSizeFromIGCwhenDeviceIsCreatedThenMaxParameterSizeIsSetCorrectly) {
85-
pDevice->maxParameterSizeFromIGC = 1u;
86+
TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledThenMaxParameterSizeIsSetCorrectly) {
87+
auto pCompilerInterface = new MockCompilerInterface;
88+
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(pCompilerInterface);
89+
pDevice->maxParameterSizeFromIGC = 2u;
90+
pDevice->callBaseGetMaxParameterSizeFromIGC = true;
91+
MockIgcFeaturesAndWorkarounds mockIgcFtrWa;
92+
pCompilerInterface->igcFeaturesAndWorkaroundsTagOCL = &mockIgcFtrWa;
93+
94+
mockIgcFtrWa.maxOCLParamSize = 0u;
8695
pDevice->initializeCaps();
87-
EXPECT_EQ(pDevice->getDeviceInfo().maxParameterSize, 1u);
88-
}
96+
EXPECT_EQ(2048u, pDevice->getDeviceInfo().maxParameterSize);
97+
98+
mockIgcFtrWa.maxOCLParamSize = 1u;
99+
pDevice->initializeCaps();
100+
EXPECT_EQ(1u, pDevice->getDeviceInfo().maxParameterSize);
101+
}

0 commit comments

Comments
 (0)