如何从.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?

查看:1296
本文介绍了如何从.cu文件获取NVVM IR(LLVM IR)以及如何将NVVM IR编译为二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CUDA C / C ++程序CUDA 7.5。已知:libNVVM库 - 一个优化的编译器库,从NVVM IR生成PTX。



我可以通过使用: nvcc -ptx< ; file> .cu -o< file> .ptx



但是如何获得NVVM IR $ c>< file> .cu ?



如何为目标架构编译NVVM IR(LLVM IR) ?



我需要这个第三方库或程序,如:libcuda.lang,...?












    • NVVM编译器(基于LLVM)从
      NVVM IR。



      NVVM IR和NVVM编译器对于正在使用的源
      语言几乎不可知。由于DCI
      (驱动程序/编译器接口)的不同,NVVM编译器的PTX codegen部分需要
      知道源语言。



      从技术上来说,NVVM IR是LLVM IR,有一组规则,
      限制和约定,以及一组支持的内在
      函数。在NVVM IR中指定的程序总是一个合法的LLVM
      程序。合法的LLVM程序可能不是合法的NVVM程序。



      解决方案

      你不能这样做。 NVIDIA的解析器是专有的和封闭的源代码,他们没有以一种你可以使用的方式暴露IR代码生成器。



      不是第一个想知道这一点的人,你可能能够找到一些有用的,但完全非官方和不支持的信息此处


      I have a CUDA C/C++ programm for CUDA 7.5. And as known: libNVVM Library - an optimizing compiler library that generates PTX from NVVM IR.

      I can get PTX by using: nvcc -ptx <file>.cu -o <file>.ptx

      But how can I get NVVM IR (LLVM IR) from <file>.cu?

      And how can I compile NVVM IR (LLVM IR) or Optimized IR for the target architecture?

      Do I need for this third-party libraries or programs such as: 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.

      解决方案

      The very short answer is that you cannot do this. NVIDIA's parser is proprietary and closed source, and they have not exposed the IR code generator in a way which can be used as you are asking about.

      That said, you are not the first person to wonder about this, and you might be able to find some useful, but completely unofficial and unsupported information here.

      这篇关于如何从.cu文件获取NVVM IR(LLVM IR)以及如何将NVVM IR编译为二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆