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
196 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
196 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

4 Replies
Alexei_K_Intel
Employee
196 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

velvia
Beginner
196 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?

Alexei_K_Intel
Employee
197 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.

velvia
Beginner
196 Views

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

Reply