Under Windows Codeblocks configuration OpenMP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.