我是 Open-cl 的新手,我正在尝试为以下矩阵运算编写内核代码:
A is a 2X2 matrix:
A = [1 2] ----> row1
[3 4] ----->row2
I need to compute:
1) s1 = transpose(row1) X row1
2) s1 = transpose(row2) X row2
3) Sum = s1+s2
我为行级编写了内核代码(即我可以做 transpose(row1) X row1 ) - 这仅用于第一行
如何使用并行性计算每一行并在内核函数中找到最终总和?
private static String programSource1 =
"__kernel"+
" void matrixMul(__global float* A, __global float* C, int rowLength)"+
"{"+
"int row = get_global_id(1);"+
"int col = get_global_id(0);"+
"C[row*rowLength+col] = A[col] * A[row];"+
"}";