Using PTX with Runtime Possible?

I am using the Runtime environment (not the driver level) in Visual Studio. I am wondering if it is possible to compile an executable with a PTX embedded, which will compile (using JIT) to a device specific binary at runtime. The documentation I have read seems to say this is possible, but I cannot find any examples in the SDK which use the Runtime API–only the Driver API. I tried changing the custom build rule for the file to only compile .ptx and turned on ‘keep’, so the file would not be deleted. When I try to compile the main .cpp file, I get unresolved externals if I do not specify this .ptx file in the Linker. If I do specify the .ptx file in the Linker, I get an ‘invalid or corrupt file’ error. Could someone explain the process of doing this in Visual Studio, if it is possible using the Runtime API?


The runtime will JIT automatically.


Thank you very much for the reply. So, to enforce a PTX compilation of code only (no cubin) in Visual Studio, do I just enter something like: ‘gencode=arch=compute_10,code=compute_10’ as an argument/flag to nvcc or do I need to change the custom build rule for the file to generate .ptx code only? Since either is a change to the custom build rule, do I modify only the build rule arguments or the Solution build rule arguments or both? (I know I am showing my ignorance here about MSVS in general).

bump to tmurray

From my experience, nvcc always embeds ptx in compiled .cu files. Whether or not it is actually loaded rather than an embedded cubin is up to the runtime…