Skip to content

Commit 82bc212

Browse files
adurangCopilot
andauthored
[OFFLOAD][L0] Also lookup for function symbols in getOffloadVarDeviceAddr (#20771)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f58c41a commit 82bc212

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

offload/plugins-nextgen/level_zero/src/L0DynWrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ DLWRAP(zeMemGetAddressRange, 4)
8181
DLWRAP(zeMemGetAllocProperties, 4)
8282
DLWRAP(zeModuleDynamicLink, 3)
8383
DLWRAP(zeModuleGetGlobalPointer, 4)
84+
DLWRAP(zeModuleGetFunctionPointer, 3)
8485
DLWRAP(zeModuleGetNativeBinary, 3)
8586
DLWRAP(zesDeviceEnumMemoryModules, 3)
8687
DLWRAP(zesMemoryGetState, 2)

offload/plugins-nextgen/level_zero/src/L0Program.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,19 +459,20 @@ Expected<void *> L0ProgramTy::getOffloadVarDeviceAddr(const char *CName) const {
459459
return Plugin::error(ErrorCode::INVALID_ARGUMENT,
460460
"Invalid arguments to getOffloadVarDeviceAddr");
461461

462-
std::string Name(CName);
463462
size_t SizeDummy = 0;
464463
void *DevicePtr = nullptr;
465464
ze_result_t RC;
466465
for (auto Module : Modules) {
467-
CALL_ZE(RC, zeModuleGetGlobalPointer, Module, Name.c_str(), &SizeDummy,
466+
CALL_ZE(RC, zeModuleGetGlobalPointer, Module, CName, &SizeDummy,
468467
&DevicePtr);
469468
if (RC == ZE_RESULT_SUCCESS && DevicePtr)
470469
return DevicePtr;
470+
CALL_ZE(RC, zeModuleGetFunctionPointer, Module, CName, &DevicePtr);
471+
if (RC == ZE_RESULT_SUCCESS && DevicePtr)
472+
return DevicePtr;
471473
}
472474
return Plugin::error(ErrorCode::INVALID_ARGUMENT,
473-
"Global variable '%s' not found on device",
474-
Name.c_str());
475+
"Symbol '%s' not found on device", CName);
475476
}
476477

477478
Error L0ProgramTy::readGlobalVariable(const char *Name, size_t Size,

0 commit comments

Comments
 (0)