-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Add device_type to SYCL_PI_TRACE and device_selector exception (…
…#6896) Device selector exception message and SYCL_PI_TRACE are extended with device type info for better debuggability in case of missed device in application that works with multiple devices. Current exception message: ``` No device of requested type available. -1 (PI_ERROR_DEVICE_NOT_FOUND) # in case of any device selector ``` Example of the current output from SYCL_PI_TRACE: ``` SYCL_PI_TRACE[all]: Selected device: -> final score = 1000 SYCL_PI_TRACE[all]: platform: Intel(R) OpenCL SYCL_PI_TRACE[all]: device: Intel(R) Xeon(R) Gold 6354 CPU @ 3.00GHz ``` New exception message: ``` No device of requested type available. -1 (PI_ERROR_DEVICE_NOT_FOUND) # in case of custom/default selector No device of requested type 'info::device_type::gpu' available. -1 (PI_ERROR_DEVICE_NOT_FOUND) # in case of gpu selector No device of requested type 'info::device_type::cpu' available. -1 (PI_ERROR_DEVICE_NOT_FOUND) # in case of cpu selector No device of requested type 'info::device_type::accelerator' available. -1 (PI_ERROR_DEVICE_NOT_FOUND) # in case of accelerator selector ``` Example of SYCL_PI_TRACE output with extra line about requested device_type: ``` SYCL_PI_TRACE[all]: Requested device_type: info::device_type::cpu SYCL_PI_TRACE[all]: Selected device: -> final score = 1000 SYCL_PI_TRACE[all]: platform: Intel(R) OpenCL SYCL_PI_TRACE[all]: device: Intel(R) Xeon(R) Gold 6354 CPU @ 3.00GHz ```
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: env SYCL_DEVICE_FILTER="" %t.out | ||
|
||
#include <sycl/sycl.hpp> | ||
using namespace sycl; | ||
|
||
int refuse_any_device_f(const device &d) { return -1; } | ||
|
||
int main() { | ||
|
||
// Check exception message for custom device selector | ||
try { | ||
queue custom_queue(refuse_any_device_f); | ||
} catch (exception &E) { | ||
assert(std::string(E.what()).find("info::device_type::") == | ||
std::string::npos && | ||
"Incorrect device type in exception message for custom selector."); | ||
} | ||
|
||
// Check exception message for pre-defined devices | ||
try { | ||
queue gpu_queue(gpu_selector_v); | ||
} catch (exception &E) { | ||
assert(std::string(E.what()).find("info::device_type::gpu") != | ||
std::string::npos && | ||
"Incorrect device type in exception message for GPU device."); | ||
} | ||
try { | ||
queue cpu_queue(cpu_selector_v); | ||
} catch (exception &E) { | ||
assert(std::string(E.what()).find("info::device_type::cpu") != | ||
std::string::npos && | ||
"Incorrect device type in exception message for CPU device."); | ||
} | ||
try { | ||
queue acc_queue(accelerator_selector_v); | ||
} catch (exception &E) { | ||
assert( | ||
std::string(E.what()).find("info::device_type::accelerator") != | ||
std::string::npos && | ||
"Incorrect device type in exception message for Accelerator device."); | ||
} | ||
|
||
return 0; | ||
} |