[LLVMdev] PTX generation examples?

Justin Holewinski justin.holewinski at gmail.com
Mon Dec 9 07:00:50 PST 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131209/17719ba0/attachment.html>


More information about the llvm-dev mailing list