個別のコンパイルモードでCuda5.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;
}
計算.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