0

我想将 float2 值复制回 CPU。GPU 端的结果是正确的,但 CPU 端的结果有些不正确。有人可以帮帮我吗

显卡代码

    #pragma OPENCL EXTENSION cl_amd_printf : enable
__kernel void matM(__global float* input, int width, int height, __global float2* output){    
    int X = get_global_id(0);
    float2  V;  
    V.x = input [X];
    V.y = input [X];
    output[X] = V;  
    printf("%f\t %f\n",output[X].x,output[X].y);
  }

中央处理器代码

output = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(cl_float2) * wid*ht, NULL, NULL);
clEnqueueReadBuffer( commands, output,CL_TRUE, 0, sizeof(cl_float2) * wid *ht, results, 0, NULL, NULL );

内部printfGPU 内核打印正确的结果,但主机端结果不正确。

感谢您的帮助

4

1 回答 1

0

cl_float2数据类型可用于主机端访问float2数据,但我的问题是别的。

全局 ID 不匹配,我有两个全局 ID,第 3 行应该是int X = get_global_id(0) + get_global_id(1).

于 2012-06-17T18:15:22.060 回答