2
votes

I am having problem converting .cu to .ptx. I am using nvcc as follows:

"C:\ Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc" -ptx -ccbin "C:\ Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -o foo.ptx foo.cu

The following is displayed in return:

foo.cu
c1xx : fatal error C1083: cannot open source file: 'foo.cu': No such file or directory

foo.cu is located in the \CUDA\v5.0\bin.

1
In which folder are you running the command? This just means that nvcc cannot find your foo.cu file. Either run the command in the file's folder, or provide a full path to nvcc. - BenC
I am giving the full path in the command but you have edited my message. > "C:\ Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc" -ptx -ccbin "C:\ Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -o foo.ptx foo.cu - Maverick
You are right. I gave the command from the said directory and it is now compiling. Its giving something like: 'tmpxft_00001100_000000000-5_foo.cudafe1.gpu' and 'tmpxft_00001100_000000000-10_foo.cudafe2.gpu' But where do I find my foo.ptx? I cannot see it. Is something still wrong? - Maverick
The ptx files are in the directory from which you launched nvcc. For instance, if I run the following command on Linux: nvcc test.cu -ptx -o test.ptx, I get test.ptx in the current directory. - BenC
No, not there. Is there any other non-commandline method? - Maverick

1 Answers

4
votes

Go to the Project Properties in Visual Studio 2010. In CUDA C/C++, in Common change the property Keep Preprocessed Files to Yes(--keep). Build the project. You should be able to see the .ptx file in folder as C:/Users/Mansoor/Documents/Visual Studio 2010/Projects/Testing_PTX/x64/Debug depending on the configuration (x32 or x64). If your .cu filename was TestingPTX.cu then the filename for PTX file would be TestingPTX.compute_xx.ptx where xx is the compute capability defined in your project properties. For multiple compute capability options there will be a dedicated .ptx file. The content of a typical PTX file can be seen at pastebin.com It is very straight forward but took me quite some time to figure out because there is not much material over the internet regarding generation of .ptx within the Visual Studio environment. Hope it will help the newbies like me.