Skip to content

[UR][DeviceSanitizer] Do not print error log for unsupported feature in urProgramBuildExp. #18022

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 4 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// REQUIRES: linux, cpu || (gpu && level_zero)
// RUN: %{build} %device_asan_flags -o %t.out
// RUN: %{run} %t.out 2>&1 | FileCheck %s

#include <sycl/detail/core.hpp>

void test() {
sycl::queue Q;
sycl::buffer<int> A{1};
Q.submit([&](sycl::handler &h) {
sycl::accessor A_acc(A, h);

h.single_task([=]() { A_acc[0] = 88; });
});
}

// CHECK-NOT: <SANITIZER>[ERROR]: Printing build log for program

int main() {
test();
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild(
auto UrRes = pfnProgramBuild(hContext, hProgram, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLog(hProgram, Devices.data(), Devices.size());
PrintUrBuildLogIfError(UrRes, hProgram, Devices.data(), Devices.size());
return UrRes;
}

Expand Down Expand Up @@ -355,7 +355,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp(

auto UrRes = pfnBuildExp(hProgram, numDevices, phDevices, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLog(hProgram, phDevices, numDevices);
PrintUrBuildLogIfError(UrRes, hProgram, phDevices, numDevices);
return UrRes;
}

Expand Down Expand Up @@ -388,7 +388,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink(
auto UrRes = pfnProgramLink(hContext, count, phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLog(*phProgram, Devices.data(), Devices.size());
PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size());
return UrRes;
}

Expand Down Expand Up @@ -426,7 +426,7 @@ ur_result_t UR_APICALL urProgramLinkExp(
auto UrRes = pfnProgramLinkExp(hContext, numDevices, phDevices, count,
phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLog(*phProgram, phDevices, numDevices);
PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices);
return UrRes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ ur_result_t urProgramBuild(
auto UrRes = pfnProgramBuild(hContext, hProgram, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLog(hProgram, Devices.data(), Devices.size());
PrintUrBuildLogIfError(UrRes, hProgram, Devices.data(), Devices.size());
return UrRes;
}

Expand All @@ -294,7 +294,7 @@ ur_result_t urProgramBuildExp(

auto UrRes = pfnBuildExp(hProgram, numDevices, phDevices, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLog(hProgram, phDevices, numDevices);
PrintUrBuildLogIfError(UrRes, hProgram, phDevices, numDevices);
return UrRes;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ ur_result_t urProgramLink(
auto UrRes = pfnProgramLink(hContext, count, phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLog(*phProgram, Devices.data(), Devices.size());
PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size());
return UrRes;
}

Expand Down Expand Up @@ -357,7 +357,7 @@ ur_result_t urProgramLinkExp(
auto UrRes = pfnProgramLinkExp(hContext, numDevices, phDevices, count,
phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLog(*phProgram, phDevices, numDevices);
PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices);
return UrRes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,34 +256,38 @@ ur_result_t EnqueueUSMBlockingSet(ur_queue_handle_t Queue, void *Ptr,
Queue, Ptr, 1, &Value, Size, NumEvents, EventWaitList, OutEvent);
}

void PrintUrBuildLog(ur_program_handle_t hProgram,
ur_device_handle_t *phDevices, size_t numDevices) {
void PrintUrBuildLogIfError(ur_result_t Result, ur_program_handle_t Program,
ur_device_handle_t *Devices, size_t NumDevices) {
if (Result == UR_RESULT_SUCCESS ||
Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE)
return;

getContext()->logger.error("Printing build log for program {}",
(void *)hProgram);
for (size_t i = 0; i < numDevices; i++) {
(void *)Program);
for (size_t I = 0; I < NumDevices; I++) {
std::vector<char> LogBuf;
size_t LogSize = 0;
auto hDevice = phDevices[i];
auto Device = Devices[I];

auto UrRes = getContext()->urDdiTable.Program.pfnGetBuildInfo(
hProgram, hDevice, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &LogSize);
Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &LogSize);
if (UrRes != UR_RESULT_SUCCESS) {
getContext()->logger.error("For device {}: failed to get build log size.",
(void *)hDevice);
(void *)Device);
continue;
}

LogBuf.resize(LogSize);
UrRes = getContext()->urDdiTable.Program.pfnGetBuildInfo(
hProgram, hDevice, UR_PROGRAM_BUILD_INFO_LOG, LogSize, LogBuf.data(),
Program, Device, UR_PROGRAM_BUILD_INFO_LOG, LogSize, LogBuf.data(),
nullptr);
if (UrRes != UR_RESULT_SUCCESS) {
getContext()->logger.error("For device {}: failed to get build log.",
(void *)hDevice);
(void *)Device);
continue;
}

getContext()->logger.error("For device {}:\n{}", (void *)hDevice,
getContext()->logger.error("For device {}:\n{}", (void *)Device,
LogBuf.data());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EnqueueUSMBlockingSet(ur_queue_handle_t Queue, void *Ptr, char Value,
const ur_event_handle_t *EventWaitList = nullptr,
ur_event_handle_t *OutEvent = nullptr);

void PrintUrBuildLog(ur_program_handle_t hProgram,
ur_device_handle_t *phDevices, size_t numDevices);
void PrintUrBuildLogIfError(ur_result_t Result, ur_program_handle_t Program,
ur_device_handle_t *Devices, size_t NumDevices);

} // namespace ur_sanitizer_layer
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ ur_result_t urProgramBuild(
const char *pOptions) {
getContext()->logger.debug("==== urProgramBuild");

UR_CALL(
getContext()->urDdiTable.Program.pfnBuild(hContext, hProgram, pOptions));
auto UrRes =
getContext()->urDdiTable.Program.pfnBuild(hContext, hProgram, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLogIfError(UrRes, hProgram, Devices.data(), Devices.size());
return UrRes;
}

UR_CALL(getTsanInterceptor()->registerProgram(hProgram));

Expand All @@ -163,9 +168,13 @@ ur_result_t urProgramLink(
ur_program_handle_t *phProgram) {
getContext()->logger.debug("==== urProgramLink");

UR_CALL(getContext()->urDdiTable.Program.pfnLink(hContext, count, phPrograms,
pOptions, phProgram));

auto UrRes = getContext()->urDdiTable.Program.pfnLink(
hContext, count, phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
auto Devices = GetDevices(hContext);
PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size());
return UrRes;
}
UR_CALL(getTsanInterceptor()->registerProgram(*phProgram));

return UR_RESULT_SUCCESS;
Expand All @@ -184,8 +193,12 @@ ur_result_t urProgramBuildExp(
const char *pOptions) {
getContext()->logger.debug("==== urProgramBuildExp");

UR_CALL(getContext()->urDdiTable.ProgramExp.pfnBuildExp(hProgram, numDevices,
phDevices, pOptions));
auto UrRes = getContext()->urDdiTable.ProgramExp.pfnBuildExp(
hProgram, numDevices, phDevices, pOptions);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLogIfError(UrRes, hProgram, phDevices, numDevices);
return UrRes;
}
UR_CALL(getTsanInterceptor()->registerProgram(hProgram));

return UR_RESULT_SUCCESS;
Expand All @@ -209,8 +222,12 @@ ur_result_t urProgramLinkExp(
ur_program_handle_t *phProgram) {
getContext()->logger.debug("==== urProgramLinkExp");

UR_CALL(getContext()->urDdiTable.ProgramExp.pfnLinkExp(
hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram));
auto UrRes = getContext()->urDdiTable.ProgramExp.pfnLinkExp(
hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram);
if (UrRes != UR_RESULT_SUCCESS) {
PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices);
return UrRes;
}

UR_CALL(getTsanInterceptor()->registerProgram(*phProgram));

Expand Down
Loading