With VS direct to setting inside the set can support OpenMP, but I was too lazy to install a codeblocks with MinGW version
Originally gcc4.4 after fully support OpenMP, the results codeblocks How to configure all hints-FOPENMP These can not be found.
I finally found out this morning that although MinGW supports OpenMP but does not allow these components to be installed during codeblocks installation, it is necessary to install a TDM-GCC with MinGW, egg pain ╮(╯▽╰)╭
Configuration process:
1) Download TDM-GCC, install the time note that the default OpenMP support is not checked, remember to check it, or install all the components ...
The path is installed when the installation will be self-configuration, do not have to engage in their own
2) Install the codeblocks (without MinGW)
3) Set Codeblocks compiler path in Settings->compiler
4) Setting->compiler->compiler settings->other options Input-fopenmp
Setting->compiler->linker settings->other linker Options Input-lgomp-lpthread
5) This configuration is complete _ (: Зゝ∠) _ Write a code try
#include "omp.h" #include <iostream> #include <time.h>void test () { int a = 0; for (int i=0;i<100000000;i++) a++;} int main () { clock_t T1 = Clock (); for (int i=0;i<8;i++) test (); clock_t t2 = Clock (); std::cout<< "Sequential time:" <<t2-t1<<std::endl; clock_t t3 = Clock (); #pragma omp parallel for for (int i=0;i<8;i++) test (); clock_t T4 = Clock (); std::cout<< "Parallel Time:" <<t4-t3<<std::endl; return 0; }
Running results found that there is a difference between serial and parallel running time!
Also a point is compile time I am the debug mode compiled, with release mode compile time is all 0 (because the speed is too fast ....) )
Under Windows Codeblocks configuration OpenMP