Page 1 of 1

is imagemagick openMP compatible?!

Posted: 2009-10-22T05:53:43-07:00
by anoosh3000
Dears,

I try to compile my code with "g++ test.cpp -D_FORTIFY_SOURCE=2 -I/usr/include/ImageMagick -L/usr/lib -O2 -W -Wall -fasynchronous-unwind-tables -fmessage-length=0 -fopenmp -fstack-protector -fstack-protector-all -funwind-tables -g -lMagick++ -lMagickCore -lMagickWand -lfreetype -lz -march=i586 -mtune=i686 -fopenmp"

which is equal to "g++ test.cpp `Magick++-config etc... `" as described in the manual. I wrote a main () function which is only:

Code: Select all

 
int main(){
 int th_id, nthreads;
#pragma omp parallel private(th_id)
 {
  th_id = std::omp_get_thread_num();
  std::cout << "Hello World from thread" << th_id << "\n";
#pragma omp barrier
 if ( th_id == 0 ) {
   nthreads = Magick::omp_get_num_threads();
   std::cout << "There are " << nthreads << " threads\n";
  }
 }
 return 0;
}

to run the openMP test. but i get:

Code: Select all

test.cpp:79: error: ‘omp_get_thread_num’ was not declared in this scope
test.cpp:83: error: ‘omp_get_num_threads’ was not declared in this scope
but i have included <omp.h> and <Magick++.h>. when i remove <Magick++.h> it compiles.

What should i do?!

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T07:55:13-07:00
by magick
Let's answer your first question, is ImageMagick OpenMP compatible? Why yes, since most of its algorithms are OpenMP enabled. You can verify like this:

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T08:15:18-07:00
by anoosh3000
thanks for your reply. so it is openMP enabled. how do i implement both into a code?

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T09:41:30-07:00
by magick
We don't understand the question. ImageMagick already is OpenMP enabled so you simply run any of the algorithms within ImageMagick and it will automatically divide the problem set up to run on each of the cores on your system simultaneously. If you are asking how to code in OpenMP, that is beyond the scope of this forum.

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T12:34:44-07:00
by anoosh3000
no. i write my code, and it runs fine with openMP on my system. But when i include <Magick++.h> header file it fails to compile ( no matter if i have used anything of Magick or not ). and gives me that error message.

any idea?

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T12:58:17-07:00
by magick
Did you remember to include omp.h? We added an include for the OpenMP header file to a simple Magick++ source module with some simple OMP code and it compiled without complaint.

Re: is imagemagick openMP compatible?!

Posted: 2009-10-22T13:04:32-07:00
by anoosh3000
yes i did. would you please paste the code and ALSO the compile command [ g++ ... ] here? thanks for your quick replies, anyway!