num_threads clause not working (OpenMP)

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)

Hi Michael,

Thank you for the report. This is a known issue and is fixed in the soon to be release 6.2 compilers.

% pgCC -mp omp.cpp -V6.1-6
% a.out
Hi, I am thread number 0 of 1
% pgCC -mp omp.cpp -V6.2-2
% a.out
Hi, I am thread number 0 of 5
Hi, I am thread number 1 of 5
Hi, I am thread number 3 of 5
Hi, I am thread number 2 of 5
Hi, I am thread number 4 of 5
  • Mat

Hi Mat,

good to hear, thanks for the fast response.


Michael Suess
My blog on parallel programming