Skip to content

Setup and Compilation

jgbit edited this page Jun 7, 2020 · 3 revisions

Support

The only requirements for developing with the VUDA library is to have access to a Vulkan compatible system and install the Vulkan SDK. That said, the main tested targets of VUDA are Windows, Linux and Mac OS (through MoltenVK).

Compilation

To compile a c++17 program (x64) using the VUDA library it is necessary to specify:

  • The path to the VUDA header file.
  • The path to the Vulkan SDK header files.
  • The path to the Vulkan SDK library files and add the additional library dependency.

Each sample accompanying the VUDA library includes a simple Makefile for compilation with g++. Simply set the path to the sample folder and run make. (if you have the CUDA toolkit installed you can compile with NVCC by simply typing make cuda).

Setting up the samples in Visual Studio is straight-forward. Make sure you compile x64 and enable c++17 features. Set the include and libary paths as well as the additional dependency on vulkan-1.lib.

Setting up the samples using Xcode is similar. Make sure to change the C++ Language Dialect to C++17 [-std=c++17], add the path to the VUDA inc directory and the Vulkan SDK's macOS/include directory to the Header Search Paths. Add both the libvulkan.1.dylib and the libvulkan.1.x.yyy.dylib to the Project navigator. (see etc. here).

Compile flags

Flag Comment
VUDA_STD_LAYER_ENABLED Enables the LunarG standard validation layer
VUDA_DEBUG_ENABLED Enables run-time exceptions

Compute kernels

It is helpful to set up the compilation of the kernels as a part of the build process.

VUDA only takes kernels in SPIR-V format (for more information see Kernel launches under Deviations from CUDA). VUDA does not provide any support for compiling CUDA C kernels directly to SPIR-V (yet). However, it does not know or care how the SPIR-V source was created - (as long as the entrypoint is the GLCompute execution model).

Most samples are based on GLSL compute shaders which are translated into SPIR-V using the glslangValidator with target “.comp” files (for a compute shader), e.g. glslangValidator.exe -V kernel.comp.glsl -o kernel.spv It also gives support for HLSL compute shaders: glslangValidator.exe -V kernel.comp.hlsl -o kernel.spv. Alternatively, kernels can be written in OpenCL and translated using clspv. clspv kernel.cl -o kernel.spv

Comparison with CUDA

If you are developing on CUDA-capable device, each sample can also be compiled with CUDA. To compile CUDA source code, install the CUDA toolkit.

To compile with CUDA simply type make cuda