intel xeon phi 常见错误记录

本文记录我使用MIC过程中,常见的错误。


  1. undefined symbol: ZSt3maxIiERKT_S2_S2" ... offload error: cannot load library to the device 0 (error code 20)

这个错误太难定位了,我最后使用了逐行注释,才找到原因出在:

intel xeon phi 常见错误记录

MIC不支持C++标准库的部分函数!

(我使用的composer xe 2013的编译器,手里没有最新的编译器,希望这个BUG已经被intel修复了)


  1. math.h 头文件中的abs函数

C++ Reference 中关于abs函数的描述

In C, only the int version exists.

For the long int equivalent seelabs.

For the long long int equivalent seellabs.

C语言只有int版的函数,没有对float进行重载。

于是乎,出现了这样的错误:

intel xeon phi 常见错误记录

两个标准化的向量的点积永远为0或者1

这段代码在CPU端和MIC运行结果不一样,原因就是上面所述的C语言版本没有重载float形参,传入的结果被隐式转换为int,结果永远为0或者1

究其原因,还是因为Intel compiler编译C++代码为MIC端可运行的程序时,链接的是C语言的库。

(再次希望最新的icpc已经修复了这个BUG)


  1. "offload error: address range partially overlaps with existing allocation"

发生此错误的代码示例如下:

__declspec(target(mic)) node* MICNodePtr;
__declspec(target(mic)) leaf* MICLeafPtr; // declare the pointer variable used on MIC

void function()
{
   #pragma offload_transfer target(mic:0)
    nocopy(MICNodePtr:length(1024) alloc_if(1) free_if(0) align(64))
    nocopy(MICLeafPtr:length(1024) alloc_if(1) free_if(0) align(64))
}

上面的代码就是为了在MIC端申请一段heap上的内存空间,然后每次offload都复用这段内存。

nocopy并没有发生从CPU到MIC的数据复制,但是依然会产生"offload error: address range partially overlaps with existing allocation"这样的错误。

我们需要把nodeMICNodePtr和leaf MICLeafPtr在CPU端也申请一段同样长度的内存空间,详细原因在这里:https://software.intel.com/en-us/blogs/2013/03/27/behind-the-scenes-offload-memory-management-on-the-intel-xeon-phi-coprocessor

原文链接: https://www.cnblogs.com/wangpei0522/p/5201181.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/228914

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午2:07
下一篇 2023年2月13日 下午2:08

相关推荐