From: miha-q <> Date: Sun, 3 Mar 2024 03:35:12 +0000 (-0500) Subject: Sat Mar 2 10:35:12 PM EST 2024 X-Git-Url: http://www.foleosoft.com/?a=commitdiff_plain;h=0f7f1e98c00f1231d8f452c34bcd4c65fedd102c;p=QAnsel.git Sat Mar 2 10:35:12 PM EST 2024 --- 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