Closed mattboran closed 5 years ago
For consistency between CPU and GPU versions, consider using the following
struct Sampler { __host__ __device__ virtual float getNextFloat() { return rand() / (RAND_MAX + 1.f); } }; struct ParallelSampler : Sampler { curandState* p_curandState; __host__ __device__ virtual float getNextFloat() { return curand_uniform(p_curandState); } };```
Can't do this. Try a templatized version?
Solution was posted to reddit: https://www.reddit.com/r/CUDA/comments/adnzcb/using_c_templates_or_some_other_mechanism_to/
And stackoverflow: https://stackoverflow.com/questions/54115284/how-to-use-macros-or-c-templates-to-allow-reusable-code-in-both-host-and-devic
For consistency between CPU and GPU versions, consider using the following