小编Ema*_*d R的帖子

推进cuda内核

我也在我的机器上安装了cuda 8.0(Linux SL7),我已经下载了推力1.8.1并用新的1.8.1替换了现有的推力库.

据我所知,从推力1.8开始支持并可以在内核中使用.我引用他们的网站:

Thrust 1.8.0引入了对CUDA __device__代码的算法调用的支持,对CUDA流的支持以及算法性能的改进.用户现在可以从CUDA __device__代码调用Thrust算法

但是,当我使用Nsight eclipse构建应用程序时,它会向我显示以下错误:

不允许从__global__函数("mykernel")调用__host__函数("thrust :: sort").

请问有什么建议吗?

这是我的代码:

#include <iostream>
#include <numeric>
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <thrust/sort.h>
#include <thrust/execution_policy.h>

__global__ void mykernel(int* a, int* b)
{

thrust::sort(a, a + 10);
}

int main(void)
{
    int a[10] = { 0, 9, 7, 3, 1, 6, 4, 5, 2, 8 };
    int b[10];
    int *d_a, *d_c;

    cudaMalloc((void**)&d_a, 10 * sizeof(int));
    cudaMalloc((void**)&d_c, 10 * sizeof(int));

    std::cout << "A\n";
    for (int i …
Run Code Online (Sandbox Code Playgroud)

cuda thrust

2
推荐指数
1
解决办法
806
查看次数

标签 统计

cuda ×1

thrust ×1