From b139d3ab1fc77b2c88fab26a928ccbb2a43b1a83 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 5 Apr 2018 17:51:37 -0400
Subject: [PATCH] P4 to Git Change 1537347 by gandryey@gera-w8 on 2018/04/05
17:42:56
SWDEV-79445 - OCL generic changes and code clean-up
- Remove obsolete code in the interop logic
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#81 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.hpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#86 edit
---
rocclr/runtime/device/pal/paldevice.cpp | 4 +-
rocclr/runtime/device/pal/palmemory.cpp | 54 ++++++++----------------
rocclr/runtime/device/pal/palmemory.hpp | 26 +-----------
rocclr/runtime/device/pal/palvirtual.cpp | 37 ----------------
4 files changed, 20 insertions(+), 101 deletions(-)
diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp
index d4cad620ad..edd90ef480 100644
--- a/rocclr/runtime/device/pal/paldevice.cpp
+++ b/rocclr/runtime/device/pal/paldevice.cpp
@@ -1309,7 +1309,7 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
// Check if owner is interop memory
if (owner.isInterop()) {
- result = gpuMemory->createInterop(Memory::InteropDirectAccess);
+ result = gpuMemory->createInterop();
} else if (owner.getMemFlags() & CL_MEM_USE_PERSISTENT_MEM_AMD) {
// Attempt to allocate from persistent heap
result = gpuMemory->create(Resource::Persistent);
@@ -1454,7 +1454,7 @@ pal::Memory* Device::createImage(amd::Memory& owner, bool directAccess) const {
// Check if owner is interop memory
if (owner.isInterop()) {
- result = gpuImage->createInterop(Memory::InteropDirectAccess);
+ result = gpuImage->createInterop();
} else if (imageBuffer) {
Resource::ImageBufferParams params;
pal::Memory* buffer = reinterpret_cast(image.parent()->getDeviceMemory(*this));
diff --git a/rocclr/runtime/device/pal/palmemory.cpp b/rocclr/runtime/device/pal/palmemory.cpp
index b498d5c9e3..48dc958813 100644
--- a/rocclr/runtime/device/pal/palmemory.cpp
+++ b/rocclr/runtime/device/pal/palmemory.cpp
@@ -23,22 +23,26 @@
namespace pal {
Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t size)
- : device::Memory(owner), Resource(gpuDev, size) {
- init();
+ : device::Memory(owner), Resource(gpuDev, size)
+ , pinnedMemory_(nullptr)
+ , parent_(nullptr) {
if (owner.parent() != nullptr) {
flags_ |= SubMemoryObject;
}
}
-Memory::Memory(const Device& gpuDev, size_t size) : device::Memory(size), Resource(gpuDev, size) {
- init();
+Memory::Memory(const Device& gpuDev, size_t size)
+ : device::Memory(size), Resource(gpuDev, size)
+ , pinnedMemory_(nullptr)
+ , parent_(nullptr) {
}
Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t width, size_t height, size_t depth,
cl_image_format format, cl_mem_object_type imageType, uint mipLevels)
- : device::Memory(owner), Resource(gpuDev, width, height, depth, format, imageType, mipLevels) {
- init();
+ : device::Memory(owner), Resource(gpuDev, width, height, depth, format, imageType, mipLevels)
+ , pinnedMemory_(nullptr)
+ , parent_(nullptr) {
if (owner.parent() != nullptr) {
flags_ |= SubMemoryObject;
@@ -47,16 +51,9 @@ Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t width, size_t he
Memory::Memory(const Device& gpuDev, size_t size, size_t width, size_t height, size_t depth,
cl_image_format format, cl_mem_object_type imageType, uint mipLevels)
- : device::Memory(size), Resource(gpuDev, width, height, depth, format, imageType, mipLevels) {
- init();
-}
-
-void Memory::init() {
- indirectMapCount_ = 0;
- interopType_ = InteropNone;
- interopMemory_ = nullptr;
- pinnedMemory_ = nullptr;
- parent_ = nullptr;
+ : device::Memory(size), Resource(gpuDev, width, height, depth, format, imageType, mipLevels)
+ , pinnedMemory_(nullptr)
+ , parent_(nullptr) {
}
#ifdef _WIN32
@@ -194,7 +191,7 @@ bool Memory::processGLResource(GLResourceOP operation) {
return retVal;
}
-bool Memory::createInterop(InteropType type) {
+bool Memory::createInterop() {
Resource::MemoryType memType = Resource::Empty;
Resource::OGLInteropParams oglRes;
#ifdef _WIN32
@@ -374,26 +371,11 @@ bool Memory::createInterop(InteropType type) {
return false;
}
- // Get the interop settings
- if (type == InteropDirectAccess) {
- // Create memory object
- if (!create(memType, createParams)) {
- return false;
- }
- } else {
- // Allocate Resource object for interop as buffer
- interopMemory_ = new Memory(dev(), size());
-
- // Create the interop object in CAL
- if (nullptr == interopMemory_ || !interopMemory_->create(memType, createParams)) {
- delete interopMemory_;
- interopMemory_ = nullptr;
- return false;
- }
+ // Create memory object
+ if (!create(memType, createParams)) {
+ return false;
}
- setInteropType(type);
-
return true;
}
@@ -401,8 +383,6 @@ Memory::~Memory() {
// Clean VA cache
dev().removeVACache(this);
- delete interopMemory_;
-
// Release associated map target, if any
if (nullptr != mapMemory_) {
mapMemory()->unmap(nullptr);
diff --git a/rocclr/runtime/device/pal/palmemory.hpp b/rocclr/runtime/device/pal/palmemory.hpp
index bbe713caf8..bb22f907df 100644
--- a/rocclr/runtime/device/pal/palmemory.hpp
+++ b/rocclr/runtime/device/pal/palmemory.hpp
@@ -28,12 +28,6 @@ class VirtualGPU;
// Wrapper that can contain a heap block or an interop buffer/image.
class Memory : public device::Memory, public Resource {
public:
- enum InteropType {
- InteropNone = 0, //!< None interop memory
- InteropHwEmulation = 1, //!< Uses HW emulaiton with calMemCopy
- InteropDirectAccess = 2 //!< Uses direct access to the interop surface
- };
-
//! Constructor (with owner)
Memory(const Device& gpuDev, //!< GPU device object
amd::Memory& owner, //!< Abstraction layer memory object
@@ -71,8 +65,7 @@ class Memory : public device::Memory, public Resource {
~Memory();
//! Creates the interop memory
- bool createInterop(InteropType type //!< The interop type
- );
+ bool createInterop();
//! Overloads the resource create method
virtual bool create(Resource::MemoryType memType, //!< Memory type
@@ -133,18 +126,6 @@ class Memory : public device::Memory, public Resource {
//! Accessors for indirect map memory object
Memory* mapMemory() const;
- //! Returns the interop memory for this memory object
- Memory* interop() const { return interopMemory_; }
-
- //! Gets interop type for this memory object
- InteropType interopType() const { return interopType_; }
-
- //! Sets interop type for this memory object
- void setInteropType(InteropType type) { interopType_ = type; }
-
- //! Set the owner
- void setOwner(amd::Memory* owner) { owner_ = owner; }
-
// Decompress GL depth-stencil/MSAA resources for CL access
// Invalidates any FBOs the resource may be bound to, otherwise the GL driver may crash.
virtual bool processGLResource(GLResourceOP operation);
@@ -165,9 +146,6 @@ class Memory : public device::Memory, public Resource {
//! Decrement map count
void decIndMapCount();
- //! Initialize the object members
- void init();
-
private:
//! Disable copy constructor
Memory(const Memory&);
@@ -175,8 +153,6 @@ class Memory : public device::Memory, public Resource {
//! Disable operator=
Memory& operator=(const Memory&);
- InteropType interopType_; //!< Interop type
- Memory* interopMemory_; //!< interop memory
Memory* pinnedMemory_; //!< Memory used as pinned system memory
const Memory* parent_; //!< Parent memory object
};
diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp
index 31358c6aed..4d07346f49 100644
--- a/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/rocclr/runtime/device/pal/palvirtual.cpp
@@ -2489,25 +2489,6 @@ void VirtualGPU::submitAcquireExtObjects(amd::AcquireExtObjectsCommand& vcmd) {
// If resource is a shared copy of original resource, then
// runtime needs to copy data from original resource
it->getInteropObj()->copyOrigToShared();
-
- // Check if OpenCL has direct access to the interop memory
- if (memory->interopType() == Memory::InteropDirectAccess) {
- continue;
- }
-
- // Does interop use HW emulation?
- if (memory->interopType() == Memory::InteropHwEmulation) {
- static const bool Entire = true;
- amd::Coord3D origin(0, 0, 0);
- amd::Coord3D region(memory->size());
-
- // Synchronize the object
- if (!blitMgr().copyBuffer(*memory->interop(), *memory, origin, origin, region, Entire)) {
- LogError("submitAcquireExtObjects - Interop synchronization failed!");
- vcmd.setStatus(CL_INVALID_OPERATION);
- return;
- }
- }
}
profilingEnd(vcmd);
@@ -2524,24 +2505,6 @@ void VirtualGPU::submitReleaseExtObjects(amd::ReleaseExtObjectsCommand& vcmd) {
assert(it && "Memory object for interop is nullptr");
pal::Memory* memory = dev().getGpuMemory(it);
- // Check if we can use HW interop
- if (memory->interopType() == Memory::InteropHwEmulation) {
- static const bool Entire = true;
- amd::Coord3D origin(0, 0, 0);
- amd::Coord3D region(memory->size());
-
- // Synchronize the object
- if (!blitMgr().copyBuffer(*memory, *memory->interop(), origin, origin, region, Entire)) {
- LogError("submitReleaseExtObjects interop synchronization failed!");
- vcmd.setStatus(CL_INVALID_OPERATION);
- return;
- }
- } else {
- if (memory->interopType() != Memory::InteropDirectAccess) {
- LogError("None interop release!");
- }
- }
-
// If resource is a shared copy of original resource, then
// runtime needs to copy data back to original resource
it->getInteropObj()->copySharedToOrig();