Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-436

NVLink Vs PCIe Transfer Time

Problem

Compare transfer times for the same payload over NVLink and PCIe: time_ms = transfer_bytes / (bandwidth_gbps * 1e6) for each link. Return [nvlink_ms, pcie_ms, pcie_ms / nvlink_ms].

The signature is nvlink_vs_pcie(transfer_bytes, nvlink_gbps, pcie_gbps).

Hint

The ratio of times is just the inverse ratio of bandwidths.

Test cases

case 1
in: [1000000000,900,32]
expected: [1.1111111111,31.25,28.125]
case 2
in: [500000000,450,16]
expected: [1.1111111111,31.25,28.125]
case 3
in: [1000000,900,32]
expected: [0.0011111111,0.03125,28.125]
case 4
in: [4000000000,900,64]
expected: [4.4444444444,62.5,14.0625]
Starter codePython
def nvlink_vs_pcie(transfer_bytes, nvlink_gbps, pcie_gbps):
    # Your code here
    pass

4 test cases · run your code against them in the editor