I'm not sure this question is correctly formulated, I'm still learning.
I was wondering if there is a way, when I run a sycl program with a cpu_selector
to get if I'm using it as single core or multi core
This is sort of possible using sycl::info::device::max_compute_units
. Here's a minimal example:
#include <CL/sycl.hpp>
#include <iostream>
int main(){
sycl::device d = sycl::cpu_selector().select_device();
std::cout << d.get_info<sycl::info::device::max_compute_units>() << std::endl;
}
On my machine (which has 8 physical cores & 16 hardware threads), this returns 16
.
I think it is generally true that OpenCL considers hardware threads to be 'compute units', but I can't confirm this. Furthermore, it'll only tell you how many hardware threads the OpenCL backend considers are present, not how many you are using.
Edit for follow up question:
I think the OpenCL backend will always use all available resources. However, if you're working on a CPU, you can limit available threads using taskset
. For example, if I set the mask to use only thread 0:
taskset 0x00000001 ./a.out
I get the answer 1
.