All problems
Async Copy Pipeline Stages
Problem
Choose the number of pipeline stages that fit in shared memory: stages = min(max_stages, smem_bytes // stage_bytes), clamped to at least 1.
The signature is pipeline_stages(smem_bytes, stage_bytes, max_stages). Return an integer.
Hint
Double buffering uses two stages; deeper pipelines hide more latency at the cost of shared memory.
Test cases
case 1
in: [100000,16384,4]
expected: 4
case 2
in: [32768,16384,4]
expected: 2
case 3
in: [8192,16384,4]
expected: 1
case 4
in: [65536,8192,8]
expected: 8
Starter codePython
def pipeline_stages(smem_bytes, stage_bytes, max_stages):
# Your code here
pass4 test cases · run your code against them in the editor