Allocatable array in OpenMP

Allocatable array in OpenMP

Hello 

I tried to generate below OpenMP code

INTEGER, ALLOCATABLE :: A(:)

....

C$OMP PARALLEL DEFAULT(SHARED) 

C$OMP DO private(A)

       do i =1,n

      ALLOCATE((A(k)) // k - variable from do-loop procedure

......

However,  error encountered while attempting to allocate a data object.

As I know, this bug was fixed by former patch. But I'm unable to update. (ifort - 11.1.052)

So I tried to next

INTEGER, pointer :: A(:)

....

C$OMP PARALLEL DEFAULT(SHARED) 

C$OMP DO private(A)

       do i =1,n

      nullify(A)

       ALLOCATE((A(k)) // k - variable from do-loop procedure

......

But this generates incorrect values.

What should I do? (Array size should gain from inter do-loop)

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

If you were using a recent compiler, I'd suggest filing a problem report with an actual test case, if you can get access via premier.intel.com.  If there is a bug in a compiler which is no longer on support, you don't have much choice beyond finding a work-around or upgrading to a newer compiler which can run your case (which we won't know without an actual example).

A possible work-around might be to put the allocate in a separate procedure, and make that procedure thread safe by declaring it with RECURSIVE or by setting -auto or equivalent (not -openmp).

In first example try: change private(A) to firstprivate(A).

In second example try, move nullify(A) to out of parallel region, change private(A) to firstprivate(A).

If all else fails, enclose the contents of the parallel region into a subroutine, then call the subroutine from the parallel region.

Jim Dempsey

www.quickthreadprogramming.com

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen