OpenMP: Get total number of running threads

后端 未结 3 589
囚心锁ツ
囚心锁ツ 2021-02-19 02:38

I need to know the total number of threads that my application has spawned via OpenMP. Unfortunately, the omp_get_num_threads() function does not w

3条回答
  •  萌比男神i
    2021-02-19 03:31

    The code you have shown has a problem in that an "omp section" has to be within the lexical scope of an "omp sections". I am assuming that you meant the "omp parallel" to be an "omp parallel sections". The other way to do this, is to use "omp task" and then you don't have to keep count of the number of threads. You would just assign the threads to the parallel region and allow the OpenMP implementation to assign the tasks to the threads.

提交回复
热议问题