is imagemagick openMP compatible?!

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
anoosh3000

is imagemagick openMP compatible?!

Post 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?!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: is imagemagick openMP compatible?!

Post 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:
anoosh3000

Re: is imagemagick openMP compatible?!

Post by anoosh3000 »

thanks for your reply. so it is openMP enabled. how do i implement both into a code?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: is imagemagick openMP compatible?!

Post 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.
anoosh3000

Re: is imagemagick openMP compatible?!

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: is imagemagick openMP compatible?!

Post 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.
anoosh3000

Re: is imagemagick openMP compatible?!

Post by anoosh3000 »

yes i did. would you please paste the code and ALSO the compile command [ g++ ... ] here? thanks for your quick replies, anyway!
Post Reply