Remove Support for reading a function pointer of a kernel

Signed-off-by: Neil R Spruit <neil.r.spruit@intel.com>
This commit is contained in:
Neil R Spruit
2022-07-26 03:31:38 +00:00
committed by Compute-Runtime-Automation
parent 84f19a1b93
commit 8d5792abf6
2 changed files with 5 additions and 25 deletions

View File

@@ -906,30 +906,12 @@ bool ModuleImp::linkBinary() {
}
ze_result_t ModuleImp::getFunctionPointer(const char *pFunctionName, void **pfnFunction) {
// Check if the function is in the exported symbol table
// Check if the function is in the exported symbol table, if the symbol cannot be found then this function name is invalid.
auto symbolIt = symbols.find(pFunctionName);
if ((symbolIt != symbols.end()) && (symbolIt->second.symbol.segment == NEO::SegmentType::Instructions)) {
*pfnFunction = reinterpret_cast<void *>(symbolIt->second.gpuAddress);
}
// If the Function Pointer is not in the exported symbol table, then this function might be a kernel.
// Check if the function name matches a kernel and return the gpu address to that function
if (*pfnFunction == nullptr) {
auto kernelImmData = this->getKernelImmutableData(pFunctionName);
if (kernelImmData != nullptr) {
auto isaAllocation = kernelImmData->getIsaGraphicsAllocation();
*pfnFunction = reinterpret_cast<void *>(isaAllocation->getGpuAddress());
// Ensure that any kernel in this module which uses this kernel module function pointer has access to the memory.
for (auto &data : this->getKernelImmutableDataVector()) {
if (data.get() != kernelImmData) {
data.get()->getResidencyContainer().insert(data.get()->getResidencyContainer().end(), isaAllocation);
}
}
}
}
if (*pfnFunction == nullptr) {
if ((symbolIt == symbols.end()) || (symbolIt->second.symbol.segment != NEO::SegmentType::Instructions)) {
return ZE_RESULT_ERROR_INVALID_FUNCTION_NAME;
}
*pfnFunction = reinterpret_cast<void *>(symbolIt->second.gpuAddress);
return ZE_RESULT_SUCCESS;
}

View File

@@ -1789,7 +1789,7 @@ TEST_F(ModuleFunctionPointerTests, givenInvalidFunctionNameAndModuleWithExported
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_FUNCTION_NAME, res);
}
TEST_F(ModuleFunctionPointerTests, givenModuleWithExportedSymbolThenGetFunctionPointerReturnsGpuAddressToKernelFunction) {
TEST_F(ModuleFunctionPointerTests, givenModuleWithExportedKernelThenGetFunctionPointerOfKernelFunctionReturnsInvalidFunctionName) {
uint64_t gpuAddress = 0x12345;
@@ -1819,9 +1819,7 @@ TEST_F(ModuleFunctionPointerTests, givenModuleWithExportedSymbolThenGetFunctionP
void *functionPointer = nullptr;
ze_result_t res = module0->getFunctionPointer("kernelFunction", &functionPointer);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(reinterpret_cast<uint64_t>(functionPointer), module0->kernelImmDatas[0]->getIsaGraphicsAllocation()->getGpuAddress());
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_FUNCTION_NAME, res);
}
class DeviceModuleSetArgBufferTest : public ModuleFixture, public ::testing::Test {