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

TBB and NUMA

velvia
Beginner
511 Views

Hi,

I would like to use TBB on a bi-Xeon plateform and I would like to use the first-touch policy to commit my array so half of it is bound to the first CPU and half of it is bound to the second CPU. Obivously, I want to use the cache-affinity partitioner so I can later use the same mapping in between tasks and cores.

How can I do that?

Best regards,

Francois

0 Kudos
1 Solution
Alexei_K_Intel
Employee
511 Views

Unfortunately no, but it may give some distribution. Perhaps, you may want to try tbb::static_partitioner that can achieve uniform distribution. However, it is a Community Preview feature and available only in recent versions.

View solution in original post

0 Kudos
4 Replies
Alexei_K_Intel
Employee
511 Views

Hi Francois,

The simplest way is to initialize the data structures with tbb::parallel_for. Try something like

tbb::affinity_partitioner ap;
tbb::parallel_for(0, N, [&array] (int i) {
    array = 0;
}, ap );

I hope it will help. 

Regards, Alex

0 Kudos
velvia
Beginner
511 Views

Hi Alex,

Is there anything in this loop that guarantees us that half of the tasks will be sent to the first CPU and half of them will be sent to the second one?

0 Kudos
Alexei_K_Intel
Employee
512 Views

Unfortunately no, but it may give some distribution. Perhaps, you may want to try tbb::static_partitioner that can achieve uniform distribution. However, it is a Community Preview feature and available only in recent versions.

0 Kudos
velvia
Beginner
511 Views

Thanks for the hint Alexei. I'll give it a try.

0 Kudos
Reply