首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >推力: b40c_thrust::vote_reduction的多重定义

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

Stack Overflow用户
提问于 2013-01-13 21:49:39
回答 1查看 476关注 0票数 0

我在不同的编译模式下使用Cuda5.0。在……里面

代码语言:javascript
运行
复制
thrust/system/cuda/detail/detail/b40c/kernel_utils.h

有这样的定义

代码语言:javascript
运行
复制
__shared__ int vote_reduction[B40C_WARP_THREADS];

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

解决这个问题的办法是什么?

添加了:再现问题的代码

推力版本: 100600

iterator.h

代码语言:javascript
运行
复制
#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

代码语言:javascript
运行
复制
#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

代码语言:javascript
运行
复制
#include "iterator.h"

int compute();

calculation.cu

代码语言:javascript
运行
复制
#include "calculation.h"

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

main.cu

代码语言:javascript
运行
复制
#include "calculation.h"

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

编译命令(NSight)

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-23 12:16:04

这似乎是一个缺陷或问题与单独的编译,是专门针对版本的推力,在CUDA 5.x工具包。升级或降级到推力1.5.3或推力1.7似乎解决了这个问题

这个答案是从评论中收集的,并作为一个社区wiki条目添加,以便将问题从未回答的问题列表中删除。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14308591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档