我们不能对CUDA中的浮点变量使用原子操作吗? [英] Can't we use atomic operations for floating point variables in CUDA?

查看:304
本文介绍了我们不能对CUDA中的浮点变量使用原子操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 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 仅支持整数参数,而计算能力3.5设备仅支持64位整数参数。

The short answer is no. 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中的浮点变量使用原子操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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