Vector Addition
2026/3/9小于 1 分钟
Vector Addition
题面
Write a GPU program that performs element-wise addition of two vectors containing 32-bit floating point numbers. The program should take two input vectors of equal length and produce a single output vector containing their sum.
Implementation Requirements
- External libraries are not permitted
- The
solvefunction signature must remain unchanged - The final result must be stored in vector
C
Examples
Example 1:
Input: A = [1.0, 2.0, 3.0, 4.0]
B = [5.0, 6.0, 7.0, 8.0]
Output: C = [6.0, 8.0, 10.0, 12.0]Example 2:
Input: A = [1.5, 1.5, 1.5]
B = [2.3, 2.3, 2.3]
Output: C = [3.8, 3.8, 3.8]Constraints
- Input vectors
AandBhave identical lengths - 1 ≤
N≤ 100,000,000 - Performance is measured with
N= 25,000,000