CUDA 中的整数 min/max

Integer min/max in CUDA

我在 CUDA Math API 文档中看到有用于单精度和双精度 min/max 操作的函数(例如 fminf())。我假设这些是高度优化的,等等。似乎没有像这样的整数函数。这是真的?这有什么原因吗?

有 min/max 个整数设备函数,但它们都是通过重载 max() 调用的。查看 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);
}

它们没有列在 Integer Intinsics 部分,因为在 math_functions.hpp 中,max 函数被重载来为您调用这些函数。 __nv* 函数记录在 device_function_decls.hpp.