Matrix Multiplication
2026/3/9小于 1 分钟
Matrix Multiplication
题面
Write a program that multiplies two matrices of 32-bit floating point numbers on a GPU. Given matrix
𝐴
of dimensions
𝑀
×
𝑁
and matrix
𝐵
of dimensions
𝑁
×
𝐾
, compute the product matrix
𝐶
𝐴
×
𝐵
, which will have dimensions
𝑀
×
𝐾
. All matrices are stored in row-major format.
Implementation Requirements
- Use only native features (external libraries are not permitted)
- The solve function signature must remain unchanged
- The final result must be stored in matrix C
Examples
Example 1:
Input:
Matrix
𝐴
(
2
×
2
):
[
1.0
2.0
3.0
4.0
]
Matrix
𝐵
(
2
×
2
):
[
5.0
6.0
7.0
8.0
]
Output:
Matrix
𝐶
(
2
×
2
):
[
19.0
22.0
43.0
50.0
]Example 2:
Input:
Matrix
𝐴
(
1
×
3
):
[
1.0
2.0
3.0
]
Matrix
𝐵
(
3
×
1
):
[
4.0
5.0
6.0
]
Output:
Matrix
𝐶
(
1
×
1
):
[
32.0
]Constraints
- 1 ≤ M, N, K ≤ 8192
- Performance is measured with M = 8192, N = 6144, K = 4096