几个线程在相同的全局内存位置写入相同的值 [英] Several threads writing the same value in the same global memory location

查看:82
本文介绍了几个线程在相同的全局内存位置写入相同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与这一个,但我属于CUDA世界。

This question is closely related to this one, but mine belongs to the CUDA world.

我在内核中有几个线程可以写入相同的值相同的全局内存位置。这已经工作正常,但恐怕它可能是假的,到目前为止,我只是幸运。

I have several threads in my kernel that could write the very same value in the same global memory location. This has been working fine, but I'm afraid that it could be potentially bogus, and that so far I was just being lucky.

是否有任何内存损坏的可能性或我的工作流程中的意外行为(由于数据竞争,缓存同步等)?

Is there any possibility of memory corruption or unexpected behavior in my workflow (due to data races, cache syncing, etc)?

推荐答案


我在内核中有几个线程可以在同一个全局内存位置。

I have several threads in my kernel that could write the very same value in the same global memory location.

与某些评论相反,这是安全的。通过安全,我的意思是写入的值将显示在该全局内存位置。不存在不会发生写入的可能性,并且不存在一些其他伪数据损坏的可能性。 此处的汤姆的回答适用于此。

Contrary to some of the comments, this is safe. By safe, I mean that the value written will show up in that global memory location. There is no possibility that a write will not occur, and there is no possibility of some other spurious data corruption. Tom's answer here is applicable to this.

如果正在写入不同的值,那么其中一个值将在该位置结束,但其中的值未定义。

If different values are being written, then one of the values will end up in that location, but which value is undefined.

这篇关于几个线程在相同的全局内存位置写入相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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