OpenCL忽略内核

时间:2012-06-05 07:47:44

标签: opencl

我熟悉OpenCL。 在互联网上找到了一个简单的例子。

内核是:

__kernel void vector_add(__global const int *A, __global const int *B, __global int *C)  
{
    // Get the index of the current element to be processed
    int i = get_global_id(0);
    // Do the operation
    C[i] = A[i] + B[i];
}

我编译并运行它。结果是:

0 + 1024 = 0
1 + 1023 = 0
2 + 1022 = 0
3 + 1021 = 0
4 + 1020 = 0
5 + 1019 = 0
6 + 1018 = 0
7 + 1017 = 0
8 + 1016 = 0
9 + 1015 = 0
10 + 1014 = 0
11 + 1013 = 0
12 + 1012 = 0
13 + 1011 = 0
14 + 1010 = 0
15 + 1009 = 0
16 + 1008 = 0
17 + 1007 = 0
18 + 1006 = 0
19 + 1005 = 0
20 + 1004 = 0
21 + 1003 = 0
22 + 1002 = 0
23 + 1001 = 0
24 + 1000 = 0
25 + 999 = 0
26 + 998 = 916789344
27 + 997 = 32756
28 + 996 = -1
29 + 995 = 0
...

我注意到它不依赖于* .cl文件内容。如果我改变C [i] = A [i] + B [i];在C [i] = 3。结果是一样的。如果我从内核文件中删除所有内容 - 结果是相同的。

可能是什么问题?

P.S。这个例子,我正在尝试编译,我在这里找到:http://www.thebigblob.com/getting-started-with-opencl-and-gpu-computing/#comment-2575

0 个答案:

没有答案