From 3db2d0ead4d9d5e47d980a3a5194b3bd10e82d39 Mon Sep 17 00:00:00 2001 From: foreman Date: Mon, 28 Sep 2015 17:41:36 -0400 Subject: [PATCH] P4 to Git Change 1195141 by gandryey@gera-dev-w7 on 2015/09/28 15:09:34 SWDEV-77522 - Remove direct references to the Resource object - In non-VM mode Resource was used as a memory object outside of SW heap Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.cpp#119 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.hpp#39 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuconstbuf.cpp#9 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuconstbuf.hpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#528 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#153 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#298 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.hpp#117 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.hpp#49 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.cpp#38 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.hpp#14 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#208 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#60 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#228 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.hpp#84 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#383 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.hpp#135 edit [ROCm/clr commit: 4b23814a4d41ac496ed6087910ac06391a105924] --- .../clr/rocclr/runtime/device/gpu/gpublit.cpp | 20 +++++------ .../clr/rocclr/runtime/device/gpu/gpublit.hpp | 9 +++-- .../rocclr/runtime/device/gpu/gpuconstbuf.cpp | 4 +-- .../rocclr/runtime/device/gpu/gpuconstbuf.hpp | 4 +-- .../rocclr/runtime/device/gpu/gpudevice.cpp | 33 ++++++++++--------- .../rocclr/runtime/device/gpu/gpudevice.hpp | 20 +++++------ .../rocclr/runtime/device/gpu/gpukernel.cpp | 30 ++++++++--------- .../rocclr/runtime/device/gpu/gpukernel.hpp | 5 ++- .../rocclr/runtime/device/gpu/gpumemory.hpp | 1 - .../rocclr/runtime/device/gpu/gpuprintf.cpp | 2 +- .../rocclr/runtime/device/gpu/gpuprintf.hpp | 10 +++--- .../rocclr/runtime/device/gpu/gpuprogram.cpp | 2 +- .../rocclr/runtime/device/gpu/gpuprogram.hpp | 2 +- .../rocclr/runtime/device/gpu/gpuresource.cpp | 6 ++-- .../rocclr/runtime/device/gpu/gpuvirtual.cpp | 22 ++++++------- .../rocclr/runtime/device/gpu/gpuvirtual.hpp | 19 +++++------ 16 files changed, 95 insertions(+), 94 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp b/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp index ab85396b93..768022a193 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp @@ -37,9 +37,9 @@ DmaBlitManager::gpuMem(device::Memory& mem) const bool DmaBlitManager::readMemoryStaged( - Resource& srcMemory, + Memory& srcMemory, void* dstHost, - Resource** xferBuf, + Memory** xferBuf, size_t origin, size_t& offset, size_t& totalSize, @@ -196,9 +196,9 @@ DmaBlitManager::readBuffer( } if (0 != srcSize) { - Resource& xferBuf0 = dev().xferRead().acquire(); - Resource& xferBuf1 = dev().xferRead().acquire(); - Resource* xferBuf[2] = { &xferBuf0, &xferBuf1 }; + Memory& xferBuf0 = dev().xferRead().acquire(); + Memory& xferBuf1 = dev().xferRead().acquire(); + Memory* xferBuf[2] = { &xferBuf0, &xferBuf1 }; // Read memory using a staged resource if (!readMemoryStaged(gpuMem(srcMemory), dstHost, xferBuf, origin[0], @@ -231,7 +231,7 @@ DmaBlitManager::readBufferRect( srcMemory, dstHost, bufRect, hostRect, size, entire); } else { - Resource& xferBuf = dev().xferRead().acquire(); + Memory& xferBuf = dev().xferRead().acquire(); amd::Coord3D dst(0, 0, 0); size_t tmpSize = 0; @@ -304,8 +304,8 @@ DmaBlitManager::readImage( bool DmaBlitManager::writeMemoryStaged( const void* srcHost, - Resource& dstMemory, - Resource& xferBuf, + Memory& dstMemory, + Memory& xferBuf, size_t origin, size_t& offset, size_t& totalSize, @@ -433,7 +433,7 @@ DmaBlitManager::writeBuffer( } if (dstSize != 0) { - Resource& xferBuf = dev().xferWrite().acquire(); + Memory& xferBuf = dev().xferWrite().acquire(); // Write memory using a staged resource if (!writeMemoryStaged(srcHost, gpuMem(dstMemory), xferBuf, origin[0], @@ -466,7 +466,7 @@ DmaBlitManager::writeBufferRect( srcHost, dstMemory, hostRect, bufRect, size, entire); } else { - Resource& xferBuf = dev().xferWrite().acquire(); + Memory& xferBuf = dev().xferWrite().acquire(); amd::Coord3D src(0, 0, 0); size_t tmpSize = 0; diff --git a/projects/clr/rocclr/runtime/device/gpu/gpublit.hpp b/projects/clr/rocclr/runtime/device/gpu/gpublit.hpp index 5abfe0b5ad..952985f307 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpublit.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpublit.hpp @@ -20,7 +20,6 @@ namespace gpu { class Device; class Kernel; -class Resource; class Memory; class VirtualGPU; @@ -189,9 +188,9 @@ private: //! Reads video memory, using a staged buffer bool readMemoryStaged( - Resource& srcMemory, //!< Source memory object + Memory& srcMemory, //!< Source memory object void* dstHost, //!< Destination host memory - Resource** xferBuf, //!< Staged buffer for read + Memory** xferBuf, //!< Staged buffer for read size_t origin, //!< Original offset in the source memory size_t& offset, //!< Offset for the current copy pointer size_t& totalSize, //!< Total size for copy region @@ -201,8 +200,8 @@ private: //! Write into video memory, using a staged buffer bool writeMemoryStaged( const void* srcHost, //!< Source host memory - Resource& dstMemory, //!< Destination memory object - Resource& xferBuf, //!< Staged buffer for write + Memory& dstMemory, //!< Destination memory object + Memory& xferBuf, //!< Staged buffer for write size_t origin, //!< Original offset in the destination memory size_t& offset, //!< Offset for the current copy pointer size_t& totalSize, //!< Total size for the copy region diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.cpp index 7eaad64424..ccf7d1f104 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.cpp @@ -12,7 +12,7 @@ namespace gpu { ConstBuffer::ConstBuffer( VirtualGPU& gpu, size_t size) - : Resource(const_cast(gpu.dev()), size, CM_SURF_FMT_RGBA32F) + : Memory(const_cast(gpu.dev()), size * VectorSize) , gpu_(gpu) , size_(size * VectorSize) , wrtOffset_(0) @@ -42,7 +42,7 @@ ConstBuffer::create() } memset(sysMemCopy_, 0, size_); - if (!Resource::create(Resource::RemoteUSWC)) { + if (!Memory::create(Resource::RemoteUSWC)) { LogPrintfError("We couldn't create HW constant buffer, size(%d)!", size_); return false; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.hpp index 115f73f8a0..aeb129e2a2 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuconstbuf.hpp @@ -5,13 +5,13 @@ #ifndef GPUCONSTBUF_HPP_ #define GPUCONSTBUF_HPP_ -#include "device/gpu/gpuresource.hpp" +#include "device/gpu/gpumemory.hpp" //! \namespace gpu GPU Resource Implementation namespace gpu { //! Cconstant buffer -class ConstBuffer : public Resource +class ConstBuffer : public Memory { public: //! Vector size of the constant buffer diff --git a/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp b/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp index 724d350d57..c54abd6db8 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp @@ -498,8 +498,8 @@ void NullDevice::fillDeviceInfo( bool Device::Heap::create(Device& device) { - // Create a new GPU resource - resource_ = new Resource(device, 0, CM_SURF_FMT_R32I); + // Create global GPU heap + resource_ = new Memory(device, 0); if (resource_ == NULL) { return false; } @@ -569,13 +569,12 @@ Device::XferBuffers::~XferBuffers() bool Device::XferBuffers::create() { - Resource* xferBuf = NULL; + Memory* xferBuf = NULL; bool result = false; - // Note: create a 1D resource - xferBuf = new Resource(dev(), bufSize_ / Heap::ElementSize, - Heap::ElementType); + // Create a buffer object + xferBuf = new Memory(dev(), bufSize_); - // We will try to creat a CAL resource for the transfer buffer + // Try to allocate memory for the transfer buffer if ((NULL == xferBuf) || !xferBuf->create(type_)) { delete xferBuf; xferBuf = NULL; @@ -593,10 +592,10 @@ Device::XferBuffers::create() return result; } -Resource& +Memory& Device::XferBuffers::acquire() { - Resource* xferBuf = NULL; + Memory* xferBuf = NULL; size_t listSize; // Lock the operations with the staged buffer list @@ -605,11 +604,10 @@ Device::XferBuffers::acquire() // If the list is empty, then attempt to allocate a staged buffer if (listSize == 0) { - // Note: create a 1D resource - xferBuf = new Resource(dev(), bufSize_ / Heap::ElementSize, - Heap::ElementType); + // Allocate memory + xferBuf = new Memory(dev(), bufSize_); - // We will try to create a CAL resource for the transfer buffer + // Allocate memory for the transfer buffer if ((NULL == xferBuf) || !xferBuf->create(type_)) { delete xferBuf; xferBuf = NULL; @@ -634,7 +632,7 @@ Device::XferBuffers::acquire() } void -Device::XferBuffers::release(VirtualGPU& gpu, Resource& buffer) +Device::XferBuffers::release(VirtualGPU& gpu, Memory& buffer) { // Make sure buffer isn't busy on the current VirtualGPU, because // the next aquire can come from different queue @@ -1225,6 +1223,11 @@ Device::getGpuMemory(amd::Memory* mem) const return static_cast(mem->getDeviceMemory(*this)); } +const device::BlitManager& +Device::xferMgr() const +{ + return xferQueue_->blitMgr(); +} CalFormat Device::getCalFormat(const amd::Image::Format& format) const @@ -2366,7 +2369,7 @@ Device::SrdManager::freeSrdSlot(uint64_t addr) { } void -Device::SrdManager::fillResourceList(std::vector& memList) +Device::SrdManager::fillResourceList(std::vector& memList) { for (uint i = 0; i < pool_.size(); ++i) { memList.push_back(pool_[i].buf_); diff --git a/projects/clr/rocclr/runtime/device/gpu/gpudevice.hpp b/projects/clr/rocclr/runtime/device/gpu/gpudevice.hpp index d4ac52cd5a..316c5325e1 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpudevice.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpudevice.hpp @@ -199,13 +199,13 @@ public: ); //! Gets the GPU resource associated with the global heap - const Resource& resource() const { return *resource_; } + const Memory& resource() const { return *resource_; } //! Returns the base virtual address of the heap uint64_t baseAddress() const { return baseAddress_; } protected: - Resource* resource_; //!< GPU resource referencing the heap memory + Memory* resource_; //!< GPU resource referencing the heap memory uint64_t baseAddress_; //!< Virtual heap base address }; @@ -277,12 +277,12 @@ public: bool create(); //! Acquires an instance of the transfer buffers - Resource& acquire(); + Memory& acquire(); //! Releases transfer buffer void release( VirtualGPU& gpu, //!< Virual GPU object used with the buffer - Resource& buffer //!< Transfer buffer for release + Memory& buffer //!< Transfer buffer for release ); //! Returns the buffer's size for transfer @@ -300,7 +300,7 @@ public: Resource::MemoryType type_; //!< The buffer's type size_t bufSize_; //!< Staged buffer size - std::list freeBuffers_; //!< The list of free buffers + std::list freeBuffers_; //!< The list of free buffers amd::Atomic acquiredCnt_; //!< The total number of acquired buffers amd::Monitor lock_; //!< Stgaed buffer acquire/release lock const Device& gpuDevice_; //!< GPU device object @@ -358,8 +358,8 @@ public: //! Frees a SRD slot void freeSrdSlot(uint64_t addr); - // Fills the resource list for VidMM KMD - void fillResourceList(std::vector& memList); + // Fills the memory list for VidMM KMD + void fillResourceList(std::vector& memList); private: //! Disable copy constructor @@ -461,7 +461,7 @@ public: ) const; //! Gets the GPU resource associated with the global heap - const Resource& globalMem() const { return heap_.resource(); } + const Memory& globalMem() const { return heap_.resource(); } //! Gets the global heap object const Heap& heap() const { return heap_; } @@ -517,7 +517,7 @@ public: const Engines& engines() const { return engines_; } //! Returns engines object - const device::BlitManager& xferMgr() const { return xferQueue_->blitMgr(); } + const device::BlitManager& xferMgr() const; VirtualGPU* xferQueue() const { return xferQueue_; } @@ -614,7 +614,7 @@ private: amd::Monitor* vaCacheAccess_; //!< Lock to serialize VA caching access std::list* vaCacheList_; //!< VA cache list std::vector* mapCache_; //!< Map cache info structure - ResourceCache* resourceCache_; //!< CAL resource cache + ResourceCache* resourceCache_; //!< Resource cache Engines engines_; //!< Available engines on device bool heapInitComplete_; //!< Keep track of initialization status of heap resources VirtualGPU* xferQueue_; //!< Transfer queue diff --git a/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp b/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp index 8f511311e7..404df210dd 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp @@ -1464,7 +1464,7 @@ Kernel::bindConstantBuffers(VirtualGPU& gpu) const for (uint i = 0; i < numCb_; i++) { ConstBuffer* cb = gpu.constBufs_[i]; result &= cb->uploadDataToHw(cbSizes_[i]) && - bindResource(gpu, *cb, i, ConstantBuffer, i, NULL, cb->wrtOffset()); + bindResource(gpu, *cb, i, ConstantBuffer, i, cb->wrtOffset()); } return result; @@ -1595,7 +1595,7 @@ Kernel::debug(VirtualGPU& gpu) const std::cerr << "--- " << name_ << " ---" << std::endl; for (uint i = 0; i < arguments_.size(); ++i) { const KernelArg* arg = argument(i); - Memory* gpuMem = gpu.slots_[i].memory_; + const Memory* gpuMem = gpu.slots_[i].memory_; std::stringstream fileName; bool bufferObj = ((arg->type_ == KernelArg::PointerGlobal) || @@ -1625,7 +1625,8 @@ Kernel::debug(VirtualGPU& gpu) const if (((arg->type_ >= KernelArg::Image1D) && (arg->type_ <= KernelArg::Image3D)) || ((src == NULL) && bufferObj)) { - Memory* resource = gpu.slots_[i].memory_; + //@todo Replace the current map + Memory* resource = const_cast(gpu.slots_[i].memory_); void* memory = resource->map(&gpu); uint* location = reinterpret_cast(memory); std::cerr << " > " << arg->name_ << (bufferObj ? ": buffer" : ": image") << std::endl; @@ -1790,7 +1791,7 @@ Kernel::setArgument( if (arg->type_ == KernelArg::PointerHwConst) { // Bind current memory object with the kernel if (!bindResource(gpu, *gpuMem, idx, - ArgumentConstBuffer, arg->index_, gpuMem)) { + ArgumentConstBuffer, arg->index_)) { return false; } assert((offset == 0) && "No offset for HW CB"); @@ -1815,7 +1816,7 @@ Kernel::setArgument( // Bind current memory object with the kernel // Note: it's a fake binding, if the buffer is part of // the global heap - if (!bindResource(gpu, *gpuMem, idx, type, arg->index_, gpuMem)) { + if (!bindResource(gpu, *gpuMem, idx, type, arg->index_)) { return false; } @@ -1875,7 +1876,7 @@ Kernel::setArgument( // Bind current memory object with the shader. if (!bindResource(gpu, *gpuMem, idx, - resType, arg->index_, gpuMem)) { + resType, arg->index_)) { return false; } @@ -1922,7 +1923,7 @@ Kernel::setArgument( // Bind current memory object with the shader. if (!bindResource(gpu, *gpuMem, idx, - ArgumentCounter, idx, gpuMem)) { + ArgumentCounter, idx)) { return false; } } @@ -2138,11 +2139,10 @@ Kernel::setSampler( bool Kernel::bindResource( VirtualGPU& gpu, - const Resource& resource, + const Memory& memory, uint paramIdx, ResourceType type, uint physUnit, - Memory* memory, size_t offset) const { gslUAVType uavType = GSL_UAV_TYPE_UNKNOWN; @@ -2185,7 +2185,7 @@ Kernel::bindResource( } // Associate resource with the slot - gpu.slots_[paramIdx].memory_ = memory; + gpu.slots_[paramIdx].memory_ = &memory; // Mark resource as bound gpu.slots_[paramIdx].state_.bound_ = true; @@ -2195,7 +2195,7 @@ Kernel::bindResource( // Bind memory with atomic counter gpu.cs()->bindAtomicCounter(argument(paramIdx)->index_, - memory->gslResource()); + memory.gslResource()); // Copy the counter value into GDS gpu.eventBegin(MainEngine); @@ -2203,7 +2203,7 @@ Kernel::bindResource( gpu.eventEnd(MainEngine, calEvent); // Mark resource as busy - memory->setBusy(gpu, calEvent); + memory.setBusy(gpu, calEvent); return true; } else if (type == ArgumentHeapBuffer) { @@ -2229,7 +2229,7 @@ Kernel::bindResource( gslMem = dev().heap().resource().gslResource(); } else { - gslMem = resource.gslResource(); + gslMem = memory.gslResource(); } // Associate memory with the physical unit, the actual binding @@ -2257,7 +2257,7 @@ Kernel::bindResource( case ArgumentConstBuffer: if ((gpu.cal_.constBuffers_[physUnit] != gslMem) || (offset != 0)) { result = gpu.setConstantBuffer(physUnit, - gslMem, offset, resource.hbSize()); + gslMem, offset, memory.hbSize()); gpu.cal_.constBuffers_[physUnit] = gslMem; } break; @@ -3667,7 +3667,7 @@ HSAILKernel::loadArguments( bool nativeMem, uint64_t vmDefQueue, uint64_t* vmParentWrap, - std::vector& memList) const + std::vector& memList) const { static const bool WaitOnBusyEngine = true; uint64_t ldsAddress = ldsSize(); diff --git a/projects/clr/rocclr/runtime/device/gpu/gpukernel.hpp b/projects/clr/rocclr/runtime/device/gpu/gpukernel.hpp index c89b9e1589..d38721463e 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpukernel.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpukernel.hpp @@ -734,11 +734,10 @@ private: */ bool bindResource( VirtualGPU& gpu, //!< virtual GPU device object - const Resource& resource, //!< resource for binding + const Memory& memory, //!< memory for binding uint paramIdx, //!< index of the parameter ResourceType type, //!< resource type uint physUnit, //!< PhysUnit - Memory* memory = NULL, //!< GPU layer memory object size_t offset = 0 ) const; @@ -900,7 +899,7 @@ public: bool nativeMem, //!< Native memory objectes are passed uint64_t vmDefQueue, //!< GPU VM default queue pointer uint64_t* vmParentWrap, //!< GPU VM parent aql wrap object - std::vector& memList //!< Memory list for GSL/VidMM handles + std::vector& memList //!< Memory list for GSL/VidMM handles ) const; //! Returns pritnf info array diff --git a/projects/clr/rocclr/runtime/device/gpu/gpumemory.hpp b/projects/clr/rocclr/runtime/device/gpu/gpumemory.hpp index 503ca42a34..49f584c693 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpumemory.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpumemory.hpp @@ -8,7 +8,6 @@ #include "top.hpp" #include "thread/atomic.hpp" #include "device/gpu/gpuresource.hpp" -#include "device/gpu/gpudevice.hpp" #include /*! \addtogroup GPU diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp index 3cfb87bf72..2e32460290 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp @@ -21,7 +21,7 @@ PrintfDbg::PrintfDbg(Device& device, FILE* file) , dbgFile_(file) , gpuDevice_(device) , wiDbgSize_(0) - , initCntValue_(device, 1, CM_SURF_FMT_R32I) + , initCntValue_(device, 4) { } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.hpp index a329158938..9c6316d8c6 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.hpp @@ -4,6 +4,8 @@ #ifndef GPUPRINTFDBG_HPP_ #define GPUPRINTFDBG_HPP_ +#include "device/gpu/gpumemory.hpp" + /*! \addtogroup GPU GPU Device Implementation * @{ */ @@ -85,7 +87,7 @@ protected: Memory* dbgBuffer_; //!< Buffer to hold debug output FILE* dbgFile_; //!< Debug file Device& gpuDevice_; //!< GPU device object - Resource* xferBufRead_; //!< Transfer buffer for the dump read + Memory* xferBufRead_; //!< Transfer buffer for the dump read //! Gets GPU device object Device& dev() const { return gpuDevice_; } @@ -100,7 +102,7 @@ protected: const std::string& fmt //!< Format string ) const; - //! Returns TRUE if a string value has to be printed + //! Returns TRUE if a string value has to be printed bool checkString( const std::string& fmt //!< Format string ) const; @@ -154,8 +156,8 @@ private: const uint32_t* workitemData //!< The PrintfDbg dump buffer ) const; - size_t wiDbgSize_; //!< Workitem debug size - Resource initCntValue_; //!< Initialized count value + size_t wiDbgSize_; //!< Workitem debug size + Memory initCntValue_; //!< Initialized count value }; class PrintfDbgHSA : public PrintfDbg { diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp index b78e56b243..bff20bf113 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp @@ -2283,7 +2283,7 @@ HSAILProgram::allocKernelTable() void HSAILProgram::fillResListWithKernels( - std::vector& memList) const + std::vector& memList) const { for (auto& it : kernels()) { memList.push_back( diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp index 916c293b06..01b61f1489 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp @@ -520,7 +520,7 @@ public: const Memory* kernelTable() const { return kernels_; } //! Adds all kernels to the mem handle lists - void fillResListWithKernels(std::vector& memList) const; + void fillResListWithKernels(std::vector& memList) const; //! Returns the maximum number of scratch regs used in the program uint maxScratchRegs() const { return maxScratchRegs_; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp index 248812b8c1..b988ec8447 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp @@ -1201,7 +1201,7 @@ Resource::setBusy( GpuEvent gpuEvent ) const { - gpu.assignGpuEvent(this, gpuEvent); + gpu.assignGpuEvent(gslResource(), gpuEvent); // If current resource is a view, then update the parent event as well if (viewOwner_ != NULL) { @@ -1212,7 +1212,7 @@ Resource::setBusy( void Resource::wait(VirtualGPU& gpu, bool waitOnBusyEngine) const { - GpuEvent* gpuEvent = gpu.getGpuEvent(this); + GpuEvent* gpuEvent = gpu.getGpuEvent(gslResource()); // Check if we have to wait unconditionally if (!waitOnBusyEngine || @@ -1781,7 +1781,7 @@ Resource::getActiveRename(VirtualGPU& gpu, GslResourceReference** rename) bool Resource::rename(VirtualGPU& gpu, bool force) { - GpuEvent* gpuEvent = gpu.getGpuEvent(this); + GpuEvent* gpuEvent = gpu.getGpuEvent(gslResource()); if (!gpuEvent->isValid() && !force) { return true; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp index f4e9012945..f8e0b622de 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -218,7 +218,7 @@ VirtualGPU::gslDestroy() } void -VirtualGPU::addXferWrite(Resource& resource) +VirtualGPU::addXferWrite(Memory& memory) { if (xferWriteBuffers_.size() > 7) { dev().xferWrite().release(*this, *xferWriteBuffers_.front()); @@ -226,14 +226,14 @@ VirtualGPU::addXferWrite(Resource& resource) } // Delay destruction - xferWriteBuffers_.push_back(&resource); + xferWriteBuffers_.push_back(&memory); } void VirtualGPU::releaseXferWrite() { - for (auto& resource : xferWriteBuffers_) { - dev().xferWrite().release(*this, *resource); + for (auto& memory : xferWriteBuffers_) { + dev().xferWrite().release(*this, *memory); } xferWriteBuffers_.clear(); } @@ -248,7 +248,7 @@ VirtualGPU::addPinnedMem(amd::Memory* mem) } // Start operation, since we should release mem object - flushDMA(getGpuEvent(dev().getGpuMemory(mem))->engineId_); + flushDMA(getGpuEvent(dev().getGpuMemory(mem)->gslResource())->engineId_); // Delay destruction pinnedMems_.push_back(mem); @@ -560,14 +560,14 @@ bool VirtualGPU::allocHsaQueueMem() { // Allocate a dummy HSA queue - hsaQueueMem_ = new gpu::Memory(dev(), sizeof(amd_queue_t)); + hsaQueueMem_ = new Memory(dev(), sizeof(amd_queue_t)); if ((hsaQueueMem_ == NULL) || - (!hsaQueueMem_->create(gpu::Resource::Local))) { + (!hsaQueueMem_->create(Resource::Local))) { delete hsaQueueMem_; return false; } amd_queue_t* queue = reinterpret_cast - (hsaQueueMem_->map(NULL, gpu::Resource::WriteOnly)); + (hsaQueueMem_->map(NULL, Resource::WriteOnly)); if (NULL == queue) { delete hsaQueueMem_; return false; @@ -1662,7 +1662,7 @@ VirtualGPU::submitKernelInternalHSA( // Get the HSA kernel object const HSAILKernel& hsaKernel = static_cast(*(kernel.getDeviceKernel(dev()))); - std::vector memList; + std::vector memList; bool printfEnabled = (hsaKernel.printfInfo().size() > 0) ? true:false; if (!printfDbgHSA().init(*this, printfEnabled )){ @@ -3182,7 +3182,7 @@ VirtualGPU::profilingCollectResults(CommandBatch* cb, const amd::Event* waitingE } bool -VirtualGPU::addVmMemory(const Resource* resource) +VirtualGPU::addVmMemory(const Memory* memory) { uint* cnt = &cal_.memCount_; (*cnt)++; @@ -3198,7 +3198,7 @@ VirtualGPU::addVmMemory(const Resource* resource) vmMems_ = tmp; numVmMems_ = *cnt; } - vmMems_[*cnt - 1] = resource->gslResource(); + vmMems_[*cnt - 1] = memory->gslResource(); return true; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.hpp index e844830c9e..818d9d9d6b 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.hpp @@ -24,7 +24,6 @@ namespace gpu { class Device; class Kernel; -class Resource; class Memory; class CalCounterReference; class VirtualGPU; @@ -110,8 +109,8 @@ public: State(): value_(0) {} }; - State state_; //!< slot's state - Memory* memory_; //!< GPU memory object + State state_; //!< slot's state + const Memory* memory_; //!< GPU memory object ResourceSlot(): memory_(NULL) {} @@ -262,14 +261,14 @@ public: //! Returns a GPU event, associated with GPU memory GpuEvent* getGpuEvent( - const Resource* resource //!< GPU resource object - ) { return &gpuEvents_[resource->gslResource()]; } + const gslMemObject gslMem //!< GSL mem object + ) { return &gpuEvents_[gslMem]; } //! Assigns a GPU event, associated with GPU memory void assignGpuEvent( - const Resource* resource, //!< GPU resource object + const gslMemObject gslMem, //!< GSL mem object GpuEvent gpuEvent - ) { gpuEvents_[resource->gslResource()] = gpuEvent; } + ) { gpuEvents_[gslMem] = gpuEvent; } //! Set the kernel as active bool setActiveKernelDesc( @@ -324,11 +323,11 @@ public: //! Adds a memory handle into the GSL memory array for Virtual Heap bool addVmMemory( - const Resource* resource //!< GPU resource object + const Memory* memory //!< GPU memory object ); //! Adds a stage write buffer into a list - void addXferWrite(Resource& resource); + void addXferWrite(Memory& memory); //! Adds a pinned memory object into a map void addPinnedMem(amd::Memory* mem); @@ -523,7 +522,7 @@ private: DmaFlushMgmt dmaFlushMgmt_; //!< DMA flush management - std::list xferWriteBuffers_; //!< Stage write buffers + std::list xferWriteBuffers_; //!< Stage write buffers std::list pinnedMems_;//!< Pinned memory list typedef std::list CommandBatchList;