preprocessing: page-lock the reader's bytes for an uncompressed image
PinInputBuffer() page-locks the buffer an image is decompressed into, which an uncompressed image never uses: it is read straight out of the reader's own buffer, so the upload came from pageable memory. Measured on this card, 72.6 MB crosses at 5.6 GB/s pageable and 14.6 GB/s registered - 12.9 ms against 5.0 ms, on every image of a sweep that stores its frames uncompressed. PinInputRegion() page-locks a region the caller owns and remembers it, so a worker that reads every frame into the same buffer registers it once. The registration is dropped with the engine, so the three workers that build one declare their raw image before it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -338,6 +338,25 @@ float ImagePreprocessorGPU::GetLastDecompressionTime_s() const {
|
||||
return bslz4_decoder ? bslz4_decoder->GetDecodeTime_s() : 0.0f;
|
||||
}
|
||||
|
||||
ImagePreprocessorGPU::~ImagePreprocessorGPU() {
|
||||
// Unchecked, as everywhere else in this teardown path: a destructor is noexcept and the region
|
||||
// may already be gone with the device.
|
||||
if (pinned_input)
|
||||
cudaHostUnregister(const_cast<void *>(pinned_input));
|
||||
}
|
||||
|
||||
void ImagePreprocessorGPU::PinInputRegion(const void *ptr, size_t bytes) {
|
||||
if (ptr == pinned_input && bytes == pinned_input_bytes)
|
||||
return;
|
||||
if (pinned_input)
|
||||
cuda_err(cudaHostUnregister(const_cast<void *>(pinned_input)));
|
||||
pinned_input = nullptr;
|
||||
pinned_input_bytes = 0;
|
||||
cuda_err(cudaHostRegister(const_cast<void *>(ptr), bytes, cudaHostRegisterDefault));
|
||||
pinned_input = ptr;
|
||||
pinned_input_bytes = bytes;
|
||||
}
|
||||
|
||||
void ImagePreprocessorGPU::PinInputBuffer(std::vector<uint8_t> &buffer, size_t size) {
|
||||
if (buffer.size() == size)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user