Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

OpenMP accuracy

MiB19801
Beginner
600 Views

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 ?

0 Kudos
8 Replies
SergeyKostrov
Valued Contributor II
600 Views
>>...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.
0 Kudos
Anthony_Richards
New Contributor I
600 Views

Your program has a bug. Disprove this last statement.

0 Kudos
SergeyKostrov
Valued Contributor II
600 Views
>>...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.
0 Kudos
mecej4
Honored Contributor III
600 Views

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!

0 Kudos
MiB19801
Beginner
600 Views

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

[fortran]

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

[/fortran]

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).

0 Kudos
IanH
Honored Contributor II
600 Views

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

0 Kudos
SergeyKostrov
Valued Contributor II
600 Views
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?
0 Kudos
jimdempseyatthecove
Honored Contributor III
600 Views

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

0 Kudos
Reply