Quicksilver icon indicating copy to clipboard operation
Quicksilver copied to clipboard

Functions declarations have HOST_DEVICE_CUDA but definitions

Open ilagunap opened this issue 7 years ago • 2 comments

In MC_Particle.hh: Function declaration of Move_Particle uses HOST_DEVICE_CUDA:

   HOST_DEVICE_CUDA
   void Move_Particle(const DirectionCosine & direction_cosine, const double distance);

but function definition does not: inline void MC_Particle::Move_Particle( const DirectionCosine &my_direction_cosine, …

In file ParticleVault.hh: putParticle is declared as HOST_DEVICE_CUDA, but the function definition does not use HOST_DEVICE_CUDA. invalidateParticle is declared as HOST_DEVICE_CUDA, but the function definition does not use HOST_DEVICE_CUDA.

ilagunap avatar Sep 05 '18 00:09 ilagunap

This is an interesting point. Do you think that the reason it currently compiles/works is due to them being inline functions, negating the compilers need to specify __host__ __device__ ?

I agree that these should match.

bleile1 avatar Sep 05 '18 15:09 bleile1

NVCC is silent on this issue, but clang generates an error. Here's the error I get when compiling with clang:

./ParticleVault.hh:175:1: error: __host__ function 'putParticle' cannot overload __host__ __device__ function 'putParticle'
putParticle(MC_Particle particle, int index)
^
./ParticleVault.hh:62:9: note: previous declaration is here
   bool putParticle(MC_Particle particle, int index);

When I add HOST_DEVICE_CUDA to the function definition the error is solved.

I'm not sure why in nvcc it works, but generally speaking clang is more strict on these language/semantics issues.

ilagunap avatar Sep 05 '18 16:09 ilagunap