@@ -35,6 +35,42 @@ cl::sycl::queue* backend_sycl::queue = nullptr;
35
35
#endif
36
36
mkl_rng::mt19937* backend_sycl::rng_engine = nullptr ;
37
37
38
+ static void show_avalable_sycl_devices ()
39
+ {
40
+ const std::vector<cl::sycl::device> devices = cl::sycl::device::get_devices ();
41
+
42
+ std::cout << " Available SYCL devices:" << std::endl;
43
+ for (std::vector<cl::sycl::device>::const_iterator it = devices.cbegin (); it != devices.cend (); ++it)
44
+ {
45
+ std::cout
46
+ // not yet implemented error << " " << it->has(sycl::aspect::usm_shared_allocations) << " "
47
+ << " - id=" << it->get_info <cl::sycl::info::device::vendor_id>()
48
+ << " , type=" << static_cast <pi_uint64>(it->get_info <cl::sycl::info::device::device_type>())
49
+ << " , gws=" << it->get_info <cl::sycl::info::device::max_work_group_size>()
50
+ << " , cu=" << it->get_info <cl::sycl::info::device::max_compute_units>()
51
+ << " , name=" << it->get_info <cl::sycl::info::device::name>() << std::endl;
52
+ }
53
+ }
54
+
55
+ static cl::sycl::device get_default_sycl_device ()
56
+ {
57
+ int dpnpc_queue_gpu = 0 ;
58
+ cl::sycl::device dev = cl::sycl::device (cl::sycl::cpu_selector ());
59
+
60
+ const char * dpnpc_queue_gpu_var = getenv (" DPNPC_QUEUE_GPU" );
61
+ if (dpnpc_queue_gpu_var != NULL )
62
+ {
63
+ dpnpc_queue_gpu = atoi (dpnpc_queue_gpu_var);
64
+ }
65
+
66
+ if (dpnpc_queue_gpu)
67
+ {
68
+ dev = cl::sycl::device (cl::sycl::gpu_selector ());
69
+ }
70
+
71
+ return dev;
72
+ }
73
+
38
74
/* *
39
75
* Function push the SYCL kernels to be linked (final stage of the compilation) for the current queue
40
76
*
@@ -89,14 +125,22 @@ void backend_sycl::backend_sycl_queue_init(QueueOptions selector)
89
125
90
126
cl::sycl::device dev;
91
127
128
+ #if not defined(NDEBUG)
129
+ show_avalable_sycl_devices ();
130
+ #endif
131
+
92
132
if (QueueOptions::CPU_SELECTOR == selector)
93
133
{
94
134
dev = cl::sycl::device (cl::sycl::cpu_selector ());
95
135
}
96
- else
136
+ else if (QueueOptions::GPU_SELECTOR == selector)
97
137
{
98
138
dev = cl::sycl::device (cl::sycl::gpu_selector ());
99
139
}
140
+ else
141
+ {
142
+ dev = get_default_sycl_device ();
143
+ }
100
144
101
145
queue = new cl::sycl::queue (dev, exception_handler);
102
146
0 commit comments