Hi
I have a code that uses derived types that includes allocatables inside a region that I want to offload. In order to get the derives type onto the device I try to manually transfer the content of the allocatables and then re-assemble the derived type on the phi. However, I have run into the problem that some kind of implicit copying must be going on ...
The issue is illustrated in the small example below. In the offload region transfer of MyType is not allowed, so I state that only TransferInt,TransferFloats should be copied to the device. However, when you get to the very last line of the program it appears that MyType has been included implicitly as in INOUT variable. An access violation is now produced runtime, since MyType could not be properly copied back from the device.
Is there any way I can turn of implicit copying in order to get around this problem?
I use the latest version of parallel studio XE.
module mTestType
type TTestType
integer :: Int
real*8,allocatable :: Floats(:)
end type TTestType
!dir$ attributes offload : mic :: TTestType
type(TTestType) :: MyType
!dir$ attributes offload : mic :: MyType
end module mTestType
program Console1
use mTestType
implicit none
integer :: TransferInt
real*8,allocatable :: TransferFloats(:)
!dir$ attributes offload : mic :: TransferInt
MyType%Int=1d0
allocate(MyType%Floats(4))
MyType%Floats(:)=2d0
allocate(TransferFloats(4))
TransferFloats(:)=MyType%Floats(:)
TransferInt=MyType%Int
!DIR$ OFFLOAD BEGIN TARGET(mic:0) IN(TransferInt,TransferFloats)
allocate(MyType%Floats(4))
MyType%Floats(:)=TransferFloats(:)
MyType%Int=TransferInt
print *,'On phi ...'
print *,MyType%Int
print *,MyType%Floats(:)
!DIR$ END OFFLOAD
print *,'On host ...'
print *,MyType%Int
print *,MyType%Floats(:)
end program Console1