Implement a GPU program that multiplies a sparse matrix A of dimensions M × N
by a dense matrix B of dimensions N × K, producing a dense output matrix
C of dimensions M × K.
All matrices are stored in row-major order using 32-bit floats.
The matrix A is approximately 60–70% sparse (i.e., 60–70% of elements are zero),
and nnz gives the number of non-zero elements in A.
Mathematically, the operation is defined as: \[ C_{ij} = \sum_{k=0}^{N-1} A_{ik} \cdot B_{kj} \quad \text{for} \quad i = 0, \ldots, M-1,\; j = 0, \ldots, K-1 \]
solve function signature must remain unchangedC
Input:
Matrix \(A\) (\(3 \times 4\)):
\[
\begin{bmatrix}
2.0 & 0.0 & 0.0 & 1.0 \\
0.0 & 3.0 & 0.0 & 0.0 \\
0.0 & 0.0 & 4.0 & 0.0
\end{bmatrix}
\]
Matrix \(B\) (\(4 \times 2\)):
\[
\begin{bmatrix}
1.0 & 2.0 \\
3.0 & 4.0 \\
5.0 & 6.0 \\
7.0 & 8.0
\end{bmatrix}
\]
Output:
Matrix \(C\) (\(3 \times 2\)):
\[
\begin{bmatrix}
9.0 & 12.0 \\
9.0 & 12.0 \\
20.0 & 24.0
\end{bmatrix}
\]
M, N, K ≤ 8,192A and B are 32-bit floats in the range [−10, 10]A is approximately 60–70% sparseM = 4,096, N = 2,048, K = 512