I have installed the C++ and Fortran compiler and tested the (C++) programs (serial and parallel versions).
in Fortran when compiling a (parallelized) code without enabling the -openmp
option should compile the code in (default) serial mode
but in C++ I get errors like
undefined reference to omp_get_thread_num
but in Fortran when you compile code without the -fopenmp flag it ignores any code which start with $!omp
like
$!omp id = omp_get_thread_num()
Is there any option like that in C++?
You can protect your C/C++ code with the _OPENMP define. This way you can avoid introducing calls to the OpenMP runtime whenever your application is not linked against it.
For instance, you can have the following code
void foo (void)
{
#ifdef _OPENMP
printf ("I have been compiled with OpenMP support\n");
#else
printf ("I have been compiled without OpenMP support\n");
#endif
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With