Author Topic: Use of OpenMp  (Read 8308 times)

deepakraom

  • Guest
Use of OpenMp
« on: May 14, 2010, 12:46:05 pm »
Hi,
 I am interested in parallel programming and I am using Code::Blocks for the same purpose.
 I am using C programming language with OpenMp Directive. I am using Code::Blocks 8.02 with GCC compiler on windows XP platform. While compiling my program given below...
____________________________________________________________________
#include<omp.h>
 #include<stdio.h>


 int main (int argc, char *argv[]) {
   int th_id, nthreads;
   #pragma omp parallel private(th_id)
   {
     th_id = omp_get_thread_num();
     printf("Hello World from thread %d\n", th_id);
     #pragma omp barrier
     if ( th_id == 0 ) {
       nthreads = omp_get_num_threads();
       printf("There are %d threads\n",nthreads);
     }
   }
   return 0;
 }
_____________
______________________________________________________

i am getting these errors..
C:\Documents and Settings\admin\My Documents\test\hi.c|1|omp.h: No such file or directory|
C:\Documents and Settings\admin\My Documents\test\hi.c||In function `int main(int, char**)':|
C:\Documents and Settings\admin\My Documents\test\hi.c|9|error: `omp_get_thread_num' was not declared in this scope|
C:\Documents and Settings\admin\My Documents\test\hi.c|13|error: `omp_get_num_threads' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|
__________________________________________
________________________
can anyone suggest me a solution in this regard...
I think the GCC version doesn't support the openmp directives. It would be better if someone suggest me to which version of GCC compatible with OpenMp commends to use with Code::Blocks
thanks in advance...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Use of OpenMp
« Reply #1 on: May 14, 2010, 01:19:59 pm »
Code
I think the GCC version doesn't support the openmp directives. It would be better if someone suggest me to which version of GCC compatible with OpenMp commends to use with Code::Blocks

try TDM-GCC, which can be downloaded from:TDM's GCC/mingw32 Builds

And read it's manual about how to use Openmp.

By the way, your question is not related to Codeblocks.  :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.