cannot quite use openmp (PGI 6.0 Workstation)

Hi there,

We got PGI workstation 6.0 installed on a 64-bit linux
SUSE LINUX Enterprise Server 9 (x86_64) - Kernel 2.6.5-7.193-smp (3).

I tested a code like below but just cannot have it show
thread_1 results. From the display, you can see that all
lines get thread_0 from OMP_get_thread_num().

Is “pgf90 -mp -L/usr/pgi/linux86-64/6.0/lib try6.f” correct for
the compiling? Was PGI fortran built properly?

Any opioion is very much appreciated.

Reggie


reggie@cluster:~/temp/pgf90>
reggie@cluster:~/temp/pgf90> cat try6.f
c use omp_lib
real r1
isum = 0.0
i_get_thread = OMP_get_num_threads()
write(,) ’ i_get_thread = ', i_get_thread

C$OMP PARALLEL DO
do k=1,6
ithread = OMP_get_thread_num()
write(,) 'ithread = ', ithread
enddo
C$OMP END PARALLEL DO
end
reggie@cluster:~/temp/pgf90>
reggie@cluster:~/temp/pgf90> pgf90 -mp -L/usr/pgi/linux86-64/6.0/lib try6.f -o
try6.out
reggie@cluster:~/temp/pgf90>
reggie@cluster:~/temp/pgf90> env|grep OMP_
OMP_NUM_THREADS=2
reggie@cluster:~/temp/pgf90>
reggie@cluster:~/temp/pgf90> try6.out
i_get_thread = 0
ithread = 0
ithread = 0
ithread = 0
ithread = 0
ithread = 0
ithread = 0

reggie@cluster:~/temp/pgf90>

additional info:

  1. The results are the same with pgf90 -mp try6.f -o try6f.out
  2. OMP_NUM_THREADS=2 has been defined prior to running try6f.out
    as is shown in the display

Hi Reggie,

You need to declare the OMP functions as INTEGER since the default type of variables beginning with “O” is REAL. Note that we added “omp_lib” to the 6.1 release.

Example:

% cat test.f
C        use omp_lib
        real r1
        integer OMP_get_num_threads, OMP_get_thread_num

        isum = 0.0
        i_get_thread = OMP_get_num_threads()
        write(*,*) ' i_get_thread = ', i_get_thread

C$OMP PARALLEL DO
        do k=1,6
                ithread = OMP_get_thread_num()
                write(*,*) 'ithread = ', ithread
        enddo
C$OMP END PARALLEL DO
        end
% pgf90 -mp -V6.0 test.f
% setenv OMP_NUM_THREADS 2
% a.out
  i_get_thread =             1
 ithread =             0
 ithread =             0
 ithread =             1
 ithread =             1
 ithread =             1
 ithread =             0

Hope this helps,
Mat

Hi mkcolg,

Thanks a lot for the tip! After declaring OMP_get_thread_num as inteter,
the code worked perfectly as your code indicated.

Best regards,

Reggie