NVIDIA Developer Zone

CUDA LLVM Compiler

NVIDIA's CUDA Compiler (NVCC) is based on the widely used LLVM open source compiler infrastructure. Developers can create or extend programming languages with support for GPU acceleration using the CUDA Compiler SDK.

Add GPU Acceleration To Your Language

You can add support for GPU acceleration to a new or existing language by creating a language-specific frontend that compiles your language to the internal representation (IR) used by LLVM. Many language frontends already exist.

The IR generated by your front end is then optimized for execution on your target device. You can add support for a new device by developing a processor-specific backend which will perform the final compilation on the optimized LLVM IR.

NVIDIA has worked with the LLVM organization to contribute the CUDA compiler source code changes to the LLVM core and parallel thread execution backend, enabling full support of NVIDIA GPUs.

CUDA Compiler SDK

The SDK contains documentation, examples and tested binaries to get you started on your own GPU accelerated compiler project.

Some of the items including in the SDK are:

  • NVVM IR specification, a target-specific subset of the LLVM IR 
  • libNVVM library and header files - which can be linked to your executable
  • NVVM IR verifier sample, for verifying parallel enabled IR from language front ends
  • Supports Mac, Windows and some Linux Platforms
  • Frontend code samples for:
    • R, a statistical computing and graphic programming language
    • Kaleidoscope, a simplied  programming language example
    • CLANG, front end for C/C++

The SDK contains samples which demostrate how to compile the R code below and generate the graphical results shown.

# define the code for Mandelbrot
mandelbrot <- function(x0, y0)
{
  iteration <- 0L;
  max_iteration <- 50L;
  x <- 0;
  y <- 0;
  while ( (x*x + y*y < 4) &&
        (iteration < max_iteration) )
  {
    xtemp <- x*x - y*y + x0;
    y = 2*x*y + y0;
    x = xtemp;
    iteration = iteration + 1L;
  }
  color = iteration;
  color;
}
# create data, compile and run and get results!
dv_points_x=rg.dv(points_x);
dv_points_y=rg.dv(points_y);
dv_points_color = rg.gapply(mandelbrot,
                     dv_points_x, dv_points_y);
colorvec = as.integer(dv_points_color);

Download the Compiler SDK

The CUDA Compiler SDK will be made available to our CUDA registered developers during GTC 2012 next week, please join the CUDA Registered Developer Program today to be kept informed of the SDK's availability.

Getting Support

Source Availability

NVIDIA has contributed key enhancements to the LLVM project to enable support of CUDA and massively parallel accelerators such as GPUs. Source is available from the LLVM Project Home Site.