Skip to content

[DeviceSanitizer] Remove device global "__AsanDeviceGlobalCount" #1584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 19, 2024
Merged
21 changes: 12 additions & 9 deletions source/loader/layers/sanitizer/asan_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,22 +415,25 @@ ur_result_t SanitizerInterceptor::registerProgram(ur_context_handle_t Context,
for (auto Device : Devices) {
ManagedQueue Queue(Context, Device);

uint64_t NumOfDeviceGlobal;
size_t MetadataSize;
void *MetadataPtr;
auto Result =
getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead(
Queue, Program, kSPIR_AsanDeviceGlobalCount, true,
sizeof(NumOfDeviceGlobal), 0, &NumOfDeviceGlobal, 0, nullptr,
nullptr);
getContext()->urDdiTable.Program.pfnGetGlobalVariablePointer(
Device, Program, kSPIR_AsanDeviceGlobalMetadata, &MetadataSize,
&MetadataPtr);
if (Result != UR_RESULT_SUCCESS) {
getContext()->logger.info("No device globals");
continue;
}

const uint64_t NumOfDeviceGlobal =
MetadataSize / sizeof(DeviceGlobalInfo);
assert((MetadataSize % sizeof(DeviceGlobalInfo) == 0) &&
"DeviceGlobal metadata size is not correct");
std::vector<DeviceGlobalInfo> GVInfos(NumOfDeviceGlobal);
Result = getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead(
Queue, Program, kSPIR_AsanDeviceGlobalMetadata, true,
sizeof(DeviceGlobalInfo) * NumOfDeviceGlobal, 0, &GVInfos[0], 0,
nullptr, nullptr);
Result = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy(
Queue, true, &GVInfos[0], MetadataPtr,
sizeof(DeviceGlobalInfo) * NumOfDeviceGlobal, 0, nullptr, nullptr);
if (Result != UR_RESULT_SUCCESS) {
getContext()->logger.error("Device Global[{}] Read Failed: {}",
kSPIR_AsanDeviceGlobalMetadata, Result);
Expand Down
1 change: 0 additions & 1 deletion source/loader/layers/sanitizer/asan_libdevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const int kPrivateLeftRedzoneMagic = (char)0xf1;
const int kPrivateMidRedzoneMagic = (char)0xf2;
const int kPrivateRightRedzoneMagic = (char)0xf3;

constexpr auto kSPIR_AsanDeviceGlobalCount = "__AsanDeviceGlobalCount";
constexpr auto kSPIR_AsanDeviceGlobalMetadata = "__AsanDeviceGlobalMetadata";

inline const char *ToString(DeviceSanitizerMemoryType MemoryType) {
Expand Down
Loading