-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathchallenge.html
More file actions
31 lines (30 loc) · 1.24 KB
/
challenge.html
File metadata and controls
31 lines (30 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<p>
Implement a GPU program that computes the dot product of two vectors containing 32-bit floating point numbers.
The dot product is the sum of the products of the corresponding elements of two vectors.
</p>
<p>
Mathematically, the dot product of two vectors \(A\) and \(B\) of length \(n\) is defined as:
\[
A \cdot B = \sum_{i=0}^{n-1} A_i \cdot B_i = A_0 \cdot B_0 + A_1 \cdot B_1 + \ldots + A_{n-1} \cdot B_{n-1}
\]
</p>
<h2>Implementation Requirements</h2>
<ul>
<li>Use only GPU native features (external libraries are not permitted)</li>
<li>The <code>solve</code> function signature must remain unchanged</li>
<li>The final result must be stored in the output variable</li>
</ul>
<h2>Example 1:</h2>
<pre>Input: A = [1.0, 2.0, 3.0, 4.0]
B = [5.0, 6.0, 7.0, 8.0]
Output: result = 70.0 (1.0*5.0 + 2.0*6.0 + 3.0*7.0 + 4.0*8.0)</pre>
<h2>Example 2:</h2>
<pre>Input: A = [0.5, 1.5, 2.5]
B = [2.0, 3.0, 4.0]
Output: result = 15.5 (0.5*2.0 + 1.5*3.0 + 2.5*4.0)</pre>
<h2>Constraints</h2>
<ul>
<li><code>A</code> and <code>B</code> have identical lengths</li>
<li>1 ≤ <code>N</code> ≤ 100,000,000</li>
<li>Performance is measured with <code>N</code> = 4194304</li>
</ul>