Reputation: 381
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
Reputation: 21
You have to include -fopenmp
in
-fopenmp
in the textBoxI have also included #include <omp.h>
dev-c++ version 5.6.1
Upvotes: 2
Reputation: 743
I guess you also have to include the header file #include < omp.h > separately
Upvotes: 0
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
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
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