我有以下例程,用于根据index中找到的索引将元素从src矩阵复制到dst矩阵。索引计算正确,但dst未更新。我遗漏了什么?
__kernel void
src_indexed_copy(__global real *dst, __global const real *src,
   __global const int *index, int src_offset)
{
        int id = get_global_id(ROW_DIM);
        int src_idx = src_offset + index[id];
        dst[id] = src[src_idx];
}全局工作区的工作项数量与索引数组中的索引数量一样多。
线性代码看起来像这样:
for (k = 0; k < n; k++) {
        dst[k] = src[m * column + index[k]];
}其从矩阵src中的列列复制所有索引的元素。
这就是我读回缓冲区的方式(在评论中被问到):
rc = clEnqueueReadBuffer(ompctx->clctx.queue, c,
        CL_TRUE, 0, i * sizeof(real), &tmp[0],
        0, NULL, NULL);
if (rc != CL_SUCCESS) {
    log_error("omp", "[%d] readbuf() failed", rc);
    goto err;
}
log_info("omp", "c");
for (k = 0; k < i; k++) {
    log_info("omp", "%6.8f", tmp[k]);
}发布于 2013-04-10 23:57:33
一定是主机代码出了问题。请验证:
https://stackoverflow.com/questions/15929592
复制相似问题