我想知道何时应该在CUDA中使用x和y坐标?我看到一些代码,当它们有嵌套循环时,它们使用x和y坐标.对此有什么一般规则吗?谢谢
我在 GPU Gems 3, Chapter 39: Parallel Prefix Sum (Scan) with CUDA一书中写了一段代码来调用内核。
然而,我得到的结果是一堆负数而不是前缀扫描。
我的内核调用是错误的还是 GPU Gems 3 书中的代码有问题?
这是我的代码:
#include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
__global__ void kernel(int *g_odata, int *g_idata, int n, int dim)
{
extern __shared__ int temp[];// allocated on invocation
int thid = threadIdx.x;
int offset = 1;
temp[2*thid] = g_idata[2*thid]; // load input into shared memory
temp[2*thid+1] = g_idata[2*thid+1];
for (int d = n>>1; d > 0; d >>= 1) // build sum in place …Run Code Online (Sandbox Code Playgroud)