I have been trying to write some code to test out an algorithm that can move data from a host buffer to a different buffer on the MIC. For instance, I have a 20 GB buffer residing in host memory. What I would like to do is have another buffer on the MIC that is, say, 4 GB in size where I can offload 2 GB of the main host buffer at a time. The reason for doing 2 GB at a time is so that I can do calculations on the first 2 GB while the asynchronous transfer of the next 2 GB is going on at the same time.
I did get this working for the case when I have two separate 2 GB arrays on the host and on the MIC (I'd like to avoid using more host memory as an intermediate buffer, though). Then, I transferred data to the intermediate buffer on the host and then scheduled the transfer onto the MIC. But since I had two separate named buffers, I also used if/else logic to control which buffer I was using, which I though ugly.
I've looked at using the 'into' modifier in the 'in' clause since this appears to do what I want it to, but rather than transferring 2GB over to the MIC, I'm seeing 6GB sent over and 8GB returned according to the offload report. Here's how I'm setting the data up:
complex(8), allocatable :: host_slab_buf(:)
!DIR$ ATTRIBUTES OFFLOAD : mic :: mic_slab_buf
complex(8), allocatable :: mic_slab_buf(:)
!Allocate the buffers.
allocate( host_slab_buf( num_elems ) )
allocate( mic_slab_buf( num_slab_elems ) )
! Allocate the memory on the MIC
!DIR$ OFFLOAD_TRANSFER target(mic:0) nocopy( mic_slab_buf: length(num_slab_elems) alloc_if(.true.) free_if(.false.) )
!DIR$ OFFLOAD_TRANSFER target(mic:0) in( host_slab_buf(start_host:end_host): into( mic_slab_buf(start_mic:end_mic) ) &
alloc_if(.false.) free_if(.false.) ) signal(sigIN1)
!DIR$ OFFLOAD BEGIN target(mic:0) out(mic_slab_buf(start_mic:end_mic) : into(host_slab_buf(start_host:end_host) ) &
alloc_if(.false.) free_if(.false.) ) wait(sigIN1) signal(sigOUT1)
! do some work
!DIR$ END OFFLOAD
The start_host/end_host and start_mic/end_mic are initialized to the range of entries I want to copy from the host over to the MIC. I also attached to whole code to look at.
I appreciate any help/insight on my issue.