Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

How to assign CPU to part of code

hoodibaba
Beginner
310 Views
Hello All,

I am new to parallel computing world and I want to assign some part of my code to run in CPU 1 and other on CPU 2. Can somebody help me in this regard or tell be some example.

I am asking this because in my previous thread, during the execution of program, either of the CPU was working...it was like when CPU1 runs then CPU 2 was using only 21 or 25% of resources and vice versa.

Please help me.

Thanks in advance.


0 Kudos
1 Solution
ARCH_R_Intel
Employee
310 Views
In general, TBB does not let you assign code to CPUs. Instead, you specify what could run in parallel ("potential parallelism") and the TBB run-time decides what actually is run in parallel ("actual parallelism"). It is usually best to speciffy much more potential parallelism than there are cores.

If your code can be partitioned into only a few pieces that can run in parallel, you might consider using tbb::parallel_invoke. There is an example of using it in Section 4.12 of the TBB Reference manual.

View solution in original post

0 Kudos
2 Replies
Krishna_R_Intel
Employee
310 Views
Hi,
Thanks for using the forum and please kindly excuse the delayed response. I will come back with an update or questions to you on this shortly. Appreciate your patience.

Thanks,
Krishna
0 Kudos
ARCH_R_Intel
Employee
311 Views
In general, TBB does not let you assign code to CPUs. Instead, you specify what could run in parallel ("potential parallelism") and the TBB run-time decides what actually is run in parallel ("actual parallelism"). It is usually best to speciffy much more potential parallelism than there are cores.

If your code can be partitioned into only a few pieces that can run in parallel, you might consider using tbb::parallel_invoke. There is an example of using it in Section 4.12 of the TBB Reference manual.
0 Kudos
Reply