user1019083
user1019083

Reputation: 381

openmp on dev c++

Is there anyway to use openmp with dev c++. I have seen links on how to use in Visual Studio, but i am more comfortable with Dev C++ interface. Adding /openmp in the linker command line doesnt work either. I couldnt find the library to download too. Am i missing something. I tried running this sample code:

#include <stdio.h> 
#include <stdlib.h>

int main(int argc, char *argv[])
{
    #pragma omp parallel
    { 
       printf("Hello, world.\n");
    }
   return 0;
 }

From where I read it was mentioned Output on a computer with 2 Cores and 2 threads will be hello world printed twice. I have a core i7 but it was printed only once.

Upvotes: 4

Views: 16394

Answers (5)

Rodolfo
Rodolfo

Reputation: 21

You have to include -fopenmp in

  1. Project-> Project Option->Parameters - Link and
  2. Tools ->Compiler Options (General) (check "add the following commands when calling the compiler" and include -fopenmp in the textBox

I have also included #include <omp.h> dev-c++ version 5.6.1

Upvotes: 2

Aseem Ahir
Aseem Ahir

Reputation: 743

I guess you also have to include the header file #include < omp.h > separately

Upvotes: 0

Victor
Victor

Reputation: 1

there is only the parallel region , the processor is informed that there is what parallelize , but as is parallelize the code they have to say via builders, probably what you want to use : #pragma omp sections

Upvotes: 0

Lays
Lays

Reputation: 111

Tools > Compiler Options > Check the option "Add the following commands when compiler is called" > in the text area put "-fopenmp"

Compile and execute again :)

Upvotes: 11

tune2fs
tune2fs

Reputation: 7705

I do not know Dev C++, but to enable openmp you also need to add the flag -fopenmp to your compiler. Additional to linking to omp.

With g++ it look like this

g++ yourProgram.cpp -o yourProgram -lgomp -fopenmp

-fopenmp will tell the compiler to generate parallel code. I hope this will help.

Upvotes: 4

Related Questions