Kassiopeia
Kassiopeia copied to clipboard
Feature request: Make OpenCL integration device agnostic
The issue
When compiling Kassiopeia with OpenCL enabled, currently the resulting code is bound to the given OpenCL devices during compile time. This is the only reason we can't provide Docker images with OpenCL enabled and why one can't compile Kassiopeia with OpenCL on one system and run it on another system (a difficulty for some HPC systems).
The background
Currently, when compiling, first https://github.com/KATRIN-Experiment/Kassiopeia/blob/main/KEMField/Source/Plugins/OpenCL/Core/src/GenerateOpenCLHeader.cc is compiled by cmake, which generates a platform-dependent header file called kEMField_opencl_defines.h
that itself is included in OpenCL (.cl
) code. That by itself could all happen at runtime since OpenCL code is compiled at runtime. But then the same header file is also used indirectly by many C++ source files (through KOpenCLInterface.hh
through KOpenCLHeaderWrapper.hh
). That's the issue.
This dependency is used to know during compile time whether double precision is available on the OpenCL hardware and therefore the C++ interface can use double or float precision for buffers as well. This can be seen by grepping for CL_TYPE
in C++ header and source files.
There is no need for this decision between float
and double
happening during compile time. It happening during compile time just means one can't change the OpenCL platform later. I therefore think it would be best to avoid all occurrences of CL_TYPE
in C++ code and always cast to double
or use dynamic types instead.