Skip to content

Commit

Permalink
Refs EA31337#738. Matrix multiplication via OpenCL. Ready for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed May 1, 2024
1 parent dce2921 commit ad24e5b
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 98 deletions.
29 changes: 10 additions & 19 deletions Matrix.matmul.naive.cl
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
#pragma OPENCL EXTENSION cl_khr_fp64 : enable

__kernel void matmul(
__global double* A,
__global double* B,
__global double* C,
int rowsA,
int colsA,
int colsB
)
{
int row = get_global_id(0);
int col = get_global_id(1);

double sum = 0.0;

for(int k = 0; k < colsA; ++k) {
sum += A[row * colsA + k] * B[k * colsB + col];
//sum += col;
__kernel void matmul(__global double* A, __global double* B, __global double* C, int rowsA, int colsA, int colsB) {
int i = get_global_id(0);
int j = get_global_id(1);

if (i < rowsA && j < colsB) {
float sum = 0.0f;
for (int k = 0; k < colsA; ++k) {
sum += A[i * colsA + k] * B[k * colsB + j];
}
C[i * colsB + j] = sum;
}

C[row * colsB + col] = sum;
}
Loading

0 comments on commit ad24e5b

Please sign in to comment.