Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

OpenMP accuracy

MiB19801
Principiante
1.581 Visualizações

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 Respostas
SergeyKostrov
Contribuidor valorado II
1.581 Visualizações
>>...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
Novo colaborador I
1.581 Visualizações

Your program has a bug. Disprove this last statement.

SergeyKostrov
Contribuidor valorado II
1.581 Visualizações
>>...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 honorário III
1.581 Visualizações

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.581 Visualizações

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 honorário III
1.581 Visualizações

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

SergeyKostrov
Contribuidor valorado II
1.581 Visualizações
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 honorário III
1.581 Visualizações

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