While working on cupy/cupy#9959, I had to do some partial reorganizing to get the Poisson Binomial gufuncs working in CuPy. This is become the Poisson Binom kernels live in xsf/include/xsf/stats.h, and this contained a mix of CPU+GPU code and CPU-only code. I think it's about time that we systematically organize the headers to make it clear which functions are supported on which platforms, and to ensure that NVRTC won't choke due to some CPU-only code being mixed into a header that is supposed to be GPU only.
Also, we need to make sure to only use relative includes within xsf. I saw that some things like #include "xsf/config.h" have snuck in recently. This will break on CuPy because xsf doesn't exist at the top level include path there, but falls under include/cupy/xsf.
I propose a directory structure like
xsf/include/xsf/... for host + device capable code
xsf/include/xsf/cpu/... for cpu-only code (and functions will go in an xsf::cpu namespace.
xsf/include/xsf/numpy.h can be grandfathered in at the top level, and this stuff is in the xsf::numpy namespace anyway and is already clearly demarcated.
Rather than doing this all in one go, I want to reorganize in this fashion on a piece-meal basis, as things are touched. So as I work to complete the changes needed for cupy/cupy#9959, I will only make this split for what is now stats.h. For any header which is intended to work on CPU/GPU I will make sure there are tests which confirm no CPU-only things have snuck in. I will also look into adding tests to make sure only relative imports are used.
@dschmitz89, @fbourgey I figured it would be best to post this to make sure we're all on the same page about this before I make a PR for the changes needed for cupy/cupy#9959.
While working on cupy/cupy#9959, I had to do some partial reorganizing to get the Poisson Binomial gufuncs working in CuPy. This is become the Poisson Binom kernels live in
xsf/include/xsf/stats.h, and this contained a mix of CPU+GPU code and CPU-only code. I think it's about time that we systematically organize the headers to make it clear which functions are supported on which platforms, and to ensure that NVRTC won't choke due to some CPU-only code being mixed into a header that is supposed to be GPU only.Also, we need to make sure to only use relative includes within
xsf. I saw that some things like#include "xsf/config.h"have snuck in recently. This will break on CuPy becausexsfdoesn't exist at the top level include path there, but falls underinclude/cupy/xsf.I propose a directory structure like
xsf/include/xsf/...for host + device capable codexsf/include/xsf/cpu/...for cpu-only code (and functions will go in anxsf::cpunamespace.xsf/include/xsf/numpy.hcan be grandfathered in at the top level, and this stuff is in thexsf::numpynamespace anyway and is already clearly demarcated.Rather than doing this all in one go, I want to reorganize in this fashion on a piece-meal basis, as things are touched. So as I work to complete the changes needed for cupy/cupy#9959, I will only make this split for what is now
stats.h. For any header which is intended to work on CPU/GPU I will make sure there are tests which confirm no CPU-only things have snuck in. I will also look into adding tests to make sure only relative imports are used.@dschmitz89, @fbourgey I figured it would be best to post this to make sure we're all on the same page about this before I make a PR for the changes needed for cupy/cupy#9959.