Open jamesavery opened 2 years ago
This has been handled in #25: each implementation now has it's own subfolder, and choosing between them is done through importing. E.g. the GPU version would be:
import lib.cpp.gpu.histograms
whereas the parallel CPU version would be
import lib.cpp.cpu.histograms
TODO (later) should be where the specific implementation could be emitted for better portability, e.g.: if a GPU and a GPU implementation is available, choose that, otherwise choose parallel CPU if a parallel CPU implementation exists, otherwise choose the sequential CPU version.
Currently, we have a bit of a mess for choosing the different "backend" implementations: sequential CPU, parallel CPU, and GPU is selected with suffixes to function names (e.g. field_histogram_par_cpu). This is quite messy.
Instead, we should gather the full implementation for each backend in their own directories (seq_cpu, par_cpu, gpu), with a common header file to ensure identical functionality.
Proposed solution: A bit of code in pybind_kernel/init.py can read an environment variable, e.g. PYBIND_BACKEND, and choose the correct backend when importing from pybind_kernel. If multiple backends are needed in a single python script, the user can import explicitly as "import pybind_kernels.seq_cpu as pb_seq, pybind_kernels.par_cpu as pb_par", for example.