This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC and OpenMP


cybernike wrote:
I am confused. I thought GCC didn't support OpenMP until 4.2, but why my
4.1.2 GCC compiler recognizes the following OpenMP code. Is it safe to use?

#include <omp.h>
#include <stdio.h>
int main (int argc, char *argv[]) {
int id, nthreads;
#pragma omp parallel private (id)
{
id = omp_get_thread_num ();
printf (âHello World from thread %d\nâ, id);
#pragma omp barrier
if (id == 0) {
nthreads = omp_get_num_threads ();
printf (âThere are %d threads\nâ, nthreads);
}
}
return 0;
}
Let me guess, you are using a redhat system, right ?
The gcc 4.1.2 shipped with fedora had OpenMP support in it (ie it's not the stock gcc 4.1.2).
For me, it worked for simple examples, but I soon hit some bugs which made me switch to
cvs versions... 4.3 support has corrected many problems with regard to OpenMP as far as I can tell
and should give you a better OpenMP experience. Well, I'm not sure it makes a difference, but I was
using OpenMP with C++, so with C things might be different.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]