0

I am using Intel TBB to speed up a problem in graphics domain. I want to analyze the scalability of my method.

To find the scalability I want run the same algorithm using 1, 2, 3 and 4 CPU cores.

Is there a way to tell TBB to use 2 & 3 cores while running the tests on a 4 core CPU.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847

1 Answers1

2

Yes, there is a way to do that:

The task_scheduler_init class lets you do that. You have to pass the constructor of the class the number of threads you want to use. You also have to make sure that all your TBB code runs after the instance is constructed and before it is destroyed.

Usually, it is sufficient to declare it as a variable in the main function, like this:

int main()
{
    tbb::task_scheduler_init init(3);//three threads
    do_the_work();
}
dokis
  • 36
  • 4