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

OMP task, Access violation

jansson
Beginner
1,187 Views
Hi,

If I run this program I do not get what I expect.

1)
If I use the ALLOCATABLE declaration+ allocation I get the Access violation.

2)
The other declaration do not fill G with the values expected.

What do I do wrong?
I use ifort 2011 update 8 and VS2010

How do I get the nice code formating I seen elsewhere?
Thanks for comments!
/Magnus

program Console_parallel_test
use OMP_lib
implicit none
integer i,tasks_total
! double precision G(1000,4)
double precision, ALLOCATABLE :: G(:,:)
tasks_total=1000
ALLOCATE(G(tasks_total,4))
G(1,1)=34.0D0
!$OMP parallel default(none) shared(tasks_total)
!$OMP master
do i=1,tasks_total
!$OMP task default(none) firstprivate(i) shared(G)
G(i,2)=dble( OMP_GET_THREAD_NUM() )
G(i,3)=OMP_GET_wtime()
G(i,1)=33.0D0
G(i,4)=OMP_GET_wtime()
!$OMP end task
enddo
!$OMP end master
!$OMP end parallel
continue
end program Console_parallel_test

0 Kudos
7 Replies
jimdempseyatthecove
Honored Contributor III
1,187 Views
Try adding shared(G) to the !$OMP parallel.
Note, the default(none) should have made access to G invalid (bug)

>>How do I get the nice code formatting I seen elsewhere?

There is a icon that looks like a pencil/highlighter. Click on that, select the formatting from a drop-down window (C++), paste in your text.

Jim Dempsey
0 Kudos
jansson
Beginner
1,187 Views
I tried to add G to the shared but still get the same problematic behaveour in both cases.

[bash]   !$OMP parallel default(none) shared(tasks_total,G)[/bash]
Cheers,
Magnus
0 Kudos
jansson
Beginner
1,187 Views
I simplified the above further and made three very similar programs of which one work as I expect.
The only change between them was in the kind of array used.
Which one would you expect to work? My own guess was wrong!

Pointer Array:

[fortran]  program Console_parallel_test
    use OMP_lib
    implicit none
    integer i
    double precision, pointer :: G(:)=>null()
    allocate(G(1000))
    G(1)=10001.0D0
!$OMP parallel default(none) shared(G,i)
!$OMP master
   do i=1,1000
!$OMP task default(none) firstprivate(i) shared(G)
       G(i)=i
!$OMP end task       
   enddo
!$OMP end master
!$OMP end parallel 
   continue
    end program Console_parallel_test[/fortran]

Allocatable Array:

[fortran]    program Console_parallel_test
    use OMP_lib
    implicit none
    integer i
    double precision, ALLOCATABLE :: G(:)
    ALLOCATE(G(1000))
    G(1)=10001.0D0
!$OMP parallel default(none) shared(G,i)
!$OMP master
   do i=1,1000
!$OMP task default(none) firstprivate(i) shared(G)
       G(i)=i
!$OMP end task       
   enddo
!$OMP end master
!$OMP end parallel 
   continue
    end program Console_parallel_test[/fortran]

non-dynamic Array (Assumed-size Array?):
[fortran]    program Console_parallel_test
    use OMP_lib
    implicit none
    integer i
    double precision G(1000)
    G(1)=10001.0D0
!$OMP parallel default(none) shared(G,i)
!$OMP master
   do i=1,1000
!$OMP task default(none) firstprivate(i) shared(G)
       G(i)=i
!$OMP end task       
   enddo
!$OMP end master
!$OMP end parallel 
   continue
    end program Console_parallel_test[/fortran]

For me the one using a pointer worked as I expect, not the other ones.
If I remove the TASK construct they all work.
Is this a bug some one could reproduce or a feature?

Thanks,
Magnus
0 Kudos
pbkenned1
Employee
1,187 Views

Both the allocatable array and static array versions reveal Intel compiler bugs. Jim said:

>>>Note, the default(none) should have made access to G invalid (bug)

Therein lies the rub...some bug with default(none). Just remove the default(none) clauses, and the program will run correctly. I made that modification, and printed out the last array element as a sanity check:

C:\U102891>diff U102891_alloc.f90 U102891_alloc_no_dflt.f90

< !$OMP parallel default(none) shared(G,i)

---

> !$OMP parallel shared(G,i)

< !$OMP task default(none) firstprivate(i) shared(G)

---

> !$OMP task firstprivate(i) shared(G)

>

> print *,'G(1000) = ',G(1000)

>

You also need to tell the linker extra stack is needed (/F:20000000):

C:\U102891>ifort -V

Intel Visual Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.2.278 Build 20111128

C:\U102891>ifort -Od -Qopenmp U102891_alloc_no_dflt.f90 /F:20000000

Intel Visual Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.2.278 Build 20111128

-stack:20000000 <<

C:\U102891>U102891_alloc_no_dflt.exe

G(1000) = 1000.00000000000

C:\U102891>

I'll report this to the developers. I didn't check the static allocation version, but suspect the same bug with default(none).

Patrick Kennedy
Intel Developer Support

0 Kudos
pbkenned1
Employee
1,187 Views

The tracking number for this defect is DPD200178853. I'll keep this thread updated with news from the developers.

>>>I didn't check the static allocation version, but suspect the same bug with default(none).

I confirmed the static version has the same bug. I don't know why the pointer version doesn't also, unless it's just masked by something.

Patrick

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,187 Views
Patrick,

Good initiative on following up on the default(none) bug.

Jim Dempsey
0 Kudos
jansson
Beginner
1,187 Views
Hi Patrick,

Thanks for the workaround removing default(none). I would never have tried that one by myself.
I look forward to download the fixed version since I depend on TASK for my project, and I LOVE default(none).

Thanks!
/Magnus
0 Kudos
Reply