- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I have a global array A, which contains all my data. I may use different parts of A in an offload sections. How do I just copy content of parts (more than one) I am interested in to mic but not copy all the content of global array. I have an example and how can I make it work? Thanks,
PROGRAM MAIN
IMPLICIT NONE
integer N
PARAMETER (N=10)
DOUBLE PRECISION, allocatable:: a(:)
integer i
allocate(a(N))
do i = 1, N
a(i) = i*0.1
end do
call mytest1(a,N)
STOP
END
SUBROUTINE mytest1(a,n)
IMPLICIT NONE
INTEGER n
DOUBLE PRECISION a(*)
!dir$ offload_transfer target(mic)
& in(a(2:3): alloc_if(.TRUE.) free_if(.FALSE.))
!dir$ offload_transfer target(mic)
& in(a(5:7): alloc_if(.TRUE.) free_if(.FALSE.))
!dir$ offload begin target(mic) nocopy(a(1:n))
write(*,*) a(2:3)
write(*,*) a(5:7)
!dir$ end offload
RETURN
END
I can compile it, but when I run it, it gives: offload error: address range partially overlaps with existing allocation.
Is there any way to copy more than one parts of a huge array to offload and do the calculation in offload ?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot have "a" pointing to 2 different memory location a(2:3) and a(5:7). You allocate the total size of the array you want and transfer sections of array data you want to use as shown below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If array a is truly intended to be global, then move it out of the PROGRAM block into a module and attribute it as residing in both places. Then insert once only code to allocate it on Host and alloc_if(.true.) and copy or not to MIC. Then do not pass (a,n) around on subroutine calls.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page