SWDEV-260345 - Manage constant buffer for blit

- Leverage managed buffer that would use chunks for fill pattern. Use a
different chunk for the next fill to avoid wait

Change-Id: I254483c867e112f66564ffd8f55e0a605d8896c9
Bu işleme şunda yer alıyor:
Saleel Kudchadker
2022-07-11 16:16:07 -07:00
ebeveyn 46b9430a4e
işleme 175ad024d3
3 değiştirilmiş dosya ile 29 ekleme ve 65 silme
+7 -39
Dosyayı Görüntüle
@@ -774,8 +774,6 @@ bool DmaBlitManager::hsaCopyStaged(const_address hostSrc, address hostDst, size_
KernelBlitManager::KernelBlitManager(VirtualGPU& gpu, Setup setup)
: DmaBlitManager(gpu, setup),
program_(nullptr),
constantBuffer_(nullptr),
constantBufferOffset_(0),
xferBufferSize_(0),
lockXferOps_("Transfer Ops Lock", true) {
for (uint i = 0; i < BlitTotal; ++i) {
@@ -799,10 +797,6 @@ KernelBlitManager::~KernelBlitManager() {
// Release a dummy context
context_->release();
}
if (nullptr != constantBuffer_) {
constantBuffer_->release();
}
}
bool KernelBlitManager::create(amd::Device& device) {
@@ -854,18 +848,6 @@ bool KernelBlitManager::createProgram(Device& device) {
result = true;
} while (!result);
// Create an internal constant buffer
constantBuffer_ = new (*context_) amd::Buffer(*context_, CL_MEM_ALLOC_HOST_PTR, 4 * Ki);
// Assign the constant buffer to the current virtual GPU
constantBuffer_->setVirtualDevice(&gpu());
if ((constantBuffer_ != nullptr) && !constantBuffer_->create(nullptr)) {
constantBuffer_->release();
constantBuffer_ = nullptr;
return false;
} else if (constantBuffer_ == nullptr) {
return false;
}
return result;
}
@@ -2030,14 +2012,7 @@ bool KernelBlitManager::fillBuffer1D(device::Memory& memory, const void* pattern
setArgument(kernels_[fillType], 3, sizeof(cl_mem), nullptr);
}
Memory* gpuCB = dev().getRocMemory(constantBuffer_);
if (gpuCB == nullptr) {
return false;
}
// Find offset in the current constant buffer to allow multipel fills
uint32_t constBufOffset = ConstantBufferOffset();
auto constBuf = reinterpret_cast<address>(constantBuffer_->getHostMem()) + constBufOffset;
auto constBuf = gpu().allocKernArg(kCBSize, kCBAlignment);
// If pattern has been expanded, use the expanded pattern, otherwise use the default pattern.
if (packed_obj.pattern_expanded_) {
@@ -2045,9 +2020,8 @@ bool KernelBlitManager::fillBuffer1D(device::Memory& memory, const void* pattern
} else {
memcpy(constBuf, pattern, kpattern_size32);
}
mem = as_cl<amd::Memory>(gpuCB->owner());
setArgument(kernels_[fillType], 4, sizeof(cl_mem), &mem, constBufOffset);
constexpr bool kDirectVa = true;
setArgument(kernels_[fillType], 4, sizeof(cl_mem), constBuf, 0, nullptr, kDirectVa);
koffset /= alignment;
kpattern_size32 /= alignment;
@@ -2127,18 +2101,12 @@ bool KernelBlitManager::fillBuffer2D(device::Memory& memory, const void* pattern
setArgument(kernels_[fillType], 3, sizeof(cl_mem), nullptr);
}
Memory* gpuCB = dev().getRocMemory(constantBuffer_);
if (gpuCB == nullptr) {
return false;
}
// Find offset in the current constant buffer to allow multipel fills
uint32_t constBufOffset = ConstantBufferOffset();
auto constBuf = reinterpret_cast<address>(constantBuffer_->getHostMem()) + constBufOffset;
// Get constant buffer to allow multipel fills
auto constBuf = gpu().allocKernArg(kCBSize, kCBAlignment);
memcpy(constBuf, pattern, patternSize);
mem = as_cl<amd::Memory>(gpuCB->owner());
setArgument(kernels_[fillType], 4, sizeof(cl_mem), &mem, constBufOffset);
constexpr bool kDirectVa = true;
setArgument(kernels_[fillType], 4, sizeof(cl_mem), constBuf, 0, nullptr, kDirectVa);
uint64_t mem_origin = static_cast<uint64_t>(origin[0]);
uint64_t width = static_cast<uint64_t>(size[0]);