2
0

SWDEV-363074 - Enable resource cache for SVM

Blender creates and destroys big allocations during the benchmark.
That causes big delays, because vidmm has to page-in/page-out memory.

Change-Id: I2baf4545807127406e3d2870a7581ff9ae7bcdb5
Este cometimento está contido em:
German
2022-10-27 16:39:05 -04:00
ascendente cff74ae551
cometimento dc4ad8c99c
2 ficheiros modificados com 12 adições e 7 eliminações
+11 -7
Ver ficheiro
@@ -1230,6 +1230,7 @@ bool Resource::create(MemoryType memType, CreateParams* params, bool forceLinear
svmPtr = reinterpret_cast<Pal::gpusize>(params->owner_->getSvmPtr());
desc_.SVMRes_ = true;
svmPtr = (svmPtr == 1) ? 0 : svmPtr;
desc_.reserved_va_ = (svmPtr == 1) ? false : true;
if (params->owner_->getMemFlags() & CL_MEM_SVM_ATOMICS) {
desc_.gl2CacheDisabled_ = true;
}
@@ -1424,7 +1425,8 @@ bool Resource::partialMemCopyTo(VirtualGPU& gpu, const amd::Coord3D& srcOrigin,
}
}
if (dev().settings().disableSdma_) {
bool cp_dma = dev().settings().disableSdma_;
if (cp_dma) {
// Make sure compute is done before CP DMA start
gpu.addBarrier(RgpSqqtBarrierReason::MemDependency);
} else {
@@ -1517,7 +1519,7 @@ bool Resource::partialMemCopyTo(VirtualGPU& gpu, const amd::Coord3D& srcOrigin,
copyRegion.dstOffset = dstOrigin[0] + dstResource.offset();
copyRegion.copySize = size[0];
constexpr size_t CpCopySizeLimit = (1 << 26) - sizeof(uint64_t);
if (dev().settings().disableSdma_ && (size[0] > CpCopySizeLimit)) {
if (cp_dma && (size[0] > CpCopySizeLimit)) {
size_t orgSize = size[0];
copyRegion.copySize = CpCopySizeLimit;
do {
@@ -1535,7 +1537,7 @@ bool Resource::partialMemCopyTo(VirtualGPU& gpu, const amd::Coord3D& srcOrigin,
}
}
if (dev().settings().disableSdma_) {
if (cp_dma) {
// Make sure CP dma is done
gpu.addBarrier(RgpSqqtBarrierReason::MemDependency);
}
@@ -2146,7 +2148,7 @@ bool ResourceCache::addGpuMemory(Resource::Descriptor* desc, GpuMemoryReference*
// Make sure current allocation isn't bigger than cache
if (((desc->type_ == Resource::Local) || (desc->type_ == Resource::Persistent) ||
(desc->type_ == Resource::Remote) || (desc->type_ == Resource::RemoteUSWC)) &&
(size < cacheSizeLimit_) && !desc->SVMRes_) {
(size < cacheSizeLimit_ && !(desc->SVMRes_ && desc->reserved_va_))) {
// Validate the cache size limit. Loop until we have enough space
while ((cacheSize_ + size) > cacheSizeLimit_) {
removeLast();
@@ -2197,8 +2199,8 @@ GpuMemoryReference* ResourceCache::findGpuMemory(Resource::Descriptor* desc, Pal
return ref;
}
// Early exit if resource is too big
if (size >= cacheSizeLimit_ || desc->SVMRes_) {
// Early exit if resource is too big or it's SVM allocation with a reserved VA
if (size >= cacheSizeLimit_ || (desc->SVMRes_ && desc->reserved_va_)) {
//! \note we may need to free the cache here to reduce memory pressure
return ref;
}
@@ -2210,7 +2212,9 @@ GpuMemoryReference* ResourceCache::findGpuMemory(Resource::Descriptor* desc, Pal
// Find if we can reuse this entry
if ((entry->type_ == desc->type_) && (entry->flags_ == desc->flags_) && (size <= sizeRes) &&
(size > (sizeRes >> 1)) && ((it.second->iMem()->Desc().gpuVirtAddr % alignment) == 0) &&
(entry->isAllocExecute_ == desc->isAllocExecute_)) {
(entry->isAllocExecute_ == desc->isAllocExecute_) &&
(entry->SVMRes_ == desc->SVMRes_) &&
(entry->gl2CacheDisabled_ == desc->gl2CacheDisabled_)) {
ref = it.second;
cacheSize_ -= sizeRes;
if (entry->type_ == Resource::Local) {
+1
Ver ficheiro
@@ -209,6 +209,7 @@ class Resource : public amd::HeapObject {
uint isAllocExecute_ : 1; //!< SVM resource allocation attribute for shader\cmdbuf
uint isDoppTexture_ : 1; //!< PAL resource is for a DOPP desktop texture
uint gl2CacheDisabled_ : 1;//!< PAL resource is allocated with GPU L2 cache disabled.
uint reserved_va_ : 1; //!< PAL resource was allocated for a reserved VA
};
uint state_;
};