Hi,
The following code does not work as expected:
------------------------------------------------------------------------
MODULE SIM_DATA
!$OMP declare target (GX)
! DIR$ ATTRIBUTES OFFLOAD:mic :: GX
REAL GX
END MODULE SIM_DATA
!DIR$ ATTRIBUTES OFFLOAD:mic :: test0
SUBROUTINE test0(n, b)
INTEGER n, b(n)
print *,'test0', b
END
!DIR$ ATTRIBUTES OFFLOAD:mic :: test1,test0
SUBROUTINE test1(n, a, b)
USE SIM_DATA
IMPLICIT NONE
INTEGER n, a(n), b(n,2)
print *, a
b(:,1) = a
b(:,2) = a+ 5
CALL test0(n,b(:,1))
print *, 'GX: ', GX
END
PROGRAM test_main
USE SIM_DATA
IMPLICIT NONE
INTEGER n,ai(3,2), b(3,4)
!$OMP DECLARE TARGET (test1)
ai(:,1) = 3
ai(:,2) = 4
n = 3
GX = 10
!$OMP TARGET DATA MAP (to: GX)
! DIR$ OFFLOAD_TRANSFER TARGET(mic:0) IN(GX)
!$OMP PARALLEL SECTIONS
!$OMP SECTION
!$OMP TARGET MAP(TO: n,ai(:,1)) MAP(FROM: b(:,1:2))
CALL test1(n,ai(:,1), b(:,1:2))
!$OMP end target
!$OMP SECTION
CALL test1(n,ai(:,2), b(:,3:4))
!$OMP END PARALLEL SECTIONS
!$OMP END TARGET DATA
print *, 'b='
print *, b
END
------------------------------------------------------------------------------------
did not work as I expected, GX=0.0 inside MIC.
If I change as follows
! $OMP declare target (GX)
!DIR$ ATTRIBUTES OFFLOAD:mic :: GX !Intel's specific directive
! $OMP TARGET DATA MAP (to: GX)
!DIR$ OFFLOAD_TRANSFER TARGET(mic:0) IN(GX) !Intel's specific directive
the code works as I expected. So is the compiler not OpenMP4.0 compliance or did I do something wrong?
My aim is to try to use the GLOBAL VARIABLE GX in SIM_DATA module. Please help!