略去导航.
主页
The image verification code you entered is incorrect.

发现Fedora 7 上gcc和gfortran都能支持openmp

争取以后让 charmm也能支持上。
举个Intel OpenMP的例子,fortran语言

!$omp parallel
!$omp critical
print *,'hello world'
!$omp end critical
!$omp end parallel

end

编译方法

gfortran -fopenmp hello.f -o hellof

C语言的更简单

#include "stdio.h"
//#include "omp.h" 如果用intel的icc 编译器,就要写上这行
int main()
{
#pragma omp parallel
printf("Hello World\n");
return 0;
}

编译方法

gcc -fopenmp hello.c -o helloc

执行方法

OMP_NUM_THREADS=2 ./hellof
OMP_NUM_THREADS=2 ./helloc

如果不定义OMP_NUM_THREADS,默认会等于CPU数量,在8核心的机器上,会打印出8行"Hello World",爽!!!

回复

  • 允许 HTML标签: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 行和段被自动切分。
  • 你可以用[inline:xx] 标记来内嵌显示上传的文件或者图片。
更多格式化选项信息 Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.