mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
fix: indirect access in external functions
Read indirect_stateless_count in module external functions. If greater than 0, mark all kernels that have the has_stack_calls flag set from this module as having indirect accesses. Related-To: NEO-7712 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
af5977766d
commit
e0ccf22557
@@ -296,6 +296,7 @@ cl_int Kernel::initialize() {
|
||||
kernelDescriptor.kernelAttributes.hasNonKernelArgStore ||
|
||||
kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic ||
|
||||
kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess ||
|
||||
(program->getFunctionPointerWithIndirectAccessExists() && kernelDescriptor.kernelAttributes.flags.useStackCalls) ||
|
||||
NEO::KernelHelper::isAnyArgumentPtrByValue(kernelDescriptor);
|
||||
} else {
|
||||
this->kernelHasIndirectAccess = true;
|
||||
|
||||
@@ -289,6 +289,7 @@ cl_int Program::processProgramInfo(ProgramInfo &src, const ClDevice &clDevice) {
|
||||
}
|
||||
|
||||
indirectDetectionVersion = src.indirectDetectionVersion;
|
||||
functionPointerWithIndirectAccessExists = src.functionPointerWithIndirectAccessExists;
|
||||
|
||||
return linkBinary(&clDevice.getDevice(), src.globalConstants.initData, src.globalConstants.size, src.globalVariables.initData,
|
||||
src.globalVariables.size, src.globalStrings, src.externalFunctions);
|
||||
|
||||
@@ -247,6 +247,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
MOCKABLE_VIRTUAL std::string getInternalOptions() const;
|
||||
uint32_t getMaxRootDeviceIndex() const { return maxRootDeviceIndex; }
|
||||
uint32_t getIndirectDetectionVersion() const { return indirectDetectionVersion; }
|
||||
bool getFunctionPointerWithIndirectAccessExists() const { return functionPointerWithIndirectAccessExists; }
|
||||
void retainForKernel() {
|
||||
std::unique_lock<std::mutex> lock{lockMutex};
|
||||
exposedKernels++;
|
||||
@@ -372,6 +373,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
ClDeviceVector clDevicesInProgram;
|
||||
|
||||
uint32_t indirectDetectionVersion = 0u;
|
||||
bool functionPointerWithIndirectAccessExists = false;
|
||||
bool isBuiltIn = false;
|
||||
bool isGeneratedByIgc = true;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -1776,6 +1776,66 @@ HWTEST_F(KernelResidencyTest, givenKernelWithNoKernelArgLoadNorKernelArgStoreNor
|
||||
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToTrue) {
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.DetectIndirectAccessInKernel.set(1);
|
||||
auto pKernelInfo = std::make_unique<KernelInfo>();
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 1;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgLoad = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgStore = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.flags.useStackCalls = true;
|
||||
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
commandStreamReceiver.storeMakeResidentAllocations = true;
|
||||
|
||||
auto memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
pKernelInfo->kernelAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
||||
MockProgram program(toClDeviceVector(*pClDevice));
|
||||
MockContext ctx;
|
||||
program.setContext(&ctx);
|
||||
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
|
||||
program.functionPointerWithIndirectAccessExists = true;
|
||||
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
|
||||
ASSERT_EQ(CL_SUCCESS, kernel->initialize());
|
||||
|
||||
EXPECT_TRUE(kernel->getHasIndirectAccess());
|
||||
|
||||
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(KernelResidencyTest, givenKernelWithExternalFunctionWithIndirectAccessButNoUseStackCallsAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToFalse) {
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.DetectIndirectAccessInKernel.set(1);
|
||||
auto pKernelInfo = std::make_unique<KernelInfo>();
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 1;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgLoad = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgStore = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess = false;
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.flags.useStackCalls = false;
|
||||
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
commandStreamReceiver.storeMakeResidentAllocations = true;
|
||||
|
||||
auto memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
pKernelInfo->kernelAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
||||
MockProgram program(toClDeviceVector(*pClDevice));
|
||||
MockContext ctx;
|
||||
program.setContext(&ctx);
|
||||
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
|
||||
program.functionPointerWithIndirectAccessExists = true;
|
||||
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
|
||||
ASSERT_EQ(CL_SUCCESS, kernel->initialize());
|
||||
|
||||
EXPECT_FALSE(kernel->getHasIndirectAccess());
|
||||
|
||||
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(KernelResidencyTest, givenKernelWithPtrByValueArgumentAndDetectIndirectAccessInKernelEnabledThenKernelHasIndirectAccessIsSetToTrue) {
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.DetectIndirectAccessInKernel.set(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -55,6 +55,7 @@ class MockProgram : public Program {
|
||||
using Program::deviceBuildInfos;
|
||||
using Program::disableZebinIfVmeEnabled;
|
||||
using Program::extractInternalOptions;
|
||||
using Program::functionPointerWithIndirectAccessExists;
|
||||
using Program::getKernelInfo;
|
||||
using Program::getModuleAllocations;
|
||||
using Program::internalOptionsToExtract;
|
||||
|
||||
Reference in New Issue
Block a user