• 并行调用


    这几天需要用到kernel函数包含kernel函数的例子,于是出现了几种问题:

    一、

    error : calling a global function(“childKernel”) from a global function(“kernel”) is only allowed on the compute_35 architecture or above

    • 原因及解决方法:

    这是因为默认计算能力被设定成了sm_20,compute_20,从而阻止你使用动态并行.

    解决方案:
    在您的项目属性中, 设定CUDA C/C++中的代码生成为:compute_50,sm_50
    这样即可让您的5.0的卡, 支持动态并行, 也就是您说的核函数调用核函数.


    二、

    改成compute_50,sm_50了,然后从网上找了一个例子,还是报错:错误 17 error : kernel launch from device or global functions requires separate compilation mode
    请问这个“独立编译模式”要怎么配置?

    • 原因及解决方法:
      -
      其实只需要将RDC(可重定位设备代码)打开即可.

    方式1:
    在项目属性中, 设定CUDA C/C++的Generate Relocatable Device Code为True(-rdc=true).
    同时所有所有cu文件中的该属性为”继承自项目”.

    方式2:
    手工将你所有的cu文件该属性设定为”真”.
    然后可以不管项目属性.

    任选一种.


    三、

    error LNK2001: unresolved external symbol ___fatbinwrap_66_tmpxft_00000b3c_00000000_17_cuda_device_runtime_compute_52_cpp1_ii_8b1a5d37.

    • 原因及解决方法:

      cuda从5.0版本之后开始支持dynamic parallelism,即可以在global函数中调用其他global函数,因此可以实现核函数中再调用核函数。
      dynamic parallelism(动态并行)的软硬件条件有:

      1. cuda toolKit 版本5.0或以上;
      2. GPU compute capability(计算能力)3.5及以上。

    此时就可以在核函数中调用另一个核函数了,也可以实现递归调用。但这时会出现如下link error:
    error LNK2001: unresolved external symbol ___fatbinwrap_66_tmpxft_00000b3c_00000000_17_cuda_device_runtime_compute_52_cpp1_ii_8b1a5d37.

    这是因为动态并行还需要附加另一个库:项目属性-链接器-输入-附加依赖项:cudadevrt.lib。加入即可。

  • 相关阅读:
    Python 实现红绿灯
    ELK使用1-Elasticsearch使用
    CF Educational Codeforces Round 21
    Codeforces Round #408 (Div. 2)
    2017年 湘潭邀请赛(湖南)or 江苏省赛
    Tinkoff Challenge
    欧几里德算法与扩展欧几里德算法
    operator的各种问题
    树状数组 Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains
    Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) D. Field expansion
  • 原文地址:https://www.cnblogs.com/xieqianli/p/9128972.html
Copyright © 2020-2023  润新知