推力:b40c_thrust :: vote_reduction的多重定义

时间:2013-01-13 21:49:40

标签: cuda gpgpu thrust

我在单独的编译模式下使用Cuda 5.0。 在

thrust/system/cuda/detail/detail/b40c/kernel_utils.h

有这个定义

__shared__ int vote_reduction[B40C_WARP_THREADS];

链接器抱怨vote_reduction的多重定义。

这是什么解决方法?

已添加:重现问题的代码

推力版本:100600

iterator.h

#pragma once
#include <thrust/transform_reduce.h>
#include <thrust/functional.h>

struct Unary_Op
{
    __host__ __device__ int operator()(const int index) const;
};

int iterates(int start, int end);

iterator.cu

#include "iterator.h"

__host__ __device__ int Unary_Op::operator()(const int index) const
{
    return index;
}

int iterates(int start, int end)
{
    thrust::counting_iterator<int> first(start);
    thrust::counting_iterator<int> last = first + end;

    Unary_Op unary_op = Unary_Op();
    thrust::plus<int> binary_op;
    int init = 0;

    int sum = thrust::transform_reduce(first, last, unary_op, init, binary_op);

    return sum;
}

calculation.h

#include "iterator.h"

int compute();

calculation.cu

#include "calculation.h"

int compute()
{
    return iterates(0,10);
}

main.cu

#include "calculation.h"

int main()
{
    compute();
    return 0;
}

编译命令(NSight)

Building file: ../calculation.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "" -M -o "calculation.d" "../calculation.cu"
nvcc --device-c -G -O0 -g -gencode arch=compute_20,code=sm_20  -x cu -o  "calculation.o" "../calculation.cu"

Building file: ../iterator.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "" -M -o "iterator.d" "../iterator.cu"
nvcc --device-c -G -O0 -g -gencode arch=compute_20,code=sm_20  -x cu -o  "iterator.o" "../iterator.cu"

Building file: ../main.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "" -M -o "main.d" "../main.cu"
nvcc --device-c -G -O0 -g -gencode arch=compute_20,code=sm_20  -x cu -o  "main.o" "../main.cu"

Invoking: NVCC Linker
nvcc --relocatable-device-code=true -gencode arch=compute_20,code=sm_20 -link -o  "testt"  ./calculation.o ./iterator.o ./main.o   
nvlink error   : Multiple definitions of '_ZN6thrust6system4cuda6detail6detail11b40c_thrust14vote_reductionE'
nvlink error   : Multiple definitions of '_ZN6thrust6system4cuda6detail6detail11b40c_thrust14vote_reductionE'
make: *** [tt] Error 255

1 个答案:

答案 0 :(得分:1)

这似乎是单独编译的错误或问题,该编译特定于CUDA 5.x工具包中提供的推力版本。升级或降级到推力1.5.3或推力1.7似乎已经解决了这个问题

[此答案已经从评论中汇总而成,并作为社区维基条目添加,以便将问题从未回答的问题列表中删除]