(pinned: bool, streamed: bool)
| 153 | |
| 154 | # The function we want to profile |
| 155 | def inner(pinned: bool, streamed: bool): |
| 156 | with torch.cuda.stream(s) if streamed else contextlib.nullcontext(): |
| 157 | if pinned: |
| 158 | t1_cuda = t1_cpu_pinned.to(device, non_blocking=True) |
| 159 | else: |
| 160 | t2_cuda = t2_cpu_paged.to(device, non_blocking=True) |
| 161 | t_star_cuda_h2d_event = s.record_event() |
| 162 | # This operation can be executed during the CPU to GPU copy if and only if the tensor is pinned and the copy is |
| 163 | # done in the other stream |
| 164 | t3_cuda_mul = t3_cuda * t3_cuda * t3_cuda |
| 165 | t3_cuda_h2d_event = torch.cuda.current_stream().record_event() |
| 166 | t_star_cuda_h2d_event.synchronize() |
| 167 | t3_cuda_h2d_event.synchronize() |
| 168 | |
| 169 | |
| 170 | # Our profiler: profiles the `inner` function and stores the results in a .json file |
no outgoing calls
no test coverage detected