- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to the book " Intel Xeon Phi Coprocessor High-Performance Programming", we can move data from one variable to another. I tried to follow the example and I found it worked:
Code:
<code>
program example
real , target :: a(5),b(10)
a(1)=1
a(2)=2
a(3)=3
a(4)=4
a(5)=5
print *,'*************************'
print *,'a:'
print *, a
!dir$ offload begin target (mic:0) in(a(1:5): into(b(1:5)) alloc_if(.true.) free_if(.false.) )
print *, 'b on the phi'
print *, b(1:5)
b=b+10
!dir$ end offload
!dir$offload_transfer target(mic:0) out(b(1:5) : into(a(1:5)) alloc_if(.false.))
print *,'*************************'
print *,'a:'
print *, a
end program example
</code>
I have an array A on the host and I copy them into an array B which is on the Xeon Phi. I add 10 to all elements in the B and then offload elements in the B on the Xeon Phi to the A on the host. the result is:
However if I use pointers, then there would be an error.
Code 2:
<code>
program example
real , target :: a(5),b(10)
real , pointer :: a_p(:),b_p(:)
a(1)=1
a(2)=2
a(3)=3
a(4)=4
a(5)=5
a_p=>a
b_p=>b
print *,'*************************'
print *,'a:'
print *, a
!dir$ offload begin target (mic:0) in(a_p(1:5): into(b_p(1:5)) alloc_if(.true.) free_if(.false.) )
print *, 'b on the phi'
print *, b_p(1:5)
b_p=b_p+10
!dir$ end offload
!dir$offload_transfer target(mic:0) out(b_p(1:5) : into(a_p(1:5)) alloc_if(.false.))
print *,'*************************'
print *,'a:'
print *, a
end program example
</code>
result 2:
Looks like something is wrong when I try to copy things back.
Does the into support pointers? We'll need pointers to arrays in real project.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks to be an accidental duplicate of the earlier post: http://software.intel.com/en-us/forums/topic/490255
Please refer to the earlier post for a reply.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page