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

OpenMP accuracy

MiB19801
Principiante
1.520 Vistas

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 Respuestas
SergeyKostrov
Colaborador Valioso II
1.520 Vistas
>>...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.
Anthony_Richards
Nuevo Colaborador I
1.520 Vistas

Your program has a bug. Disprove this last statement.

SergeyKostrov
Colaborador Valioso II
1.520 Vistas
>>...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
Colaborador Distinguido III
1.520 Vistas

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!

MiB19801
Principiante
1.520 Vistas

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

IanH
Colaborador Distinguido III
1.520 Vistas

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

SergeyKostrov
Colaborador Valioso II
1.520 Vistas
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
Colaborador Distinguido III
1.520 Vistas

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

Responder