Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integer min/max in CUDA

Tags:

cuda

I see in the CUDA Math API documentation that there are functions for single and double precision min/max operations (e.g. fminf()). I assume these are highly optimized, etc. There don't seem to be functions like these for integers. Is this true? Is there a reason for that?

like image 397
Phonon Avatar asked Apr 30 '15 21:04

Phonon


Video Answer


1 Answers

There are min/max device functions for integers, but they are all called with an overloaded max(). Look in device_functions.hpp:

__DEVICE_FUNCTIONS_STATIC_DECL__ int max(int x, int y)
{
  return __nv_max(x, y);
}

__DEVICE_FUNCTIONS_STATIC_DECL__ unsigned int umax(unsigned int x, unsigned int y)
{
  return __nv_umax(x, y);
}

__DEVICE_FUNCTIONS_STATIC_DECL__ long long llmax(long long x, long long y)
{
  return __nv_llmax(x, y);
}

__DEVICE_FUNCTIONS_STATIC_DECL__ unsigned long long ullmax(unsigned long long x,
                                                 unsigned long long y)
{
  return __nv_ullmax(x, y);
}

They're not listed in the Integer Intinsics section because in math_functions.hpp the max function is overloaded to call these functions for you. The __nv* functions are documented in device_function_decls.hpp.

like image 177
chappjc Avatar answered Oct 05 '22 07:10

chappjc