是否有dpc+/sycl等效于cuda的atomiccas?
从我的理解来看,CUDA的atomiccas
具有以下定义(这是四个)
int atomicCAS(int* address, int compare, int val);
,它在原子上比较了位于address> address>
的值(在doc 中命名
)在“全局共享”内存中使用比较
,如果平等将值分配给val
,否则什么都不做。在这两种情况下,返回旧
。
查看SYCL API,我只能找到compare_exchange_strong
,不幸的是,它并没有使用与上述相同的命名,它将old
与比较
,如果不成功,则会改变比较(通过引用传递)。
From my understanding, CUDA's atomicCAS
has the following definition (this is one of the four)
int atomicCAS(int* address, int compare, int val);
and it compares atomically the values located at address
(named in the doc old
) in the global shared memory with compare
and in case of equality assigns the value to val
, otherwise does nothing. In both cases returns old
.
Looking at SYCL API, I can only find compare_exchange_strong
which, unfortunately, does not do what I'm looking for as, using the same naming as above, it compares old
with compare
and if not successful, alters compare
(which is passed by reference).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如彼得·科德斯(Peter Cordes)在评论中指出的那样,
sycl :: compare_exchange_strong
是正确的选择。从SYCL 2020 Rev。 4的描述compare_exchange_strong
:So,
is, in terms of updating
ref
, equivalent toIf you are interested, you can
As Peter Cordes noted in a comment,
sycl::compare_exchange_strong
is the right choice. From the SYCL 2020 rev. 4 description ofcompare_exchange_strong
:So,
is, in terms of updating
ref
, equivalent toIf you are interested, you can see for yourself how hipSYCL implements
sycl::compare_exchange_strong
.