- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I think there is a bug with the following simplified code, ifort is giving forrtl: severe (151): allocatable array is already allocated, when compiled with ifort -fopenmp -O2. when compiled with -C it seems to give the good results.
module toto implicit none type t double precision,dimension(:),allocatable :: a contains procedure,pass :: copy_t generic,public :: assignment(=) => copy_t end type t contains subroutine copy_t(t1,t2) class(t),intent(in) :: t2 class(t),intent(out) :: t1 allocate(t1%a(size(t2%a)),source=t2%a) end subroutine end module toto
program foo
use toto use omp_lib implicit none type(t) :: g1,g2,g3 integer :: i,j !$omp parallel !$omp master allocate(g2%a(10),g3%a(10)) g2%a=-1 do i=1,10 !$omp task shared(g2,g3) private(g1) !$ print *,omp_get_thread_num(),allocated(g1%a) g1=g2 do j=1,20 g3%a=g1%a+j end do !$omp end task g2%a=i !$omp taskwait g1=g2 !$omp task shared(g3) firstprivate(g1) !$ print *,omp_get_thread_num(),allocated(g1%a) do j=1,20 g3%a=g1%a+j end do !$omp end task g2%a=i+1 !$omp taskwait end do print *,'g3a',g3%a !$omp end master !$omp end parallel end program foo
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you may need to add COPYIN(g1) or firstprivate(g1) on line 12 to assure you receive a copy of the not-allocated array descriptor of g1%a. IOW you need to copy in the state of the array descriptor.
There was some discussion elsewhere, where private(x) should imply any constructors involved with x but that some cases were overlooked.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually firstprivate gives worst result :
*** Error in `./a.out': double free or corruption (fasttop): 0x0000000000708e30 ***
0 T
2 T
6 T
======= Backtrace: =========
/lib64/libc.so.6(+0x7d1fd)[0x2aaaab5ab1fd]
./a.out[0x4255e0]
./a.out[0x40b26b]
./a.out[0x40bbf8]
./a.out[0x4086e1]
./a.out[0x4059f6]
/data/apps/Intel/2016/lib/intel64/libiomp5.so(+0x98d3a)[0x2aaaab069d3a]
/data/apps/Intel/2016/lib/intel64/libiomp5.so(+0x99666)[0x2aaaab06a666]
/data/apps/Intel/2016/lib/intel64/libiomp5.so(+0x49a6f)[0x2aaaab01aa6f]
/data/apps/Intel/2016/lib/intel64/libiomp5.so(+0x4ad59)[0x2aaaab01bd59]
/data/apps/Intel/2016/lib/intel64/libiomp5.so(+0x74f20)[0x2aaaab045f20]
/data/apps/Intel/2016/lib/intel64/libiomp5.so 3 T
/lib64/libpthread.so.0(+0x7df5)[0x2aaaab319df5]
I think its more complicated than that, since the first iteration works, but not the later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Place a print statement in your copy_t assignment function. Also add "Task 1" and "Task 2" to the trace lines such that they can be disambiguated by the reader of your log files. Also add to the trace line LOC(g1).
From the first line of your output above, it indicates that the private(g1) is calling your copy_t function. The firstprivate(g1) may also exhibit this behavior too.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi jim,
Here, is a modified version, still triggers the bug. Note that if the omp waittask is commented it goes without error.
module toto use omp_lib implicit none type t double precision,dimension(:),allocatable :: a contains procedure,pass :: copy_t generic,public :: assignment(=) => copy_t end type t contains subroutine copy_t(t1,t2) class(t),intent(in) :: t2 class(t),intent(out) :: t1 print *,'copy_t',omp_get_thread_num(),LOC(t1) allocate(t1%a(size(t2%a)),source=t2%a) end subroutine end module toto program foo use toto use omp_lib implicit none type(t) :: g1,g2,g3 integer :: i,j !$omp parallel !$omp master allocate(g2%a(10),g3%a(10)) g2%a=-1 do i=1,10 !$omp task shared(g2,g3) private(g1) !$ print *,'task1',omp_get_thread_num(),i,allocated(g1%a),LOC(g1) g1=g2 do j=1,20 g3%a=g1%a+j end do !$omp end task g2%a=i !!omp taskwait g1=g2 !$omp task shared(g3) firstprivate(g1) !$ print *,'task2',omp_get_thread_num(),allocated(g1%a),LOC(g1) do j=1,20 g3%a=g1%a+j end do !$omp end task g2%a=i+1 !$omp taskwait end do !$omp taskwait print *,'g3a',g3%a !$omp end master !$omp end parallel end program foo
Compiled with -fopenmp -O2 -C -g -traceback , the error log is :
./a.out task1 2 1 F 46912614975672 copy_t 0 140737488343616 copy_t 2 46912614975672 task2 4 T 46912614973464 task1 4 2 F 46912614971192 copy_t 0 140737488343616 copy_t 4 46912614971192 task2 3 T 46912614968984 copy_t 0 140737488343616 task1 1 3 F 46912614966712 task2 0 T 46912614964504 copy_t 1 46912614966712 copy_t 0 140737488343616 task1 4 4 F 46912614964536 copy_t 4 46912614964536 task2 3 T 46912614962200 forrtl: severe (151): allocatable array is already allocated Image PC Routine Line Source a.out 0000000000421057 Unknown Unknown Unknown a.out 000000000040465E toto_mp_copy_t_ 15 bugomptask.f90 a.out 0000000000403824 MAIN__ 34 bugomptask.f90 libiomp5.so 00002AAAAB069D3A Unknown Unknown Unknown libiomp5.so 00002AAAAB06A666 Unknown Unknown Unknown libiomp5.so 00002AAAAB01AA6F Unknown Unknown Unknown libiomp5.so 00002AAAAB01BD59 Unknown Unknown Unknown libiomp5.so 00002AAAAB045F20 Unknown Unknown Unknown libiomp5.so 00002AAAAB074EE3 Unknown Unknown Unknown libpthread.so.0 00002AAAAB319DF5 Unknown Unknown Unknown libc.so.6 00002AAAAB8281AD Unknown Unknown Unknown
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page