Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

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

Yucheng_Z_
Beginner
562 Views

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:

result1

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:

result2

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.

0 Kudos
1 Reply
Kevin_D_Intel
Employee
562 Views

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.

0 Kudos
Reply