Skip to content

Instantly share code, notes, and snippets.

@benmanns
Created March 13, 2013 02:34
Show Gist options
  • Save benmanns/5148946 to your computer and use it in GitHub Desktop.
Save benmanns/5148946 to your computer and use it in GitHub Desktop.
An OpenCL kernel for computing the dot product of two matrices.
__kernel void matdot(__global double * outputC, int widthA, int heightA, int widthB, int heightB, __global double* inputA, __global double* inputB) {
int column = get_global_id(0);
int row = get_global_id(1);
double sum = 0.0;
for (int i = 0; i < widthA; i++) {
sum += inputA[row * widthA + i] * inputB[i * widthB + column];
}
outputC[row * widthB + column] = sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment