开发者

Can't get OpenMP to Produce More than One Thread

#include <omp.h>
#include <stdio.h>


int main(int argc, char* a开发者_开发知识库rgv[])
{
 omp_set_num_threads(4);
 printf("numThreads = %d\n", omp_get_num_threads());
}

This code prints:

numThreads = 1

This is compiled in Visual Studio 2010 Ultimate. I have turned Project Configuration Properties (All Configurations) -> C/C++ -> Language -> Open MP Support to Yes(/openmp)

I'm at a loss. I've isolated this issue from a larger project where I'd like to use more than one thread.

Any ideas?


omp_get_num_threads – Size of the active team

Returns the number of threads in the current team. In a sequential section of the program omp_get_num_threads returns 1.

http://gcc.gnu.org/onlinedocs/libgomp/omp_005fget_005fnum_005fthreads.html#omp_005fget_005fnum_005fthreads

This means, use this function inside of parallel loop to know how many thread OMP uses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜