Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencl 两个缓冲区的索引副本_Opencl_Gpu_Gpgpu - Fatal编程技术网

Opencl 两个缓冲区的索引副本

Opencl 两个缓冲区的索引副本,opencl,gpu,gpgpu,Opencl,Gpu,Gpgpu,我有下面的例程,该例程基于在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_id

我有下面的例程,该例程基于在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]];
}
(k=0;k{ dst[k]=src[m*列+索引[k]]; } 它从矩阵src中的列复制所有索引元素

这就是我如何读回缓冲区(在评论中询问):

rc=clenqueueredbuffer(ompctx->clctx.queue,c,
CL_TRUE、0、i*sizeof(real)和tmp[0],
0,空,空);
如果(rc!=CL_成功){
日志错误(“omp”,“[%d]readbuf()失败”,rc);
后悔莫及;
}
日志信息(“omp”、“c”);
对于(k=0;k
主机代码中一定有错误。请核实:

  • allOpenCLAPI调用的返回值
  • 缓冲区创建标志(您需要对目标缓冲区进行写访问)
  • 内核参数对应于内核代码

您如何知道索引计算正确?试着用dst[id]=id来验证你的主机代码。我打印了它,还做了dst[id]=515和dst[id]=id。dst看起来还是一样的。在打印时,我看到索引计算正确。那么您可能无法正确读取dst。你是怎么做到的?上面加了。不管怎样,我总是得到零。@PaulIrofti:如果你能给我们一个简单的、不工作但可编译的代码摘录,那将非常有帮助。
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]);
}