openmp--test how many threads used

来源:互联网 发布:itools mac版 破解 编辑:程序博客网 时间:2024/05/20 05:09

should add the compiler directive:

#include <stdio.h>#include <omp.h>int main(){int tid;#pragma omp parallel    tid = omp_get_num_threads();  printf("thread = %d\n",tid);return 0;}

results:

thread = 8


if do not add the compile directive:

#include <stdio.h>#include <omp.h>int main(){int tid;  tid = omp_get_num_threads();  printf("thread = %d\n",tid);return 0;}

the result will be 

thread = 1

原创粉丝点击