From 0f7f1e98c00f1231d8f452c34bcd4c65fedd102c Mon Sep 17 00:00:00 2001 From: miha-q <> Date: Sat, 2 Mar 2024 22:35:12 -0500 Subject: [PATCH] Sat Mar 2 10:35:12 PM EST 2024 --- src/gpu.c | 4 ++-- src/gpu_mmul.cl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gpu.c b/src/gpu.c index bc06d62..b5e2ef0 100644 --- a/src/gpu.c +++ b/src/gpu.c @@ -69,7 +69,7 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, size_t rowsA, size_t colsB, //Create buffers size_t sizeA = rowsA * shared; size_t sizeB = shared * colsB; - size_t sizeR = shared * shared; + size_t sizeR = rowsA * colsB; cl_int err; cl_mem memA = clCreateBuffer(GPU_context, CL_MEM_READ_ONLY, sizeof(float) * sizeA, NULL, &err); if (err != CL_SUCCESS) @@ -171,7 +171,7 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, size_t rowsA, size_t colsB, exit(1); } //Run the program - size_t work_size[] = {shared, shared}; + size_t work_size[] = {rowsA, colsB}; err = clEnqueueNDRangeKernel(GPU_command_queue, kernel, 2, NULL, work_size, NULL, 0, NULL, NULL); if (err != CL_SUCCESS) { diff --git a/src/gpu_mmul.cl b/src/gpu_mmul.cl index 13c5301..1f8e4f8 100644 --- a/src/gpu_mmul.cl +++ b/src/gpu_mmul.cl @@ -13,9 +13,9 @@ __kernel void gpu_mmul int row = get_global_id(0); int col = get_global_id(1); float sum = 0; - for (int i = 0; i < shared; i++) + for (int i = 0; i < rowsA; i++) { sum += ptrA[row * colsA + i] * ptrB[i * colsB + col]; } - ptrR[row * shared + col] = sum; + ptrR[row * colsB + col] = sum; } \ No newline at end of file -- 2.39.5