Matrix Multiplication

by gogoyik22·12 views·Jun 29, 2026Open in Playground →
main.cu
123456789101112
#include <cuda_runtime.h>
#define N 64

// Kernel is launched as:  matMul<<<dim3(ceil(N/16),ceil(N/16)), dim3(16,16)>>>(A, B, C)
// gridDim  = (ceil(N/16), ceil(N/16))   blockDim = (16, 16)
// Row:  int row = blockIdx.y * blockDim.y + threadIdx.y;
// Col:  int col = blockIdx.x * blockDim.x + threadIdx.x;
__global__ void matMul(const float* A, const float* B, float* C) {
    // C[row][col] = sum_k A[row][k] * B[k][col]
    // TODO: Use blockIdx.x/y and threadIdx.x/y to assign one output element per thread
    // TODO: Accumulate the dot product and write to C[row * N + col]
}

Comments (0)

to post comments and vote
No comments yet. Be the first to share your thoughts!