文件名称:一个简单的OpenMP程序实例-OpenMP简介
文件大小:295KB
文件格式:PPT
更新时间:2024-05-13 02:10:55
OpenMP
一个简单的OpenMP程序实例 基于C/C++语言的OpenMP程序结构的一个具体实现 #include "omp.h“//eg1 int main(int argc, char* argv[]) { int nthreads, tid; int nprocs; char buf[32]; /* Fork a team of threads */ #pragma omp parallel private(nthreads, tid) { /* Obtain and print thread id */ tid = omp_get_thread_num(); printf("Hello World from OMP thread %d\n", tid); /* Only master thread does this */ if (tid==0) { nthreads = omp_get_num_threads(); printf("Number of threads %d\n", nthreads); } } return 0; }