|
| 1 | +// RUN: %clangxx -fsycl %s -o %t.out |
| 2 | +// RUN: env SYCL_DEVICE_TYPE=cpu %t.out |
| 3 | +// RUN: env SYCL_DEVICE_TYPE=gpu %t.out |
| 4 | +// RUN: env SYCL_DEVICE_TYPE=acc %t.out |
| 5 | +// RUN: env SYCL_DEVICE_TYPE=host %t.out |
| 6 | +// RUN: env SYCL_DEVICE_TYPE=CPU %t.out |
| 7 | +// RUN: env SYCL_DEVICE_TYPE=GPU %t.out |
| 8 | +// RUN: env SYCL_DEVICE_TYPE=ACC %t.out |
| 9 | +// RUN: env SYCL_DEVICE_TYPE=HOST %t.out |
| 10 | +// RUN: env SYCL_DEVICE_TYPE=Cpu %t.out |
| 11 | +// RUN: env SYCL_DEVICE_TYPE=Gpu %t.out |
| 12 | +// RUN: env SYCL_DEVICE_TYPE=Acc %t.out |
| 13 | +// RUN: env SYCL_DEVICE_TYPE=Host %t.out |
| 14 | +// RUN: env SYCL_DEVICE_TYPE=XPU %t.out |
| 15 | + |
| 16 | +//==------------------- device-check.cpp --------------------------==// |
| 17 | +// This is a diagnostic test which ensures that |
| 18 | +// device types are case-insensitive. |
| 19 | +// It also checks for SYCL_DEVICE being set incorrectly. |
| 20 | +//==---------------------------------------------------------------==// |
| 21 | + |
| 22 | +#include <CL/sycl.hpp> |
| 23 | +#include <iostream> |
| 24 | + |
| 25 | +using namespace cl::sycl; |
| 26 | + |
| 27 | + |
| 28 | +int main() { |
| 29 | + try { |
| 30 | + queue q = queue(); |
| 31 | + auto device = q.get_device(); |
| 32 | + auto deviceName = device.get_info<cl::sycl::info::device::name>(); |
| 33 | + std::cout << " Device Name: " << deviceName << std::endl; |
| 34 | + } |
| 35 | + |
| 36 | + catch (runtime_error &E) { |
| 37 | + if (std::string(E.what()).find( |
| 38 | + "SYCL_DEVICE_TYPE is not recognized. Must be GPU, CPU, ACC or HOST.") == |
| 39 | + std::string::npos) { |
| 40 | + std::cout << "Test failed: received error is incorrect." << std::endl; |
| 41 | + return 1; |
| 42 | + } else { |
| 43 | + std::cout << "Test passed: caught the expected error." << std::endl; |
| 44 | + return 0; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + std::cout << "Test passed: results are correct." << std::endl; |
| 49 | + return 0; |
| 50 | +} |
0 commit comments