Resolving Thrust/CUDA warnings "Cannot tell what pointer points to..." - visual-studio-2010

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"
Has anyone else seen this and how do I either disable them or fix my code?
Thanks,
Ade
Here's my code.
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
#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.
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.
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.

So... figured it out and thought I'd post it here. The solution is either
Don't use the -G flag on NVCC
or
Compile for arch sm_20 (Fermi) if you are targetting such a device
This is a known limitation of NVCC and not a Thrust bug. See:
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; change the compute_10,sm_10 to compute_20,sm_20

Related

Can't find neither .cubin nor .ptx file compiling CUDA

I am working on CUDA (7.0) project using Visual Studio 2013. The project is 64bit.
I am using driver API and need to load module from ptx or cubin file.But I can't find the file.
In VS I go Properties->CUDA C/C++ ->Common->NVCC Compilation Type ,change it to -cubin or ptx .the compiler finishes ok but I can't find that file.I only can see kernel.cu.obj and kernel.cu.cache files in output debug directory.What can be wrong here?
UPDATE:
If I go to Properties->CUDA C/C++ ->Common->Keep Preprocessed Files and set YES.Then I see .ptx,and other intermediate stuff.But as far as I understand this option is not mandatory to get .ptx?Also demo CUDA SDK projects like "matrixMulDrv" spitr ptx with that option off.I can't figure out where is the difference.
Here is matrixMulDrv project compile command:
C:\ProgramData\NVIDIA Corporation\CUDA
Samples\v7.0\0_Simple\matrixMulDrv>"C:\Program Files\NVIDIA GPU
Computing Toolkit\CUDA\v7.0\bin\nvcc.exe"
-gencode=arch=compute_20,code=\"compute_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I./
-I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0/include" -I../../common/inc -I"C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir
x64\Debug -maxrregcount=0 --machine 64 -ptx -cudart static -Xcompiler
"/wd 4819" -o data/matrixMul_kernel64.ptx "C:\ProgramData\NVIDIA
Corporation\CUDA
Samples\v7.0\0_Simple\matrixMulDrv\matrixMul_kernel.cu"
And here is my project CUDA kernel compile command:
E:\Documents\visual studio
2012\Projects\ProjectName\ProjectName>"C:\Program Files\NVIDIA GPU
Computing Toolkit\CUDA\v7.0\bin\nvcc.exe"
-gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I"E:\Documents\visual studio
2012\Projects\XXXXXX\XXXXX\XXXXX\include" -I"E:\Documents\visual
studio 2012\Projects\XXXXX\XXXXX\XXXXX\include" -I"E:\Documents\visual
studio 2012\Projects\XXXXXXXX\XXXXXXX\XXXXXX\include"
-I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXXX\include" -I"E:\Documents\visual
studio 2012\Projects\ProjectName\ProjectName\include"
-I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXX\include" -I"E:\Documents\visual
studio 2012\Projects\XXXXXX\XXXXXX\XXXXXX\include"
-I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXX\include" -I"E:\Documents\visual
studio 2012\Projects\XXXXXX\XXXXXX\XXXXXX\include" -I"C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0/include"
-I"C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\common\inc" -I"E:\Documents\visual studio 2012\Projects\ProjectName\ProjectName\include" -I"C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir
x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g
-DWIN32 -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o x64\Debug\skernel.cu.obj "E:\Documents\visual studio
2012\Projects\ProjectName\ProjectName\src\skernel.cu"
It is possible to see that matrixMulDrv project is set to compile .ptx with this line data/matrixMul_kernel64.ptx while in my project I have -o x64\Debug\skernel.cu.obj .But I have the same CUDA compiler settings on both projects.
CUDA projects in Visual Studio can inherit compile settings both at the project level (in which case they are defined in Project Properties...CUDA...Device) and at the file level (in which case you can right click on the file to bring up its properties and find them in a similar location).
The file can inherit its settings from the global project settings, or it can replace them (if you so select at the file level).
Some of those settings will determine what type of output will be generated (and therefore effectively what compile switches are needed) when that file is compiled by nvcc. Ordinary CUDA runtime API projects need their modules compiled into ("hybrid") object files (i.e. .o), but CUDA driver API projects will typically need cuda "objects" in the form of a .cubin file or a .ptx file.
There are settings to modify this generation, and for example to switch a file from typical CUDA runtime API compilation to typical driver API compilation, you could change the "NVCC Compilation Type" option from "Generate hybrid object file (--compile)" to "Generate .ptx file (-ptx)"
If you do this at the file level, it will need to be done for each file that needs its settings changed.

Compiling cuda from command line - win32

I don't want the whole VS install, especially since it would eat up most of my C space, so I grabbed the SDK. I've also installed the cuda SDK. I'm running into a rather absurd problem though:
d:\cuda\class>nvcc --cubin unit1-1.cu
unit1-1.cu
unit1-1.cu
tmpxft_00001224_00000000-5_unit1-1.cudafe1.gpu
tmpxft_00001224_00000000-11_unit1-1.cudafe2.gpu
'nvopencc' is not recognized as an internal or external command,
operable program or batch file.
d:\cuda\class>nvopencc
nvopencc: no input files
For general help: nvopencc --help
To search help: nvopencc -help:<string>
It's saying that nvopencc isn't a valid command and yet I can run it! Anyone have any idea at all how to fix this?? I found --cubin on a command somewhere and hoped it would work...I have no idea if it's supposed to be there. At any rate, with or without I get the same error.
Here's a typical call to nvcc.exe, generated by Visual Studio 2010. Looks like you need to specify the location of the compiler binaries.
nvcc.exe -gencode=arch=compute_30,code=\"sm_30,compute_30\"
--use-local-env --cl-version 2010 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"
-I"\C\common\inc" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing
Toolkit\CUDA\v5.0\include" --keep --keep-dir "Release" -maxrregcount=0
--machine 32 --compile -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -o "Release\kernel.cu.obj" "c:\test_cuda\test_cuda\kernel.cu"

'X86' conflicts with target machine type 'x64'

I'm getting the following error:
LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
I'm working on a 64 bit machine (VS2008) and I have the x64 compiler. I checked that the build is on x64.
Why isn't it compiling? Here's the build log:
echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\include" -maxrregcount=0 --compile -o "x64\Debug/lowWrappers.cu.obj" lowWrappers.cu
In the top of the properties dialogue, there's a Platform dropdown. That should say "Active(x64)". If it says "Active(Win32)", that's your problem. Click "Configuration Manager..." in the top right, select the platform for your project, select "" and find x64. You can then delete the Win32 platform if you like.
(this might be a bit out of date...but I found a fix, since I just ran into this problem).
The short answer, in your Project Properties->Configuration Properties->CUDA RuntimeAPI->Host
set the "Target Machine Platform" to x64. (mine was at x86 despite having the platform at x64).
Make sure that any libraries you are using have also been compiled on 64 bit.

How to build CUDA 4.0 samples with Visual Studio?

I'm using Visual Studio 2010 and want to build the examples under C:\ProgramData\NVIDIA Corporation\NVIDIA 4.0 GPU Computing Toolkit\C\src.
I had lots of problems regarding include files, but they are partly solved by building the cutil project under C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common using Visual Studio.
But when I try to compile the nbody example, I get an error message which implies a conflict with previously installed 3.2 GPU Computing Toolkit.
How can I fix this "exit with -1" error?
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA
4.0.targets(357,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"./" -I"../../common/inc"
-I"../../../shared/inc" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include" -G0 --keep-dir "Debug" -maxrregcount=0
--machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler "/EHsc /nologo /Od /Zi /MTd " -o "Win32/Debug/bodysystemcuda.cu.obj"
"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK
4.0\C\src\nbody\bodysystemcuda.cu"" exited with code -1.
You appear to have the 3.2 include directory in the path instead of the 4.0 what is CUDA_INC_PATH set to ?

Cuda 4.0 with Visual Studio 2010 cl compiler error

As I did not get any help in the Nvidia forums (see my post at the bottom of the thread), and it seems I am not the only one struggeling with similar problems, I will give it a try here.
I tried to compile the Cuda SDK 4.0 examples as well as following the very nice tutorial by Ade Miller. But compiling the ".cu" file won't work.
This is the (exemplary) command the compiler invokes:
"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 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC bin\x86_amd64"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" -G0
--keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -D_NEXUS_DEBUG
-g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "x64\Debug\Hello.cu.obj"
"D:\Code\CUDA\Test_Cuda_4_0\Test_Cuda_4_0\Hello.cu"
And this is the strange error message I always get.
nvcc fatal : Compiler 'cl' in PATH different than the one specified with -ccbin
EDIT: To be a bit more precise: Visual Studio just tells me the command did not succeed ("exit code -1") -> to see this error message I have to invoke the command by myself in the command line.
1) Why should nvcc care about the path in the environment variable differing from the one specified with the command line option? If it would care, wouldn't this make the command line option completely useless?
2) How to fix ;) ?
I use Win7 64Bit, VS2010 Prof SP1, and the following nvidia versions:
cudatoolkit_4.0.17_win_64
devdriver_4.0_winvista-win7_64_270.81_general
gpucomputingsdk_4.0.19_win_64
Many thanks for your help!
try using the conventional method to start writing a CUDA program, as given in Getting Started guide(Copy the sample). To solve the above problem you have to add it as an environment variable. But since the SDK samples are already linked, they don't give problems.
I had a similar problem. previously i copied cl.exe in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin for test several parameters with nvcc.exe and forget delete this file from this directory. i removed this file and everything is OK. purpose of PATH for my problem in really was for this path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin and wasn't PATH in Environment variables.

Resources