I have a curiosity about the best way to handle this. I have a simulation which has macroscopic parameters controlled by a structure in global memory, with some host functions for getting and setting the globals via cudaMemcpyToSymbol. This works well.
However, some of the functions are declared as device and host so that I can have a unit testing framework exercise the individual functions. Some of those functions refer to the globals, so they can’t be exercised from the host, because of course the host can’t access the global in the same way.
I tried implementing a host-side globals structure, which would work–but I’d need some way for the functions themselves to tell if they were running on the device or the host, and I can’t find a way to do that. Is there any good pattern for this sort of thing?