README for CUDA Compiler SDK Samples ==================================== Introduction ------------ Here are three simple samples illustrating the use of libNVVM. simple reads in a NVVM IR program from a file, compiles it to PTX, and launches the program on GPU using CUDA driver APIs. ptxgen is a standalone NVVM IR program to PTX compiler. It will link the libDevice library with the input NVVM IR program, verify the IR for conformance to the NVVM IR specification, and then generate PTX. cuda-c-linking builds an NVVM IR program using the LLVM IR build APIs, links the generated PTX with a PTX generated by nvcc, and launches the linked program on GPU using CUDA driver APIs. Steps of Building the Samples ----------------------------- The following three environment variables can be used to control the build process for the samples. If not specified, CUDA_HOME will be derived by looking for nvcc in your PATH. CUDA_HOME : The directory where the CUDA toolkit is installed, e.g. /usr/local/cuda. LIBNVVM_HOME : The directory where libNVVM components are located. e.g. $CUDA_HOME/nvvm. LLVM_HOME : The directory of CMake-based LLVM install directory. This must point to an installation of LLVM 3.2. If you don't set LLVM_HOME or do not have CMake-based LLVM installed, then the sample 'cuda-c-linking' will not be built. This sample requires LLVM version 3.2. After setting the environment variables and adding path to cmake tool in the PATH environment variable, sample script build.sh (for Linux and Mac OS X) or build.bat (for Windows) may be executed. This script will use build directory "build" to build the samples, and then install them in the "install" directory. The following shows how to build the samples on Linux and Mac OS X. Note that setting CUDA_HOME and LIBNVVM_HOME are not needed if nvcc is in your PATH. $ export CUDA_HOME= $ export LIBNVVM_HOME= $ export LLVM_HOME= $ mkdir $ cd $ cmake -DCMAKE_INSTALL_PREFIX= -DCUDA_HOME=$CUDA_HOME -DLIBNVVM_HOME=$LIBNVVM_HOME -DLLVM_HOME=$LLVM_HOME .. $ make install The following shows how to build the samples on Windows. Note that setting CUDA_HOME and LIBNVVM_HOME are not needed if nvcc is in your PATH. $ set CUDA_HOME= $ set LIBNVVM_HOME= $ set LLVM_HOME= $ mkdir $ cd $ cmake -DCMAKE_INSTALL_PREFIX= -DCUDA_HOME=%CUDA_HOME% -DLIBNVVM_HOME=%LIBNVVM_HOME% -DLLVM_HOME=%LLVM_HOME% -G "NMake Makefiles" .. $ nmake install is the directory where you want the built binaries to be installed. The built executables will be copied under /bin.