P4 to Git Change 1317211 by gandryey@gera-w8 on 2016/09/21 16:53:02
SWDEV-102971 - [CQE OCL][OpenCL on PAL] "computer on low memory" issue observed folllowed by tdr while running few WF Conformance tests together - Use custom memory allocator to avoid memory grow in PAL - Extra clean-ups in resource alloc, including a fix for image pitch in the persistent memory Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#11 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#22 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#9 edit
This commit is contained in:
@@ -190,10 +190,10 @@ bool Memory::processGLResource(GLResourceOP operation)
|
||||
switch (operation)
|
||||
{
|
||||
case GLDecompressResource:
|
||||
retVal = gslGLAcquire();
|
||||
retVal = glAcquire();
|
||||
break;
|
||||
case GLInvalidateFBO:
|
||||
retVal = gslGLRelease();
|
||||
retVal = glRelease();
|
||||
break;
|
||||
default:
|
||||
assert(false && "unknown GLResourceOP");
|
||||
|
||||
@@ -946,7 +946,6 @@ Resource::create(MemoryType memType, CreateParams* params)
|
||||
|
||||
pinAddress = tmpHost;
|
||||
|
||||
// Align width to avoid GSL useless assert with a view
|
||||
if (hostMemOffset != 0) {
|
||||
allocSize += hostMemOffset;
|
||||
}
|
||||
@@ -1045,8 +1044,8 @@ Resource::free()
|
||||
}
|
||||
|
||||
// Add resource to the cache
|
||||
if (wait && !dev().resourceCache().addGpuMemory(&desc_, memRef_)) {
|
||||
gslFree();
|
||||
if (!dev().resourceCache().addGpuMemory(&desc_, memRef_)) {
|
||||
palFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1064,7 +1063,7 @@ Resource::free()
|
||||
dev().vgpus()[idx]->releaseMemory(iMem());
|
||||
}
|
||||
}
|
||||
gslFree();
|
||||
palFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1072,10 +1071,10 @@ Resource::free()
|
||||
else {
|
||||
if (renames_.size() == 0) {
|
||||
// Destroy GSL resource
|
||||
if (wait && (iMem() != 0)) {
|
||||
if (iMem() != 0) {
|
||||
// Release virtual memory object on the specified virtual GPU
|
||||
gpu_->releaseMemory(iMem(), wait);
|
||||
gslFree();
|
||||
palFree();
|
||||
}
|
||||
}
|
||||
else for (size_t i = 0; i < renames_.size(); ++i) {
|
||||
@@ -1084,7 +1083,7 @@ Resource::free()
|
||||
if (iMem() != 0) {
|
||||
// Release virtual memory object on the specified virtual GPUs
|
||||
gpu_->releaseMemory(iMem());
|
||||
gslFree();
|
||||
palFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1496,7 +1495,13 @@ Resource::gpuMemoryMap(size_t* pitch, uint flags, Pal::IGpuMemory* resource) con
|
||||
else {
|
||||
amd::ScopedLock lk(dev().lockPAL());
|
||||
void* address;
|
||||
*pitch = desc().width_ * elementSize();
|
||||
if (image_ != nullptr) {
|
||||
constexpr Pal::SubresId ImgSubresId = { Pal::ImageAspect::Color, 0, 0 };
|
||||
Pal::SubresLayout layout;
|
||||
image_->GetSubresourceLayout(ImgSubresId, &layout);
|
||||
*pitch = layout.rowPitch / elementSize();
|
||||
}
|
||||
*pitch = desc().width_;
|
||||
if (Pal::Result::Success == resource->Map(&address)) {
|
||||
return address;
|
||||
}
|
||||
@@ -1524,7 +1529,7 @@ Resource::gpuMemoryUnmap(Pal::IGpuMemory* resource) const
|
||||
}
|
||||
|
||||
bool
|
||||
Resource::gslGLAcquire()
|
||||
Resource::glAcquire()
|
||||
{
|
||||
bool retVal = true;
|
||||
if (desc().type_ == OGLInterop) {
|
||||
@@ -1534,7 +1539,7 @@ Resource::gslGLAcquire()
|
||||
}
|
||||
|
||||
bool
|
||||
Resource::gslGLRelease()
|
||||
Resource::glRelease()
|
||||
{
|
||||
bool retVal = true;
|
||||
if (desc().type_ == OGLInterop) {
|
||||
@@ -1543,7 +1548,7 @@ Resource::gslGLRelease()
|
||||
return retVal;
|
||||
}
|
||||
void
|
||||
Resource::gslFree() const
|
||||
Resource::palFree() const
|
||||
{
|
||||
amd::ScopedLock lk(dev().lockPAL());
|
||||
|
||||
|
||||
@@ -174,10 +174,10 @@ public:
|
||||
union {
|
||||
struct {
|
||||
uint dimSize_ : 2; //!< Dimension size
|
||||
uint cardMemory_ : 1; //!< GSL resource is in video memory
|
||||
uint imageArray_ : 1; //!< GSL resource is an array of images
|
||||
uint buffer_ : 1; //!< GSL resource is a buffer
|
||||
uint tiled_ : 1; //!< GSL resource is tiled
|
||||
uint cardMemory_ : 1; //!< PAL resource is in video memory
|
||||
uint imageArray_ : 1; //!< PAL resource is an array of images
|
||||
uint buffer_ : 1; //!< PAL resource is a buffer
|
||||
uint tiled_ : 1; //!< PAL resource is tiled
|
||||
uint SVMRes_ : 1; //!< SVM flag to the cal resource
|
||||
uint scratch_ : 1; //!< Scratch buffer
|
||||
uint isAllocExecute_ : 1; //!< SVM resource allocation attribute for shader\cmdbuf
|
||||
@@ -351,8 +351,8 @@ public:
|
||||
bool isCacheable() const
|
||||
{ return (isMemoryType(Remote) || isMemoryType(Pinned)) ? true : false; }
|
||||
|
||||
bool gslGLAcquire() ;
|
||||
bool gslGLRelease() ;
|
||||
bool glAcquire() ;
|
||||
bool glRelease() ;
|
||||
|
||||
//! Returns HW state for the resource (used for images only)
|
||||
const void* hwState() const { return hwState_; }
|
||||
@@ -407,20 +407,20 @@ private:
|
||||
VirtualGPU* gpu //!< Virtual GPU device object
|
||||
);
|
||||
|
||||
//! Calls GSL to map a resource
|
||||
//! Calls PAL to map a resource
|
||||
void* gpuMemoryMap(
|
||||
size_t* pitch, //!< Pitch value for the image
|
||||
uint flags, //!< Map flags
|
||||
Pal::IGpuMemory* resource //!< GSL memory object
|
||||
Pal::IGpuMemory* resource //!< PAL memory object
|
||||
) const;
|
||||
|
||||
//! Uses GSL to unmap a resource
|
||||
//! Uses PAL to unmap a resource
|
||||
void gpuMemoryUnmap(
|
||||
Pal::IGpuMemory* resource //!< GSL memory object
|
||||
Pal::IGpuMemory* resource //!< PAL memory object
|
||||
) const;
|
||||
|
||||
//! Fress all GSL resources associated with OCL resource
|
||||
void gslFree() const;
|
||||
//! Fress all PAL resources associated with OCL resource
|
||||
void palFree() const;
|
||||
|
||||
//! Converts Resource memory type to the PAL heaps
|
||||
void memTypeToHeap(
|
||||
@@ -434,7 +434,7 @@ private:
|
||||
size_t offset_; //!< Resource offset
|
||||
size_t curRename_; //!< Current active rename in the list
|
||||
RenameList renames_; //!< Rename resource list
|
||||
GpuMemoryReference* memRef_; //!< GSL resource reference
|
||||
GpuMemoryReference* memRef_; //!< PAL resource reference
|
||||
const Resource* viewOwner_; //!< GPU resource, which owns this view
|
||||
uint64_t pinOffset_; //!< Pinned memory offset
|
||||
void* glInteropMbRes_;//!< Mb Res handle
|
||||
|
||||
@@ -251,6 +251,7 @@ VirtualGPU::Queue::flush()
|
||||
}
|
||||
// Start command buffer building
|
||||
Pal::CmdBufferBuildInfo cmdBuildInfo = {};
|
||||
cmdBuildInfo.pMemAllocator = &vlAlloc_;
|
||||
if (Pal::Result::Success != iCmdBuffs_[cmdBufIdSlot_]->Begin(cmdBuildInfo)) {
|
||||
LogError("PAL failed CB building initialization!");
|
||||
return false;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "palCmdBuffer.h"
|
||||
#include "palCmdAllocator.h"
|
||||
#include "palQueue.h"
|
||||
#include "palLinearAllocator.h"
|
||||
|
||||
/*! \addtogroup PAL PAL Resource Implementation
|
||||
* @{
|
||||
@@ -53,14 +54,15 @@ public:
|
||||
|
||||
Queue(Pal::IDevice* palDev)
|
||||
: iDev_(palDev), iQueue_(NULL),
|
||||
cmdBufIdSlot_(StartCmdBufIdx), cmdBufIdCurrent_(StartCmdBufIdx),
|
||||
cmbBufIdRetired_(0), cmdCnt_(0)
|
||||
{
|
||||
for (uint i = 0; i < MaxCmdBuffers; ++i) {
|
||||
iCmdBuffs_[i] = NULL;
|
||||
iCmdFences_[i] = NULL;
|
||||
}
|
||||
cmdBufIdSlot_(StartCmdBufIdx), cmdBufIdCurrent_(StartCmdBufIdx),
|
||||
cmbBufIdRetired_(0), cmdCnt_(0), vlAlloc_(64 * Ki)
|
||||
{
|
||||
for (uint i = 0; i < MaxCmdBuffers; ++i) {
|
||||
iCmdBuffs_[i] = NULL;
|
||||
iCmdFences_[i] = NULL;
|
||||
}
|
||||
vlAlloc_.Init();
|
||||
}
|
||||
|
||||
~Queue();
|
||||
|
||||
@@ -102,6 +104,7 @@ public:
|
||||
uint cmbBufIdRetired_; //!< The last retired command buffer ID
|
||||
uint cmdCnt_; //!< Counter of commands
|
||||
std::map<Pal::IGpuMemory*, uint> memReferences_;
|
||||
Util::VirtualLinearAllocator vlAlloc_;
|
||||
};
|
||||
|
||||
struct CommandBatch : public amd::HeapObject
|
||||
|
||||
Reference in New Issue
Block a user