P4 to Git Change 1552704 by gandryey@gera-w8 on 2018/05/09 15:11:23
SWDEV-79445 - OCL generic changes and code clean-up
- Following CL#1552596. Make sure virtual GPU is set for the internal allocations before the create() call, since the deferred alloc is disabled.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.cpp#128 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#416 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.hpp#144 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.cpp#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#96 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#51 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.cpp#21 edit
[ROCm/clr commit: c11b2d52b7]
This commit is contained in:
@@ -693,7 +693,8 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
|
||||
// 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_ != NULL) && !constantBuffer_->create(NULL)) {
|
||||
constantBuffer_->release();
|
||||
constantBuffer_ = NULL;
|
||||
@@ -702,15 +703,13 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the constant buffer to the current virtual GPU
|
||||
constantBuffer_->setVirtualDevice(&gpu());
|
||||
|
||||
if (dev().settings().xferBufSize_ > 0) {
|
||||
xferBufferSize_ = dev().settings().xferBufSize_;
|
||||
for (uint i = 0; i < MaxXferBuffers; ++i) {
|
||||
// Create internal xfer buffers for image copy optimization
|
||||
xferBuffers_[i] = new (*context_) amd::Buffer(*context_, 0, xferBufferSize_);
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
if ((xferBuffers_[i] != NULL) && !xferBuffers_[i]->create(NULL)) {
|
||||
xferBuffers_[i]->release();
|
||||
xferBuffers_[i] = NULL;
|
||||
@@ -719,8 +718,6 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
//! @note Workaround for conformance allocation test.
|
||||
//! Force GPU mem alloc.
|
||||
//! Unaligned images require xfer optimization,
|
||||
@@ -2355,6 +2352,7 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
}
|
||||
|
||||
amdMemory = new (*context_) amd::Buffer(*context_, CL_MEM_USE_HOST_PTR, pinAllocSize);
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
if ((amdMemory != NULL) && !amdMemory->create(tmpHost, SysMem)) {
|
||||
amdMemory->release();
|
||||
return NULL;
|
||||
@@ -2362,7 +2360,6 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
|
||||
// Get device memory for this virtual device
|
||||
// @note: This will force real memory pinning
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
Memory* srcMemory = dev().getGpuMemory(amdMemory);
|
||||
|
||||
if (srcMemory == NULL) {
|
||||
|
||||
@@ -626,7 +626,6 @@ void VirtualGPU::submitReadMemory(amd::ReadMemoryCommand& vcmd) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_READ_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -724,7 +723,6 @@ void VirtualGPU::submitWriteMemory(amd::WriteMemoryCommand& vcmd) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_WRITE_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -816,7 +814,6 @@ bool VirtualGPU::copyMemory(cl_command_type type, amd::Memory& srcMem, amd::Memo
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_COPY_BUFFER;
|
||||
bufferFromImageSrc->setVirtualDevice(this);
|
||||
srcMemory = dev().getGpuMemory(bufferFromImageSrc);
|
||||
}
|
||||
}
|
||||
@@ -827,7 +824,6 @@ bool VirtualGPU::copyMemory(cl_command_type type, amd::Memory& srcMem, amd::Memo
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_COPY_BUFFER;
|
||||
bufferFromImageDst->setVirtualDevice(this);
|
||||
dstMemory = dev().getGpuMemory(bufferFromImageDst);
|
||||
}
|
||||
}
|
||||
@@ -1034,7 +1030,6 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) {
|
||||
if (NULL == bufferFromImage) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memoryBuf = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
if (!blitMgr().copyBuffer(*memoryBuf, *memory->mapMemory(), origin, dstOrigin, size,
|
||||
@@ -1134,7 +1129,6 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
|
||||
if (NULL == bufferFromImage) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memoryBuf = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
if (!blitMgr().copyBuffer(*memory->mapMemory(), *memoryBuf, srcOrigin, origin, size,
|
||||
@@ -1191,7 +1185,6 @@ bool VirtualGPU::fillMemory(cl_command_type type, amd::Memory* amdMemory, const
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_FILL_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -3054,9 +3047,9 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
|
||||
return true;
|
||||
}
|
||||
|
||||
amd::Memory* VirtualGPU::createBufferFromImage(amd::Memory& amdImage) const {
|
||||
amd::Memory* VirtualGPU::createBufferFromImage(amd::Memory& amdImage) {
|
||||
amd::Memory* mem = new (amdImage.getContext()) amd::Buffer(amdImage, 0, 0, amdImage.getSize());
|
||||
|
||||
mem->setVirtualDevice(this);
|
||||
if ((mem != NULL) && !mem->create()) {
|
||||
mem->release();
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ class VirtualGPU : public device::VirtualDevice, public CALGSLContext {
|
||||
//! Creates buffer object from image
|
||||
amd::Memory* createBufferFromImage(
|
||||
amd::Memory& amdImage //! The parent image object(untiled images only)
|
||||
) const;
|
||||
);
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<CALimage, GslKernelDesc*> GslKernels;
|
||||
|
||||
@@ -695,6 +695,9 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
// Create internal xfer buffers for image copy optimization
|
||||
xferBuffers_[i] = new (*context_) amd::Buffer(*context_, 0, xferBufferSize_);
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
|
||||
if ((xferBuffers_[i] != NULL) && !xferBuffers_[i]->create(NULL)) {
|
||||
xferBuffers_[i]->release();
|
||||
xferBuffers_[i] = NULL;
|
||||
@@ -703,8 +706,6 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
//! @note Workaround for conformance allocation test.
|
||||
//! Force GPU mem alloc.
|
||||
//! Unaligned images require xfer optimization,
|
||||
@@ -2375,7 +2376,7 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
}
|
||||
|
||||
amdMemory = new (*context_) amd::Buffer(*context_, CL_MEM_USE_HOST_PTR, pinAllocSize);
|
||||
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
if ((amdMemory != NULL) && !amdMemory->create(tmpHost, SysMem)) {
|
||||
amdMemory->release();
|
||||
return NULL;
|
||||
@@ -2383,7 +2384,6 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
|
||||
// Get device memory for this virtual device
|
||||
// @note: This will force real memory pinning
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
Memory* srcMemory = dev().getGpuMemory(amdMemory);
|
||||
|
||||
if (srcMemory == NULL) {
|
||||
|
||||
@@ -1015,7 +1015,6 @@ void VirtualGPU::submitReadMemory(amd::ReadMemoryCommand& vcmd) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_READ_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1112,6 @@ void VirtualGPU::submitWriteMemory(amd::WriteMemoryCommand& vcmd) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_WRITE_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -1205,7 +1203,6 @@ bool VirtualGPU::copyMemory(cl_command_type type, amd::Memory& srcMem, amd::Memo
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_COPY_BUFFER;
|
||||
bufferFromImageSrc->setVirtualDevice(this);
|
||||
srcMemory = dev().getGpuMemory(bufferFromImageSrc);
|
||||
}
|
||||
}
|
||||
@@ -1216,7 +1213,6 @@ bool VirtualGPU::copyMemory(cl_command_type type, amd::Memory& srcMem, amd::Memo
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_COPY_BUFFER;
|
||||
bufferFromImageDst->setVirtualDevice(this);
|
||||
dstMemory = dev().getGpuMemory(bufferFromImageDst);
|
||||
}
|
||||
}
|
||||
@@ -1423,7 +1419,6 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) {
|
||||
if (nullptr == bufferFromImage) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memoryBuf = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
if (!blitMgr().copyBuffer(*memoryBuf, *memory->mapMemory(), origin, dstOrigin, size,
|
||||
@@ -1526,7 +1521,6 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
|
||||
if (nullptr == bufferFromImage) {
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memoryBuf = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
if (!blitMgr().copyBuffer(*memory->mapMemory(), *memoryBuf, srcOrigin, origin, size,
|
||||
@@ -1586,7 +1580,6 @@ bool VirtualGPU::fillMemory(cl_command_type type, amd::Memory* amdMemory, const
|
||||
LogError("We should not fail buffer creation from image_buffer!");
|
||||
} else {
|
||||
type = CL_COMMAND_FILL_BUFFER;
|
||||
bufferFromImage->setVirtualDevice(this);
|
||||
memory = dev().getGpuMemory(bufferFromImage);
|
||||
}
|
||||
}
|
||||
@@ -3038,9 +3031,9 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
|
||||
return true;
|
||||
}
|
||||
|
||||
amd::Memory* VirtualGPU::createBufferFromImage(amd::Memory& amdImage) const {
|
||||
amd::Memory* VirtualGPU::createBufferFromImage(amd::Memory& amdImage) {
|
||||
amd::Memory* mem = new (amdImage.getContext()) amd::Buffer(amdImage, 0, 0, amdImage.getSize());
|
||||
|
||||
mem->setVirtualDevice(this);
|
||||
if ((mem != nullptr) && !mem->create()) {
|
||||
mem->release();
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ class VirtualGPU : public device::VirtualDevice {
|
||||
//! Creates buffer object from image
|
||||
amd::Memory* createBufferFromImage(
|
||||
amd::Memory& amdImage //! The parent image object(untiled images only)
|
||||
) const;
|
||||
);
|
||||
|
||||
private:
|
||||
struct MemoryRange {
|
||||
|
||||
@@ -720,7 +720,8 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
|
||||
// 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;
|
||||
@@ -729,15 +730,15 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the constant buffer to the current virtual GPU
|
||||
constantBuffer_->setVirtualDevice(&gpu());
|
||||
|
||||
if (dev().settings().xferBufSize_ > 0) {
|
||||
xferBufferSize_ = dev().settings().xferBufSize_;
|
||||
for (uint i = 0; i < MaxXferBuffers; ++i) {
|
||||
// Create internal xfer buffers for image copy optimization
|
||||
xferBuffers_[i] = new (*context_) amd::Buffer(*context_, 0, xferBufferSize_);
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
|
||||
if ((xferBuffers_[i] != nullptr) && !xferBuffers_[i]->create(nullptr)) {
|
||||
xferBuffers_[i]->release();
|
||||
xferBuffers_[i] = nullptr;
|
||||
@@ -746,8 +747,6 @@ bool KernelBlitManager::createProgram(Device& device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the xfer buffer to the current virtual GPU
|
||||
xferBuffers_[i]->setVirtualDevice(&gpu());
|
||||
//! @note Workaround for conformance allocation test.
|
||||
//! Force GPU mem alloc.
|
||||
//! Unaligned images require xfer optimization,
|
||||
@@ -2051,7 +2050,7 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
}
|
||||
|
||||
amdMemory = new (*context_) amd::Buffer(*context_, CL_MEM_USE_HOST_PTR, pinAllocSize);
|
||||
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
if ((amdMemory != nullptr) && !amdMemory->create(tmpHost, SysMem)) {
|
||||
amdMemory->release();
|
||||
return nullptr;
|
||||
@@ -2059,7 +2058,6 @@ amd::Memory* DmaBlitManager::pinHostMemory(const void* hostMem, size_t pinSize,
|
||||
|
||||
// Get device memory for this virtual device
|
||||
// @note: This will force real memory pinning
|
||||
amdMemory->setVirtualDevice(&gpu());
|
||||
Memory* srcMemory = dev().getRocMemory(amdMemory);
|
||||
|
||||
if (srcMemory == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user