我们可以知道哪个块/线程找到设备内存的最小值吗? [英] Can we know which block/thread find the minimum value of the device memory?
问题描述
cuda atomicMin
操作似乎只找到设备内存中继的最小值。但是,有没有反正找到哪个块/线程最终找到这个最小值?我有compute-2.0。
cuda atomicMin
operation seems only find the minimum value of a device memory trunk. But, is there anyway to find which block/thread finally find this minimum value? I have compute-2.0.
推荐答案
如果你正在做一个 atomicMin
在32位值上,可以对64位值使用广义原子操作,其中32位表示最小值,其中32位表示线程的全局索引。 此处概述了一般方法。
If you are doing an atomicMin
on a 32-bit value, you can use a generalized atomic operation on a 64 bit value, 32 bits of which represent the minimized value, and 32bits of which represent the global index of the thread. A general approach is outlined here.
由于64位 atomicMin
是仅支持cc 3.5设备,我假设您找到的是32位最小值。
Since 64 bit atomicMin
is only supported on cc 3.5 devices, I assume you are finding 32-bit minimum values.
如果您正在工作使用64位值,则可以使用并行缩减技术通过缩减来携带最小(或最大)值和索引。 此问题/ answer 演示了一种平行缩减方法,它可以找到矩阵的每行的最大值和索引。
If you are working with 64-bit values, then you can use a parallel reduction technique to carry both the minimum (or maximum) value and the index through the reduction. This question/answer demonstrates a parallel reduction approach which finds both maximum and index, per row of a matrix.
这篇关于我们可以知道哪个块/线程找到设备内存的最小值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!