C++ Code::Blocks + MinGW 配置 OpenMP 和例子

http://forums.codeblocks.org/index.php?topic=13104.0

 

配置OpenMP:

1. "Settings -> Compiler and debugger setting-> Compiler settings-> Other options", 加入"-fopenmp”

C++ Code::Blocks + MinGW 配置 OpenMP 和例子_第1张图片

 

2. "Settings -> Compiler and debugger setting-> Linker settings" -> Link libraries -> Add

找到MigGW中的libgomp.dll.a

在/mingw/lib/gcc/mingw32/4.6.2(version number)/libgomp.dll.a

C++ Code::Blocks + MinGW 配置 OpenMP 和例子_第2张图片

 

运行例子:

1.

#include 
#include 
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}

 

2.

见http://blog.csdn.net/housisong/article/details/1485166,可以对比单核和多核的运行速度差别;

 

 

 

你可能感兴趣的:(Codeblocks,OpenMP,C++,MinGW)