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

Diagnostic console output

Penunuri__David
Beginner
501 Views

I am putting some diagnostic console output statements in my code which uses TBB like

cout << "blah..blah..blah" << endl;

It is hard to read the results because the different threads are mixing their output on the console.

HOW DO I FIX THIS (IGNORING FOR THE MOMENT THE PERFORMANCE IMPACT)?

I tried to search the forum with no luck.  I know in pthreads I could lock/unlock a section of code using a mutex.  It is not clear how to do this in TBB.

0 Kudos
1 Reply
Nikita_P_Intel
Employee
501 Views

Hi David,

you can just set the number of threads to 1 for debugging purpose via tbb::task_scheduler_init(1), or use one of tbb::mutex classes to surround and protect your output.

-- Nikita

0 Kudos
Reply