正在加载图片...
C举例 #include <omp.h> #include <stdio.h> 头文件:omp.h int main() OpenMP指令标识符#pragma omp { int nthreads,tid; #pragma omp parallel private(nthreads,tid) tid=omp_get_thread_num();/获取线程号 printf("Hello world from OpenMP thread %d\n",tid); if (tid==0) { nthreads=:omp_get_num_threads();/获取线程个数 printf("Number of threads %d\n",nthreads); } ·编译 return 0; gcc -fopenmp OMP_hello.c http://math.ecnu.edu.cn/-jypan 10 http://math.ecnu.edu.cn/~jypan #include <omp.h> #include <stdio.h> int main() { int nthreads, tid; #pragma omp parallel private(nthreads,tid) { tid=omp_get_thread_num(); // 获取线程号 printf("Hello world from OpenMP thread %d\n", tid); if (tid==0) { nthreads=omp_get_num_threads(); // 获取线程个数 printf("Number of threads %d\n", nthreads); } } return 0; } 10 C 举例  头文件:omp.h  OpenMP 指令标识符 #pragma omp  编译 gcc –fopenmp OMP_hello.c
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有