[Omp] question about reduction

James Beyer beyerj at cray.com
Thu Feb 15 09:06:20 PST 2007


Does the reduction clause force the user to only use that operator on 
the object list in the clause?  The following code example the following 
code compiles with several compilers, however, at least one issues an 
error message saying that the reduction clause and the expression inside 
the single construct do not match.

james


         program foo
           integer x,num
           external omp_get_num_threads
           integer omp_get_num_threads

           x = 0
!$omp parallel reduction(-:x)
             x = x - 3
!$omp master
               num = omp_get_num_threads()
!$omp end master

!$omp single
               x = x + 5
!$omp end single
!$omp end parallel

           if ( x .ne. 5+(-3*num) ) then
             print *,'Test failed'
           else
             print *,'Test passed'
           endif

         end


More information about the Omp mailing list