- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'd like to know if there is a way to execute a parallel_for kernel with a single thread in the case of cpu device, or in general if it was possible to specify the degree of parallelism.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
--" Is it possible to set the number of actual cpu threads/core on which these work-item will be executed?"
yes, it is possible to set the number of CPU cores to be used for kernel execution. Export the below mentioned environmental variable and launch your application.
export DPCPP_CPU_NUM_CUS=<no. of CPU core to be used>
> export DPCPP_CPU_NUM_CUS=5
Please refer to the below developer guide for more details. Check the flags under DPC++ Environment Variables Section at the end.
Please let us know if the provided information helped.
Thanks & Regards
Goutham
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In SYCL, kernels can be invoked using either of the below SYCL functions.
· single_task
· parallel_for
· parallel_for_work_group
As per the query which you have asked, i.e “I'd like to know if there is a way to execute a parallel_for kernel with a single thread”.
Yes, it is very much possible to execute a kernel with a single instance. You can do it using either one of the following methods.
1. Using single_task: Only one instance of the kernel will be executed with a single work item.
myQueue.submit([&](handler & cgh) {
cgh.single_task<class kernel_name>([=] () {
// [kernel code]
});
});
2. Using parallel_for: Execute a kernel in parallel across a range of specified processing elements.
myQueue.submit([&](handler & cgh) {
cgh.parallel_for<class myKernel>(range<1>(numWorkItems),[=](id<1> myID) {
//[kernel code]
});
});
Here, if you want to invoke the kernel with only one thread then specify the numWorkItems=1
You can refer to the below oneapi-programming guide for more information.
And, regarding “in general if it was possible to specify the degree of parallelism”. Could you please elaborate on what exactly you are looking for?
Regards
Goutham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What I mean is: I have my kernel with a certain range (greater than 1) that is executed on cpu device. Is it possible to set the number of actual cpu threads/core on which these work-item will be executed? For example, if I have a cpu with 12 threads, can I specify to use only 1 thread or 4 threads ( or in general n of these threads) to execute my kernel? Something like "tbb::global_control::max_allowed_parallelism" of TBB but that works also in the "parallel_for" case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Apologies for the delay!
We are looking into your query with the internal engineering team. We will get back to you soon.
Thanks & Regards
Goutham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
--" Is it possible to set the number of actual cpu threads/core on which these work-item will be executed?"
yes, it is possible to set the number of CPU cores to be used for kernel execution. Export the below mentioned environmental variable and launch your application.
export DPCPP_CPU_NUM_CUS=<no. of CPU core to be used>
> export DPCPP_CPU_NUM_CUS=5
Please refer to the below developer guide for more details. Check the flags under DPC++ Environment Variables Section at the end.
Please let us know if the provided information helped.
Thanks & Regards
Goutham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Glad to know that your issue is resolved!
Could you please confirm, if we can close this thread from our side?
Regards
Goutham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the confirmation.
Intel will no longer monitor this thread. However, it will remain open, to allow community members to participate.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page