Skip to content

Commit 022236d

Browse files
fix: disable indirect detection if any stack calls
Don't know if kernels will be initialized in the order needed to check for indirect accesses in stack calls. Remove now unused functionPointerWithIndirectAccessExists and reading this value from zebin. Related-To: NEO-12235 Signed-off-by: Dominik Dabek <[email protected]> Source: ad22937
1 parent dc6faef commit 022236d

File tree

11 files changed

+4
-26
lines changed

11 files changed

+4
-26
lines changed

level_zero/core/source/kernel/kernel_imp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ ze_result_t KernelImp::initialize(const ze_kernel_desc_t *desc) {
11121112
kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic ||
11131113
kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess ||
11141114
kernelDescriptor.kernelAttributes.hasIndirectAccessInImplicitArg ||
1115-
(moduleImp->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists && kernelDescriptor.kernelAttributes.flags.useStackCalls) ||
1115+
kernelDescriptor.kernelAttributes.flags.useStackCalls ||
11161116
NEO::KernelHelper::isAnyArgumentPtrByValue(kernelDescriptor);
11171117
} else {
11181118
kernelHasIndirectAccess = true;

level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
14271427
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
14281428
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
14291429
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1430-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = false;
14311430
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
14321431

14331432
kernel->initialize(&desc);
@@ -1446,7 +1445,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
14461445
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = true;
14471446
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
14481447
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1449-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = false;
14501448
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
14511449

14521450
kernel->initialize(&desc);
@@ -1465,7 +1463,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
14651463
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
14661464
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = true;
14671465
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1468-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = false;
14691466
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
14701467

14711468
kernel->initialize(&desc);
@@ -1484,7 +1481,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
14841481
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
14851482
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
14861483
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = true;
1487-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = false;
14881484
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
14891485

14901486
kernel->initialize(&desc);
@@ -1503,7 +1499,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
15031499
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
15041500
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
15051501
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1506-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = true;
15071502
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.flags.useStackCalls = false;
15081503
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
15091504

@@ -1523,7 +1518,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
15231518
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
15241519
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
15251520
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1526-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = true;
15271521
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.flags.useStackCalls = true;
15281522
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = false;
15291523

@@ -1543,7 +1537,6 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, givenDetectIndirectAccessInKernelEn
15431537
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgStore = false;
15441538
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasNonKernelArgAtomic = false;
15451539
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectStatelessAccess = false;
1546-
module->getTranslationUnit()->programInfo.functionPointerWithIndirectAccessExists = false;
15471540
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.flags.useStackCalls = false;
15481541
module->mockKernelImmData->mockKernelDescriptor->kernelAttributes.hasIndirectAccessInImplicitArg = true;
15491542

opencl/source/kernel/kernel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ cl_int Kernel::initialize() {
332332
kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic ||
333333
kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess ||
334334
kernelDescriptor.kernelAttributes.hasIndirectAccessInImplicitArg ||
335-
(program->getFunctionPointerWithIndirectAccessExists() && kernelDescriptor.kernelAttributes.flags.useStackCalls) ||
335+
kernelDescriptor.kernelAttributes.flags.useStackCalls ||
336336
NEO::KernelHelper::isAnyArgumentPtrByValue(kernelDescriptor);
337337
} else {
338338
this->kernelHasIndirectAccess = true;

opencl/source/program/process_device_binary.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ cl_int Program::processProgramInfo(ProgramInfo &src, const ClDevice &clDevice) {
315315
}
316316

317317
indirectDetectionVersion = src.indirectDetectionVersion;
318-
functionPointerWithIndirectAccessExists = src.functionPointerWithIndirectAccessExists;
319318

320319
return linkBinary(&clDevice.getDevice(), src.globalConstants.initData, src.globalConstants.size, src.globalVariables.initData,
321320
src.globalVariables.size, src.globalStrings, src.externalFunctions);

opencl/source/program/program.h

-2
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ class Program : public BaseObject<_cl_program> {
248248
MOCKABLE_VIRTUAL std::string getInternalOptions() const;
249249
uint32_t getMaxRootDeviceIndex() const { return maxRootDeviceIndex; }
250250
uint32_t getIndirectDetectionVersion() const { return indirectDetectionVersion; }
251-
bool getFunctionPointerWithIndirectAccessExists() const { return functionPointerWithIndirectAccessExists; }
252251
void retainForKernel() {
253252
std::unique_lock<std::mutex> lock{lockMutex};
254253
exposedKernels++;
@@ -374,7 +373,6 @@ class Program : public BaseObject<_cl_program> {
374373
ClDeviceVector clDevicesInProgram;
375374

376375
uint32_t indirectDetectionVersion = 0u;
377-
bool functionPointerWithIndirectAccessExists = false;
378376
bool isBuiltIn = false;
379377
bool isGeneratedByIgc = true;
380378

opencl/test/unit_test/kernel/kernel_tests.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWithNoKernelArgLoadNorKernelArgStoreNor
19761976
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
19771977
}
19781978

1979-
HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToTrue) {
1979+
HWTEST_F(KernelResidencyTest, givenKernelWithStackCallsAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToTrue) {
19801980
DebugManagerStateRestore restorer;
19811981
debugManager.flags.DetectIndirectAccessInKernel.set(1);
19821982
auto pKernelInfo = std::make_unique<KernelInfo>();
@@ -1997,7 +1997,6 @@ HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessA
19971997
MockContext ctx;
19981998
program.setContext(&ctx);
19991999
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
2000-
program.functionPointerWithIndirectAccessExists = true;
20012000
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
20022001
ASSERT_EQ(CL_SUCCESS, kernel->initialize());
20032002

@@ -2006,7 +2005,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessA
20062005
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
20072006
}
20082007

2009-
HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessButNoUseStackCallsAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToFalse) {
2008+
HWTEST_F(KernelResidencyTest, givenKernelWithoutStackCallsAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToFalse) {
20102009
DebugManagerStateRestore restorer;
20112010
debugManager.flags.DetectIndirectAccessInKernel.set(1);
20122011
auto pKernelInfo = std::make_unique<KernelInfo>();
@@ -2028,7 +2027,6 @@ HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessB
20282027
MockContext ctx;
20292028
program.setContext(&ctx);
20302029
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
2031-
program.functionPointerWithIndirectAccessExists = true;
20322030
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
20332031
ASSERT_EQ(CL_SUCCESS, kernel->initialize());
20342032

opencl/test/unit_test/mocks/mock_program.h

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class MockProgram : public Program {
5555
using Program::deviceBuildInfos;
5656
using Program::disableZebinIfVmeEnabled;
5757
using Program::extractInternalOptions;
58-
using Program::functionPointerWithIndirectAccessExists;
5958
using Program::getKernelInfo;
6059
using Program::getModuleAllocations;
6160
using Program::internalOptionsToExtract;

shared/source/device_binary_format/zebin/zeinfo_decoder.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,6 @@ DecodeError decodeZeInfoKernels(ProgramInfo &dst, Yaml::YamlParser &parser, cons
496496
if (DecodeError::success != zeInfoErr) {
497497
return zeInfoErr;
498498
}
499-
if (kernelInfo->kernelDescriptor.kernelMetadata.kernelName == Zebin::Elf::SectionNames::externalFunctions) {
500-
dst.functionPointerWithIndirectAccessExists |= kernelInfo->kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess;
501-
}
502499

503500
dst.kernelInfos.push_back(kernelInfo.release());
504501
}

shared/source/program/program_info.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct ProgramInfo {
4848
uint32_t minScratchSpaceSize = 0U;
4949
uint32_t indirectDetectionVersion = 0U;
5050
size_t kernelMiscInfoPos = std::string::npos;
51-
bool functionPointerWithIndirectAccessExists = false;
5251
};
5352

5453
size_t getMaxInlineSlmNeeded(const ProgramInfo &programInfo);

shared/test/unit_test/device_binary_format/device_binary_formats_tests.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ TEST(DecodeSingleDeviceBinary, GivenZebinWithExternalFunctionsThenDecodingSuccee
343343
EXPECT_TRUE(decodeErrors.empty()) << decodeErrors;
344344
EXPECT_NE(nullptr, programInfo.linkerInput.get());
345345
EXPECT_EQ(1, programInfo.linkerInput->getExportedFunctionsSegmentId());
346-
EXPECT_TRUE(programInfo.functionPointerWithIndirectAccessExists);
347346
}
348347

349348
TEST(DecodeSingleDeviceBinary, GivenOclElfFormatThenDecodingFails) {

shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -6691,8 +6691,6 @@ TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadat
66916691
EXPECT_EQ(128U, fun1Info.numGrfRequired);
66926692
EXPECT_EQ(8U, fun1Info.simdSize);
66936693
EXPECT_EQ(0U, fun1Info.barrierCount);
6694-
6695-
EXPECT_FALSE(programInfo.functionPointerWithIndirectAccessExists);
66966694
}
66976695
}
66986696

@@ -6733,8 +6731,6 @@ TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadat
67336731
EXPECT_EQ(128U, fun0Info.numGrfRequired);
67346732
EXPECT_EQ(8U, fun0Info.simdSize);
67356733
EXPECT_EQ(1U, fun0Info.barrierCount);
6736-
6737-
EXPECT_FALSE(programInfo.functionPointerWithIndirectAccessExists);
67386734
}
67396735

67406736
TEST(PopulateZeInfoExternalFunctionsMetadata, GivenInvalidExternalFunctionsMetadataThenFail) {

0 commit comments

Comments
 (0)