Inline Support

As a quick clarification, are inline functions supported for __device functions? There doesn’t appear to be documentation on them in the reference guide, although there are several __host __device inline functions defined in samples. Several of my more complex kernels can be made much more readable via some refactoring to inlined functions…


I compiled successfully this function using nvcc:

inline __device__  void vec3_sub ( const vec3* a, const vec3* b, vec3* res )


	res->x = a->x - b->x;

	res->y = a->y - b->y;

	res->z = a->z - b->z;


If I remove the “inline” I got a compiler error… Something like “sorry, device functions cannot be called, pls use inline”.

however I cannot tell you if works in the HW… cuz I’m making my first CUDA programs in emultation mode :))

Currently all device functions are automatically inlined, so the inline keyword is redundant.

I’m not sure what caused that error. How did you try to call the function? Note you can’t call device functions from the host, only from other device or global functions.

Only global functions can be called from the host, using an execution configuration (<<< >>>).