Skip to content

Commit 61cb6d7

Browse files
authored
[SYCL] Add traces for SYCL_DEVICE_ALLOWLIST decisions (#17426)
Add traces to `SYCL_UR_TRACE` for filtering/allowing devices due to `SYCL_DEVICE_ALLOWLIST` in response to #17114. These traces will look like this: ``` SYCL_UR_TRACE: Device allowed by SYCL_DEVICE_ALLOWLIST SYCL_UR_TRACE: platform: Intel(R) OpenCL SYCL_UR_TRACE: device: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz ``` ``` SYCL_UR_TRACE: Device filtered by SYCL_DEVICE_ALLOWLIST SYCL_UR_TRACE: platform: Intel(R) FPGA Emulation Platform for OpenCL(TM) SYCL_UR_TRACE: device: Intel(R) FPGA Emulation Device ```
1 parent 10e1d00 commit 61cb6d7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

sycl/source/detail/allowlist.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,26 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
289289
return AllowListParsed;
290290
}
291291

292+
static void traceAllowFiltering(const DeviceDescT &DeviceDesc, bool Allowed) {
293+
bool shouldTrace = false;
294+
if (Allowed) {
295+
shouldTrace = detail::ur::trace(detail::ur::TraceLevel::TRACE_BASIC);
296+
} else {
297+
shouldTrace = detail::ur::trace(detail::ur::TraceLevel::TRACE_ALL);
298+
}
299+
300+
if (shouldTrace) {
301+
auto selectionMsg = Allowed ? "allowed" : "filtered";
302+
std::cout << "SYCL_UR_TRACE: Device " << selectionMsg
303+
<< " by SYCL_DEVICE_ALLOWLIST" << std::endl
304+
<< "SYCL_UR_TRACE: "
305+
<< " platform: " << DeviceDesc.at(PlatformNameKeyName)
306+
<< std::endl
307+
<< "SYCL_UR_TRACE: "
308+
<< " device: " << DeviceDesc.at(DeviceNameKeyName) << std::endl;
309+
}
310+
}
311+
292312
// Checking if we can allow device with device description DeviceDesc
293313
bool deviceIsAllowed(const DeviceDescT &DeviceDesc,
294314
const AllowListParsedT &AllowListParsed) {
@@ -423,9 +443,11 @@ void applyAllowList(std::vector<ur_device_handle_t> &UrDevices,
423443
DeviceDesc[DeviceNameKeyName] = DeviceNameValue;
424444

425445
// check if we can allow device with such device description DeviceDesc
426-
if (deviceIsAllowed(DeviceDesc, AllowListParsed)) {
446+
bool isAllowed = deviceIsAllowed(DeviceDesc, AllowListParsed);
447+
if (isAllowed) {
427448
UrDevices[InsertIDx++] = Device;
428449
}
450+
traceAllowFiltering(DeviceDesc, isAllowed);
429451
}
430452
UrDevices.resize(InsertIDx);
431453
}

0 commit comments

Comments
 (0)