The num_threads clause is not working according to the OpenMP specification in the pgCC compiler. Example code:
#include <iostream>
#include <omp.h>
const int THREADS=5;
int main()
{
# pragma omp parallel num_threads (THREADS)
{
#pragma omp critical
{
/* Ausgabe der Thread-Nummer */
std::cout << "Hi, I am thread number " << omp_get_thread_num () <<
" of " << omp_get_num_threads () << std::endl;
}
}
return 0;
}
Expected output (tested against other compilers and the OpenMP-specification):
Hi, I am thread number 3 of 5
Hi, I am thread number 0 of 5
Hi, I am thread number 1 of 5
Hi, I am thread number 4 of 5
Hi, I am thread number 2 of 5
Output when compiled with the pgCC compiler:
Hi, I am thread number 0 of 1
I tested using the following compiler:
$ pgCC -V
pgCC 6.1-5 64-bit target on x86-64 Linux
–
Michael Suess
My blog on parallel programming (especially OpenMP)