Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Zhongze_L_
Beginner
91 Views

number of cores

Hi,

Does anybody know how to get the number of cores in TBB?

Thanks,
Zhongze
0 Kudos
7 Replies
91 Views

Hi Zhongze,

tbb::task_scheduler_init::default_num_threads() returns the number of threads that the task scheduler will use by default. Often this is equal to the number of cores, but I don't know how hyperthreading CPUs are treated.

Regards,
Christian

Andrey_Marochko
New Contributor III
91 Views

Each HT (or "logical") core is treated in the same way as a full core.

AJ13
New Contributor I
91 Views

Hi Zhongze,

If you don't mind my asking, what do you need to know the number of cores for?

AJ
Alexey_K_Intel3
Employee
91 Views

MADamarochk:
Each HT (or "logical") core is treated in the same way as a full core.

I would add that this may change in future.

Andrey_Marochko
New Contributor III
91 Views

To complete the picture, TBB sees only those CPUs/cores (HT or full) that are enabled by the BIOS and OS.

Zhongze_L_
Beginner
91 Views


I need that number in order to partition a graph. It doesn't make sense to partition a graph into 16 subgraphs on a dual core machine or partition a graph into 2 subgraphs on a quad-core machine.

Thanks,
Zhongze
Andrey_Marochko
New Contributor III
91 Views

Hi, Zhongze

As I explained in the answer to your other post, you most probably do not need to know the number of cores at all, since the degree of partitioning should depend on the amount of work necessary to process each subgraph. And if your sparse matrices are really large, then you should partition the graph in much more parts then the number of cores.

In fact partitioning into 16 (or even more) subgrapphs on dualcore machine usually makes perfect sence, as the work distribution across the subgraphs is normally very nonuniform (this is one of the problems with running MPI version of this algorithm on the grids). TBB applications running on shared memory systems can benefit from fine grained parallelism. Follow the link above for more details.
Reply