|
Prev: write matrix
Next: Public review
From: Domel on 4 Jul 2008 15:18 The following code should allocate an allocatable shared array inside the parallel construct using SINGLE clause. It generates a run time error with ifort 10.1: forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable USEDD when it is not allocated It *IS* allocated at the end of the routine RESIZE, only something gets screwed up on the return . It is allocated inside the SINGLE region, so no double allocation. The problem is gone if the call to resize is replaced by explicit inlining of the routine (uncomment the commented lines and do not call RESIZE). The problem will also go away if the RESIZE routine is present -and called from - directly the main file. Looks like an obvious bug to me. Any comments to open my eyes? Thanks -- Dominik main file: PROGRAM NS3T USE NS3T10 IMPLICIT NONE CALL SETUP_A END PROGRAM NS3T separate file: MODULE NS3T10 USE OMP_LIB IMPLICIT NONE CONTAINS SUBROUTINE SETUP_A INTEGER, DIMENSION(:), ALLOCATABLE :: USEDD INTEGER :: NTH=1, MYID=1 !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(NTH, MYID) NTH = OMP_GET_NUM_THREADS() MYID = OMP_GET_THREAD_NUM() !$OMP SINGLE PRINT *, NTH, MYID CALL RESIZE(USEDD,1) ! IF(ALLOCATED(USEDD)) DEALLOCATE(USEDD) ! ALLOCATE(USEDD(1)) PRINT *, ALLOCATED(USEDD) USEDD = 0 PRINT *, USEDD !$OMP END SINGLE !$OMP END PARALLEL END SUBROUTINE SETUP_A SUBROUTINE RESIZE(V,S) INTEGER, DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: V INTEGER, INTENT(IN) :: S IF(ALLOCATED(V)) DEALLOCATE(V) ALLOCATE(V(S)) PRINT *, 'RESIZE : ', S END SUBROUTINE RESIZE END MODULE NS3T10
From: Roman on 4 Jul 2008 18:35 > INTEGER, DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: V Hi, When I compiled your code with /stand:f95 option, the above line produced the following warning: Warning: Allocatable dummy arguments is an extension of Standard F95. [V] Maybe that's the problem? Roman
From: Roman on 4 Jul 2008 19:14 Hi, Your code seems to work if the array is already allocated before entering the parallel region: SUBROUTINE SETUP_A INTEGER, DIMENSION(:), ALLOCATABLE :: USEDD INTEGER :: NTH=1, MYID=1 allocate(USEDD(1)) !!! !$OMP PARALLEL DEFAULT(NONE) SHARED(USEDD) PRIVATE(NTH, MYID) !$ NTH = OMP_GET_NUM_THREADS() !$ MYID = OMP_GET_THREAD_NUM() !$OMP SINGLE !$ PRINT *, NTH, MYID CALL RESIZE(USEDD, 5) PRINT *, ALLOCATED(USEDD) USEDD = 0 PRINT *, USEDD !$OMP END SINGLE !$OMP END PARALLEL END SUBROUTINE SETUP_A
From: Domel on 5 Jul 2008 03:49 Hi, thanks for the comment. Yes indeed, the problem is the allocation inside the parallel region. I looked through the OpenMP specifications and did not find a requirement that allocatable arrays can not be allocated there... -- Dominik On 5 Jul., 01:14, Roman <she...(a)eos.ubc.ca> wrote: > Hi, > > Your code seems to work if the array is already allocated > before entering the parallel region: > > SUBROUTINE SETUP_A > INTEGER, DIMENSION(:), ALLOCATABLE :: USEDD > INTEGER :: NTH=1, MYID=1 > > allocate(USEDD(1)) !!! > > !$OMP PARALLEL DEFAULT(NONE) SHARED(USEDD) PRIVATE(NTH, MYID) > !$ NTH = OMP_GET_NUM_THREADS() > !$ MYID = OMP_GET_THREAD_NUM() > > !$OMP SINGLE > !$ PRINT *, NTH, MYID > CALL RESIZE(USEDD, 5) > > PRINT *, ALLOCATED(USEDD) > USEDD = 0 > PRINT *, USEDD > !$OMP END SINGLE > !$OMP END PARALLEL > > END SUBROUTINE SETUP_A
From: Domel on 5 Jul 2008 03:51
Hmm, that is interesting, didn't know that, thanks. However, the thing works without OpenMP. In addition, emitting such warning means that the compiler is aware of the situation and handles it. So it makes me even more confident it is a bug. -- Dominik On 5 Jul., 00:35, Roman <she...(a)eos.ubc.ca> wrote: > > INTEGER, DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: V > > Hi, > > When I compiled your code with /stand:f95 option, > the above line produced the following warning: > > Warning: Allocatable dummy arguments is an extension of Standard > F95. [V] > > Maybe that's the problem? > > Roman |