English

__host__ __device__ -- Generic programming in Cuda

Programming Languages 2023-09-11 v1

Abstract

We present patterns for Cuda/C++ to write save generic code which works both on the host and device side. Writing templated functions in Cuda/C++ both for the CPU and the GPU bears the problem that in general both __host__ and __device__ functions are instantiated, which leads to lots of compiler warnings or errors.

Cite

@article{arxiv.2309.03912,
  title  = {__host__ __device__ -- Generic programming in Cuda},
  author = {Thomas Mejstrik},
  journal= {arXiv preprint arXiv:2309.03912},
  year   = {2023}
}

Comments

First draft

R2 v1 2026-06-28T12:15:35.258Z