All problems
CUDA Graph Node Count
Problem
Count the nodes of a CUDA graph as kernels + memcpys + events, and the launch overhead saved versus eager execution as (nodes - 1) * launch_overhead_us, clamped at 0.
The signature is cuda_graph_nodes(num_kernels, num_memcpys, num_events, launch_overhead_us). Return [nodes, saved_us].
Hint
Graph capture replays many launches as a single submission, cutting CPU overhead.
Test cases
case 1
in: [10,2,0,5]
expected: [12,55]
case 2
in: [1,0,0,5]
expected: [1,0]
case 3
in: [50,10,4,2.5]
expected: [64,157.5]
case 4
in: [0,0,0,5]
expected: [0,0]
Starter codePython
def cuda_graph_nodes(num_kernels, num_memcpys, num_events, launch_overhead_us):
# Your code here
pass4 test cases · run your code against them in the editor