|
| 1 | +// REQUIRES: cpu, gpu, accelerator, opencl |
| 2 | + |
| 3 | +// RUN: %clangxx -fsycl %s -o %t.out |
| 4 | + |
| 5 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:fpga %t.out | FileCheck %s --check-prefixes=CHECK-ACC-ONLY |
| 6 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %t.out | FileCheck %s --check-prefixes=CHECK-GPU-ONLY |
| 7 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %t.out | FileCheck %s --check-prefixes=CHECK-CPU-ONLY |
| 8 | + |
| 9 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:fpga,gpu %t.out | FileCheck %s --check-prefixes=CHECK-ACC-GPU |
| 10 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:fpga,cpu %t.out | FileCheck %s --check-prefixes=CHECK-ACC-CPU |
| 11 | + |
| 12 | +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu,fpga,gpu %t.out | FileCheck %s --check-prefixes=CHECK-ACC-GPU-CPU |
| 13 | +// RUN: env ONEAPI_DEVICE_SELECTOR="opencl:*" %t.out | FileCheck %s --check-prefixes=CHECK-ACC-GPU-CPU |
| 14 | +// |
| 15 | +// CHECK-ACC-ONLY-NOT: Device: cpu |
| 16 | +// CHECK-ACC-ONLY-NOT: Device: gpu |
| 17 | +// CHECK-ACC-ONLY: Device: acc |
| 18 | + |
| 19 | +// |
| 20 | +// CHECK-GPU-ONLY-NOT: Device: acc |
| 21 | +// CHECK-GPU-ONLY-NOT: Device: cpu |
| 22 | +// CHECK-GPU-ONLY: Device: gpu |
| 23 | + |
| 24 | +// |
| 25 | +// CHECK-CPU-ONLY-NOT: Device: acc |
| 26 | +// CHECK-CPU-ONLY-NOT: Device: gpu |
| 27 | +// CHECK-CPU-ONLY: Device: cpu |
| 28 | + |
| 29 | +// |
| 30 | +// CHECK-ACC-GPU-NOT: Device: cpu |
| 31 | +// CHECK-ACC-GPU-DAG: Device: acc |
| 32 | +// CHECK-ACC-GPU-DAG: Device: gpu |
| 33 | + |
| 34 | +// |
| 35 | +// CHECK-ACC-CPU-NOT: Device: gpu |
| 36 | +// CHECK-ACC-CPU-DAG: Device: acc |
| 37 | +// CHECK-ACC-CPU-DAG: Device: cpu |
| 38 | + |
| 39 | +// |
| 40 | +// CHECK-ACC-GPU-CPU-DAG: Device: acc |
| 41 | +// CHECK-ACC-GPU-CPU-DAG: Device: gpu |
| 42 | +// CHECK-ACC-GPU-CPU-DAG: Device: cpu |
| 43 | +// |
| 44 | + |
| 45 | +#include <iostream> |
| 46 | +#include <map> |
| 47 | +#include <sycl/sycl.hpp> |
| 48 | + |
| 49 | +using namespace sycl; |
| 50 | + |
| 51 | +int main() { |
| 52 | + |
| 53 | + std::map<info::device_type, std::string> m = { |
| 54 | + {info::device_type::cpu, "cpu"}, |
| 55 | + {info::device_type::gpu, "gpu"}, |
| 56 | + {info::device_type::accelerator, "acc"}, |
| 57 | + {info::device_type::all, "all"}}; |
| 58 | + |
| 59 | + for (auto &d : device::get_devices()) { |
| 60 | + std::cout << "Device: " << m[d.get_info<info::device::device_type>()] |
| 61 | + << std::endl; |
| 62 | + } |
| 63 | + |
| 64 | + return 0; |
| 65 | +} |
0 commit comments