Repository navigation
Conversation
The sorts of the TPC merger, which CUDA and HIP run with thrust, run on a single GPU thread on the other backends. A backend whose memory is shared with the host can sort there instead, with the CPU code of the kernels, once its stream is drained. The new parameter UNIFIED_MEM_SORT_ON_HOST selects this for the sorts of the merged tracks, of the looper candidates, of the O2 output and of the border ranges, through the new kernel device type HostOnDeviceMemory. It differs from CPU, whose kernels work on the host processors and their host memory: these kernels run on a copy of the device processors, which points at the host view of the device memory (mDeviceMemoryHostView, set by the backend if that is at another address), with the host's parameters and calibration objects. Pointer arguments are moved to the host view as well. The parameter is 0 for all backends.
On a single GPU thread, the sorts of the merged tracks by quality and by q/pT, of the looper candidates and of the O2 output tracks took about 730 ms per event on a 30-collision Pb-Pb time frame, at up to 140 times the CPU's time, and the 360 border-range sorts per time frame another 312 ms. The GPU memory is shared with the host, so sort there with UNIFIED_MEM_SORT_ON_HOST, which also orders the elements that compare equal as on the CPU.
The candidate search of the border track merging, 180 launches per time frame of a few thousand tracks each, took 46 ms per event (kernels serialized) on a 30-collision Pb-Pb time frame on the GPU, where each thread first walks the sorted ranges from the start. On the host, right after the range sorts which already drained the stream, it takes 4.6 ms, including pointing the processors at the host view of the shared memory for each launch. One host thread, so that the merging across the central electrode stays as on the CPU. Benchmark, 6 interleaved rounds of 10 events: -6 +- 2 ms per event. It runs as the sorts with UNIFIED_MEM_SORT_ON_HOST do: the CPU code, on the device processors in the memory shared with the host.
|
@davidrohr our understanding of your comments. Notice the accounting for CPU running in what is considered (shared) device memory. |
davidrohr
left a comment
There was a problem hiding this comment.
This looks quite good and is pretty much what I had in mind. There is one issue with converting const ptr to non-const, that should be fixed. And 2 minor comments:
| GPUReconstructionCPU::runKernelVirtual(num, args); | ||
| } | ||
|
|
||
| void* GPUReconstructionCPU::HostPointer(const void* ptr) const |
There was a problem hiding this comment.
I do not like that this converts a const ptr to a non-const ptr. If you need only 1 version, input and output should have the same constness. Otherwise, please provide 2 overloads.
There was a problem hiding this comment.
I suspect it's the usual address-space-part-of-the-type issue. I'll let you know.
| RecordMarker(_xyz.z.ev, _xyz.x.stream); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Just out of curiosity, why can't you use the HostOnDeviceMemory for this like for all the sorting?
There was a problem hiding this comment.
No particular reason, just historical of how the patch came to be.
The candidate search of the border track merging, 180 launches per time
frame of a few thousand tracks each, took 46 ms per event (kernels
serialized) on a 30-collision Pb-Pb time frame on the GPU, where each
thread first walks the sorted ranges from the start. On the host, right
after the range sorts which already drained the stream, it takes 4.6 ms,
including pointing the processors at the host view of the shared memory
for each launch. One host thread, so that the merging across the central
electrode stays as on the CPU. Benchmark, 6 interleaved rounds of 10
events: -6 +- 2 ms per event.
It runs as the sorts with UNIFIED_MEM_SORT_ON_HOST do: the CPU code, on
the device processors in the memory shared with the host.