• intel xeon phi 常见错误记录


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


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

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

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

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


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

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

    In C, only the int version exists.
    For the long int equivalent see labs.
    For the long long int equivalent see llabs.

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

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

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

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

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

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


    3.  "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"这样的错误。

    我们需要把node*MICNodePtr和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

  • 相关阅读:
    Redis入门--- 五大数据类型 ---String ,List
    Redis入门 --- 安装
    Netty 应用实例-群聊系统,心跳检测机制案例 ,WebSocket 编程实现服务器和客户端长连接
    红锁的实现
    基于Redis实现分布式锁
    基于分布式锁 分布式全局唯一ID
    Netty Java BIO 编程 (一)
    Netty Java NIO 基本介绍Channel 和 buffer (二)
    Java AIO 基本介绍
    SpringBoot 系列教程自动配置选择生效
  • 原文地址:https://www.cnblogs.com/wangpei0522/p/5201181.html
Copyright © 2020-2023  润新知