Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fortran 使用带有“的指针”;变成;在英特尔至强Phi卸载指令中_Fortran_Intel_Intel Mic - Fatal编程技术网

Fortran 使用带有“的指针”;变成;在英特尔至强Phi卸载指令中

Fortran 使用带有“的指针”;变成;在英特尔至强Phi卸载指令中,fortran,intel,intel-mic,Fortran,Intel,Intel Mic,根据《英特尔至强Phi协处理器高性能编程》一书,我们可以将数据从一个变量移动到另一个变量。我试着效仿这个例子,我发现它奏效了: 代码: 主机上有一个数组A,我将它们复制到Xeon Phi上的数组B中。我向B中的所有元素添加10,然后将Xeon Phi上的B中的元素卸载到主机上的A中。结果是: 但是,如果我使用指针,那么就会出现错误 代码2: program example real , target :: a(5),b(10) real , pointer :: a_p(:),b_p(:)

根据《英特尔至强Phi协处理器高性能编程》一书,我们可以将数据从一个变量移动到另一个变量。我试着效仿这个例子,我发现它奏效了:

代码:

主机上有一个数组A,我将它们复制到Xeon Phi上的数组B中。我向B中的所有元素添加10,然后将Xeon Phi上的B中的元素卸载到主机上的A中。结果是:

但是,如果我使用指针,那么就会出现错误

代码2:

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
结果2:

当我试图把东西复制回来时,似乎有什么地方出了问题


输入是否支持指针?在实际项目中,我们需要指向数组的指针

至少你可以复制到一个非指针数组。但是你可能应该在支持论坛上询问
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