OpenMP accuracy

OpenMP accuracy

I am compiling my project with /Qopenmp to process some simple do loops without any reduction. I get vastly different results in terms of accuracy with and without openmp. Any suggestions to overcome this ?

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>...I am compiling my project with /Qopenmp to process some simple do loops without any reduction. I get vastly different results
>>in terms of accuracy with and without openmp. Any suggestions to overcome this?..

It would be nice if you provide example of differences ( that is, numbers ). In general, it is possible that results of some computations will differ for threaded and non-threaded versions of the same algorithm.

Your program has a bug. Disprove this last statement.

>>...Your program has a bug...

What program are you talking about? The question in the Initial Post was too generic and the MiB1980 user did not provide any sources.

mecej4's picture

Quote:

Sergey Kostrov wrote:

The question in the Initial Post was too generic and the MiB1980 user did not provide any sources.

That is precisely what Tony Richards hinted, but he employed sardonic humor instead of making direct statements!

I have a lot of DO statements. The calls where I find some precision change looks something like this

complex*16 a
 integer*4 iarray,jarray
 allocatable a(:),iarray(:),jarray(:)
 allocate (a(1:n2),iarray(1:n2),jarray(1:n2))
!$OMP PARALLEL DO 
 do k=1,n2
 i=iarray(k)
 j=jarray(k)
 call calculatexij(i,j,a(i))
 enddo
!$OMP END PARALLEL DO

Above is just an extract. The actual code is more complex than this with logic to populate the iarray, jarray etc. The main change is in the precision of the calculation of a(i).

For that specific example, you need to declare i and j as private.

It doesn't clear what is going on in:
...
call calculatexij(i,j,a(i)
...
What is a difference when it comes to the precision?

jimdempseyatthecove's picture

When i and j are not declared as private(i,j), the default declaration is public(i,j)

Public(i,j) means all threads share i and j
The first thread to issue i=iarray(k), will have its result variable i overwritten by the next thread to issue i=iarray(k), and so on.
This results in some i,j combinations being evaluated twice, and
some combinations of i,j not being evaluated at all

Private(i,j) means each thread has separate variables i and j.
This results in all intended combinations of i,j to be evaluated once.

Jim Dempsey

www.quickthreadprogramming.com

Login to leave a comment.