简体   繁体   English

解决Thrust / CUDA警告“无法分辨指针指向哪个......”

[英]Resolving Thrust/CUDA warnings “Cannot tell what pointer points to…”

I'm trying to build a trivial application using Thrust/CUDA 4.0 and get lots of warnings "warning : Cannot tell what pointer points to, assuming global memory space" 我正在尝试使用Thrust / CUDA 4.0构建一个简单的应用程序并获得大量警告“警告:无法告诉指针指向哪个,假设全局内存空间”

Has anyone else seen this and how do I either disable them or fix my code? 有没有其他人看过这个,我如何禁用它们或修复我的代码?

Thanks, 谢谢,

Ade 阿德

Here's my code. 这是我的代码。

Hello.h Hello.h

class DECLSPECIFIER Hello   
{ 
private:
    thrust::device_vector<unsigned long> m_device_data;

public:
    Hello(const thrust::host_vector<unsigned long>& data);
    unsigned long Sum();
    unsigned long Max();
};

Hello.cu Hello.cu

#include "Hello.h"

Hello::Hello(const thrust::host_vector<unsigned long>& data)
{
    m_device_data = data;
}

unsigned long Hello::Sum()
{
    return thrust::reduce(m_device_data.cbegin(), m_device_data.cend(), 0, thrust::plus<unsigned long>());
}

unsigned long Hello::Max()
{
    return *thrust::max_element(m_device_data.cbegin(), m_device_data.cend(), thrust::less<unsigned long>());
}

The output 输出

1>  Compiling CUDA source file Hello.cu...
1>  
1>  C:\SrcHg\blog\HelloWorld\HelloWorldCuda>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2008 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include"  -G0  --keep-dir "Debug" -maxrregcount=32  --machine 32 --compile  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MDd " -o "Debug\Hello.cu.obj" "C:\SrcHg\blog\HelloWorld\HelloWorldCuda\Hello.cu" 
1>  Hello.cu
1>  tmpxft_00001fac_00000000-0_Hello.cudafe1.gpu
1>  tmpxft_00001fac_00000000-5_Hello.cudafe2.gpu
1>  Hello.cu
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust/detail/internal_functional.h(197): warning : Cannot tell what pointer points to, assuming global memory space
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust/detail/internal_functional.h(197): warning : Cannot tell what pointer points to, assuming global memory space
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust/detail/internal_functional.h(197): warning : Cannot tell what pointer points to, assuming global memory space

There's a lot of these. 有很多这些。

Fermi uses uniform addressing of shared and global memory space, while pre-Fermi messages don't. Fermi使用统一寻址共享和全局存储空间,而前费米消息则不然。

For the pre-Fermi case, when you get an address, you don't know if it should be shared or global. 对于前费米案例,当您获得地址时,您不知道它是应该共享还是全局。 The compiler tries to figure it out, but sometimes it can't. 编译器试图找出它,但有时它不能。 When that happens, the message pops up - "assuming global" is correct in 99.999% of cases, because when you want a pointer to shared memory, you usually explicitly take an address of a shared variable and the compiler can recognise that. 当发生这种情况时,弹出的消息 - “假设全局”在99.999%的情况下是正确的,因为当你想要一个指向共享内存的指针时,你通常会明确地获取共享变量的地址,编译器可以识别它。

For Fermi cards, shared-or-global can be deduced at runtime (based on the address) and no assumptions have to be made by the compiler. 对于费米卡,可以在运行时推导出共享或全局(基于地址),并且编译器不必进行任何假设。

Suggeston: Ignore those warnings. Suggeston:忽略那些警告。

So... figured it out and thought I'd post it here. 所以......想出来,以为我会把它发布在这里。 The solution is either 解决方案是

Don't use the -G flag on NVCC 不要在NVCC上使用-G标志

or 要么

Compile for arch sm_20 (Fermi) if you are targetting such a device 如果您要定位此类设备,请编译为sm_20(费米)

This is a known limitation of NVCC and not a Thrust bug. 这是NVCC的已知限制,而不是Thrust错误。 See: 看到:

http://groups.google.com/group/thrust-users/browse_thread/thread/1914198abf646c6d/8bc00e6030b0030b?#8bc00e6030b0030b http://groups.google.com/group/thrust-users/browse_thread/thread/1914198abf646c6d/8bc00e6030b0030b?#8bc00e6030b0030b

if you are using mirosoft visual studio: from project->properties->CUDA C/C++->Device->Code Generation; 如果您正在使用mirosoft visual studio:from project-> properties-> CUDA C / C ++ - > Device-> Code Generation; change the compute_10,sm_10 to compute_20,sm_20 将compute_10,sm_10更改为compute_20,sm_20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM