This question might be trivial, unfortunately I haven't found the answer I was looking for.
I used dpct
migration tool to port some cuda code to Intel DPC++ and then I further optimized everything I needed and eventually got rid of everything related to dpct
expect the super handy
dpct::get_current_device();
which basically solves all the previous pain I had to put compile options to select the appropriate device and control them with Makefiles and so on.
Is there any way to do this without using dpct ? I had a look at how dpct does this (here) but it looks pretty non-straightforward and it relies on other internal functions.
Is there any way to avoid this ?
I'm not totally clear from your question whether you want to 1) grab a handle to your device or 2) select a device on which to run stuff, so I'll try to answer both. Note that dpct::get_current_device()
isn't actually selecting a device, it's just returning the device which you have already selected earlier in your program.
sycl::queue
, which we use to submit kernels, memory copy operations etc. From a sycl::queue
you can access your device with:sycl::device d = q.get_device();
sycl::queue q{sycl::gpu_selector()};
sycl::queue q{sycl::cpu_selector()};
sycl::queue q{sycl::default_selector()};
Note that the last option (sycl::default_selector()
) is probably what dpct
is currently doing for you.