Using poniters whith “into” in Intel Xeon Phi offload directive

Using poniters whith “into” in Intel Xeon Phi offload directive

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.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today