CUDA中的整数最小值/最大值 [英] Integer min/max in CUDA

查看:168
本文介绍了CUDA中的整数最小值/最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CUDA Math API 文档中看到了一些功能单精度和双精度最小/最大运算(例如 fminf())。我认为这些是高度优化的,等等。对于整数,似乎没有像这样的函数。这是真的?

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?

推荐答案

存在整数的最小/最大设备函数,但是它们都被重载调用 max()。在device_functions.hpp中查找:

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);
}

它们未在Integer Intinsics部分中列出,因为在math_functions.hpp中 max 函数已重载,可以为您调用这些函数。 __ nv * 函数记录在device_function_decls.hpp中。

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.

这篇关于CUDA中的整数最小值/最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆