Cuda 推力转换损失数据警告

Cuda 推力转换损失数据警告,cuda,thrust,Cuda,Thrust,我试图使用推力对一些数据执行缩减,但在编译时,我收到了很多关于可能的数据转换丢失的警告 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust/system/cuda/detail/cuda_launch_config.h(338) : see reference to function template instantiation 'size_t thrust::system::cuda::detail::b

我试图使用推力对一些数据执行缩减,但在编译时,我收到了很多关于可能的数据转换丢失的警告

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust/system/cuda/detail/cuda_launch_config.h(338) : see reference to function template instantiation 'size_t thrust::system::cuda::detail::block_size_with_maximum_potential_occupancy<thrust::system::cuda::detail::cuda_launch_config_detail::util::zero_function<T>>(const thrust::system::cuda::detail::function_attributes_t &,const thrust::system::cuda::detail::device_properties_t &,UnaryFunction)' being compiled
1>          with
1>          [
1>              T=size_t,
1>              UnaryFunction=thrust::system::cuda::detail::cuda_launch_config_detail::util::zero_function<size_t>
1>          ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust/system/cuda/detail/cuda_launch_config.h(147): warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data
1>          C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust/system/cuda/detail/cuda_launch_config.h(159) : see reference to function template instantiation 'L thrust::system::cuda::detail::cuda_launch_config_detail::util::divide_ri<L,R>(const L,const R)' being compiled
1>          with
1>          [
1>              L=int,
1>              R=size_t
1>          ]
1>          C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust/system/cuda/detail/cuda_launch_config.h(272) : see reference to function template instantiation 'L thrust::system::cuda::detail::cuda_launch_config_detail::util::round_i<L,size_t>(const L,const R)' being compiled
1>          with
1>          [
1>              L=int,
1>              R=size_t
1>          ]
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\struch/system/CUDA/detail/CUDA\u launch\u config.h(338):请参阅函数模板实例化“size\u t struch::system::CUDA::detail::block\u size\u with_maximum\u potential\u占用率”正在编译(常量推力::系统::cuda::细节::函数(属性)&,常量推力::系统::cuda::细节::设备(属性)&,一元函数)
1> 与
1>          [
1> T=尺寸,
1> UnaryFunction=推力::系统::cuda::细节::cuda\u启动\u配置\u细节::util::零函数
1>          ]
1> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\asch/system/CUDA/detail/CUDA\u launch\u config.h(147):警告C4267:“返回”:从“大小”转换为“整数”,可能会丢失数据
1> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\推力/system/CUDA/detail/CUDA_-launch_-config.h(159):请参阅正在编译的函数模板实例化“L推力::系统::CUDA::细节::CUDA_-launch_-config_-detail::util::divide_-ri(常数L,常数R)”的参考
1> 与
1>          [
1> L=int,
1> R=尺寸
1>          ]
1> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\stress/system/CUDA/detail/CUDA_launch_config.h(272):请参阅正在编译的函数模板实例化“L-stress::system::CUDA::detail::CUDA_launch_config_detail::util::round_i(const L,const R)”
1> 与
1>          [
1> L=int,
1> R=尺寸
1>          ]
我知道这些是警告,但它们真的很烦人,有没有办法关闭它们?

我想你可以使用
#pragma warning(disable:4267)
。但是,如果你没有令人信服的理由不这样做,我会修改代码


size\u t
int
不是一回事。现在对你有用的东西可能会在某个时候咬到你不想被咬的地方。例如,请参见。

这是两年后的事,问题仍然存在。我已经弄清楚了这里发生了什么,并找到了解决方案

首先,重申这个问题。如果您创建了一个全新的CUDA项目(我使用的是CUDA 7.5和Visual Studio 2013),并简单地说:

#include <thrust/device_vector.h>

int main()
{
    thrust::device_vector<int> test;
    return 0;
}
execution\u policy.hpp
中:

typedef size_t size_type;
所有的警告都消失了

现在,我将转到推力github项目,并提出这样一个更改


希望这能帮助一些人,这让我发疯。

谢谢你的建议。这篇文章很有趣。那么,你有没有办法避免这些警告而不忽略它们?我发现这很难,因为推力是一个模板库,甚至很难找到哪里出了问题,更不用说修改推力的代码了。有人发现了吗e警告?这不是一件好事。在我的推力代码中,我看不到任何地方我使用了不适当的
int
,我看到很多/大部分警告都是推力内部的——在启动代码上等等。
typedef size_t size_type;