如何在 CUDA 中对浮点值使用 atomicMax? [英] How do I use atomicMax on floating-point values in CUDA?

查看:336
本文介绍了如何在 CUDA 中对浮点值使用 atomicMax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 atomicMax() 在 CUDA 内核中找到最大值:

I have used atomicMax() to find the maximum value in the CUDA kernel:

__global__ void global_max(float* values, float* gl_max)
{
    int i=threadIdx.x + blockDim.x * blockIdx.x;
    float val=values[i];

    atomicMax(gl_max, val);
}

它抛出以下错误:

错误:没有重载函数atomicMax"的实例与参数列表匹配

error: no instance of overloaded function "atomicMax" matches the argument list

参数类型为:(float *, float).

推荐答案

简短的回答是你不能.正如您从 原子函数文档中所见atomicMax 仅支持整数参数,64 位整数参数仅在计算能力为 3.5 的设备上支持.

The short answer is that you can't. As you can see from the atomic function documentation, only integer arguments are supported for atomicMax and 64 bit integer arguments are only supported on compute capability 3.5 devices.

这篇关于如何在 CUDA 中对浮点值使用 atomicMax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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