Limit the Number of Threads Used by Parallel Frameworks
Intel® Advisor
serial
programs.
Before
you use the
Intel Advisor
Run Your Program as a Serial Program
To run the current version of your program as a serial program, you need to limit the number of threads to 1. To run your program with a single thread:
- WithIntel® oneAPI Threading Building Blocks (oneTBB), in the main thread create atbb::task_scheduler_init init(1);object for the lifetime of the program and run the executable again. For example:int main() { tbb::task_scheduler_init init(1); // ...rest of program... return 0; }The effect oftask_scheduler_initapplies separately to each user-created thread. So if the program creates threads elsewhere, you need to create atbb::task_scheduler_init init(1);for that thread's lifetime as well. Use of certainoneTBBfeatures can prevent the program from running serially. For more information, see theoneTBBdocumentation.
- With OpenMP*, do one of the following:
- Set the OpenMP* environment variableOMP_NUM_THREADSto 1 before you run the program.
- Omit the compiler option that enables recognition of OpenMP pragmas and directives. On Windows* OS, omit/Qopenmp, and on Linux* OS omit-openmp.
For more information, see your compiler documentation.
If you cannot remove the parallelism, you should add annotations to mark the parallel code regions and learn how parallel code will impact
tool reports.
Intel Advisor