如何从 .cu 文件获取 NVVM IR (LLVM IR) 以及如何将 NVVM IR 编译为二进制文件?
How can I get NVVM IR (LLVM IR) from .cu - file and how to compile NVVM IR to binary?
我有一个用于 CUDA 7.5 的 CUDA C/C++ 程序。众所周知:libNVVM 库 - 一个优化编译器库,可从 NVVM IR 生成 PTX。
我可以通过以下方式获取 PTX:nvcc -ptx <file>.cu -o <file>.ptx
但是如何从 <file>.cu
获取 NVVM IR (LLVM IR)?
以及如何为目标架构编译 NVVM IR (LLVM IR) 或优化 IR?
我是否需要此第三方库或程序,例如:libcuda.lang、...?
The NVVM compiler (which is based on LLVM) generates PTX code from
NVVM IR.
NVVM IR and NVVM compilers are mostly agnostic about the source
language being used. The PTX codegen part of a NVVM compiler needs to
know the source language because of the difference in DCI
(driver/compiler interface).
Technically speaking, NVVM IR is LLVM IR with a set of rules,
restrictions, and conventions, plus a set of supported intrinsic
functions. A program specified in NVVM IR is always a legal LLVM
program. A legal LLVM program may not be a legal NVVM program.
非常简短的回答是你不能这样做。 NVIDIA 的解析器是专有的和闭源的,他们没有以您所询问的方式公开 IR 代码生成器。
也就是说,您不是第一个对此感到疑惑的人,您或许可以找到一些有用但完全非官方且不受支持的信息here。
我有一个用于 CUDA 7.5 的 CUDA C/C++ 程序。众所周知:libNVVM 库 - 一个优化编译器库,可从 NVVM IR 生成 PTX。
我可以通过以下方式获取 PTX:nvcc -ptx <file>.cu -o <file>.ptx
但是如何从 <file>.cu
获取 NVVM IR (LLVM IR)?
以及如何为目标架构编译 NVVM IR (LLVM IR) 或优化 IR?
我是否需要此第三方库或程序,例如:libcuda.lang、...?
The NVVM compiler (which is based on LLVM) generates PTX code from NVVM IR.
NVVM IR and NVVM compilers are mostly agnostic about the source language being used. The PTX codegen part of a NVVM compiler needs to know the source language because of the difference in DCI (driver/compiler interface).
Technically speaking, NVVM IR is LLVM IR with a set of rules, restrictions, and conventions, plus a set of supported intrinsic functions. A program specified in NVVM IR is always a legal LLVM program. A legal LLVM program may not be a legal NVVM program.
非常简短的回答是你不能这样做。 NVIDIA 的解析器是专有的和闭源的,他们没有以您所询问的方式公开 IR 代码生成器。
也就是说,您不是第一个对此感到疑惑的人,您或许可以找到一些有用但完全非官方且不受支持的信息here。