We present PATOS, a CLANG-based source-to-source compiler to extend the OpenCL kernel language with C++ classes and template types for classes and functions. The generated code is standard conforming OpenCL-C which is usable with unmodified OpenCL drivers. With PATOS, type-agnostic host libraries can directly use OpenCL without having to deal with manual type matching.   First, PATOS has parse for the types that are actually used, either by analyzing the host code or by manually instantiating the required types directly inside of the kernel file. Classes are "flattened" into structs along with functions operating on their data. Templates are separately instantiated with all templates mapped to the requested types. Type-aware name mangling prevents name clashes. The generated header and implementation can be used by the OpenCL driver without modification.
['Franz Richter-Gottfried', 'Patrick Kreutzer', 'Alexander Ditter', 'Max Schneider', 'Dietmar Fey']
C++ Classes and Templates for OpenCL Kernels with PATOS