小编ggg*_*123的帖子

GNU 并行和 GPU?

我有兴趣让 GNU Parallel 在 GPU 上运行一些数值计算任务。一般来说,这是我最初的方法:

  1. 编写任务以使用 OpenCL 或其他一些 GPU 接口库
  2. 在任务列表上调用GNU并行(我不确定是否需要这一步

这就提出了以下问题:

  1. 我的方法/用例是否受益于 GNU Parallel 的使用(即我是否应该在这里使用它)?
  2. GNU Parallel 是否提供了在 GPU 上并行运行任务的内置机制?
  3. 如果是这样,我该如何配置 GNU Parallel 来做到这一点?

gpu gnu-parallel

2
推荐指数
1
解决办法
1823
查看次数

有人可以解释为什么这可以计算无符号整数中的设置位吗?

我看到了这段名为“Counting bits set, Brian Kernighan's way”的代码。我很困惑如何“按位与”整数及其减量如何计算设置位,有人可以解释一下吗?

unsigned int v; // count the number of bits set in v
unsigned int c; // c accumulates the total bits set in v
for (c = 0; v; c++)
{
  v &= v - 1; // clear the least significant bit set
}
Run Code Online (Sandbox Code Playgroud)

c bit-manipulation kernighan-and-ritchie

2
推荐指数
1
解决办法
395
查看次数