[LLVMdev] PTX generation examples?

Larry Gritz lg at larrygritz.com
Mon Dec 9 09:19:36 PST 2013


Ah, that's helpful.  I knew that I'd need to end up with PTX as text, not a true binary, but I would have figured that it would come out of MCJIT. Thanks for helping to steer me away from the wrong trail.

OK, one more question: Can anybody clarify the pros and cons of generating the PTX through the standard LLVM distro, versus using the "libnvvm" that comes with the Cuda SDK?

	-- lg


On Dec 9, 2013, at 7:00 AM, Justin Holewinski <justin.holewinski at gmail.com> wrote:

> There is no MCJIT support for PTX at the moment (mainly because PTX does not have a binary format, and is not machine code per se).
> 
> To generate PTX at run-time, you just set up a standard codegen pass manager like you would like an off-line compiler.  The output will be a string buffer that contains the PTX, which you can load into the CUDA runtime.
> 
> As for determining if PTX support is compiled into the LLVM binary you are using, you could register all targets and then check if you can create a Target for the "nvptx" or "nvptx64" triple:
> 
>   InitializeAllTargets();
>   InitializeAllTargetMCs();
>   InitializeAllAsmPrinters();
>   InitializeAllAsmParsers();
> 
>   std::string Err;
>   const Target *Tgt = TargetRegistry::lookupTarget("nvptx64", Err);
>   if (Tgt) {
>     // nvptx target is available
>   } else {
>     // nvptx target is not available
>   }
> 
> 
> More information about the PTX target can be found at: http://llvm.org/docs/NVPTXUsage.html
> 
> 
> 
> On Fri, Dec 6, 2013 at 3:43 PM, Larry Gritz <lg at larrygritz.com> wrote:
> OK, fine -- an example of MCJIT that sets up for PTX JIT would also be helpful.
> 
> 
> On Dec 6, 2013, at 12:32 PM, Eli Bendersky <eliben at google.com> wrote:
> 
>> 
>> You'll have to switch to MCJIT for this purpose. Legacy JIT doesn't emit PTX.
>> 
>> Eli 
> 
> --
> Larry Gritz
> lg at larrygritz.com
> 
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 
> 
> 
> -- 
> 
> Thanks,
> 
> Justin Holewinski

--
Larry Gritz
lg at larrygritz.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131209/eabfea47/attachment.html>


More information about the llvm-dev mailing list