CUDA/C++ Style Guide

File Structure

  • All C++ headers (.h, .hpp) must be includable in sources built without cuda support

  • Use C++ source files (.cc, .cpp) where possible for improved compilation speed

  • Use Cuda source files (.cu) only for code blocks containing device code (at least 1 _device_ or _global_ definition)

  • Use empty _host_ and _device_ definition guards in function headers to make them portable for builds without cuda support

  • Do not declare _global_ functions in C++ header or source file (.h, .hpp, .cc, .cpp)

  • Declare kernel calling functions in C++ headers (.h, .hpp) and encapsulate pointers to device and host memory locations

Naming Conventions

  • Use g_ prefix for _global_ functions to signify a cuda kernel entry point