diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-11-14 13:16:56 +0000 |
---|---|---|
committer | Isabella Gottardi <isabella.gottardi@arm.com> | 2018-11-21 09:52:04 +0000 |
commit | df3103622b7de05f4e35b22a2c94b4a46eab4efc (patch) | |
tree | 17e10253e7a069c69d10bea0882b699b99d74b86 /src/runtime/CL/CLMemory.cpp | |
parent | c47ef20d69e8ea0f519fdc679435cd7037fc18fe (diff) | |
download | ComputeLibrary-df3103622b7de05f4e35b22a2c94b4a46eab4efc.tar.gz |
COMPMID-1088: Use IMemoryRegion in interfaces where possible
-Simplifies import memory interface
-Changes the used of void** handles with appropriate interfaces.
Change-Id: I5918c855c11f46352058864623336b352162a4b7
Diffstat (limited to 'src/runtime/CL/CLMemory.cpp')
-rw-r--r-- | src/runtime/CL/CLMemory.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/runtime/CL/CLMemory.cpp b/src/runtime/CL/CLMemory.cpp index bbc513d783..5bea85cfae 100644 --- a/src/runtime/CL/CLMemory.cpp +++ b/src/runtime/CL/CLMemory.cpp @@ -24,23 +24,20 @@ #include "arm_compute/runtime/CL/CLMemory.h" #include "arm_compute/core/Error.h" +#include "arm_compute/core/utils/misc/Cast.h" namespace arm_compute { CLMemory::CLMemory() : _region(nullptr), _region_owned(nullptr) { - create_empty_region(); } CLMemory::CLMemory(std::shared_ptr<ICLMemoryRegion> memory) : _region(nullptr), _region_owned(std::move(memory)) { - if(_region_owned == nullptr) - { - create_empty_region(); - } - _region = _region_owned.get(); + _region_owned = memory; + _region = _region_owned.get(); } CLMemory::CLMemory(ICLMemoryRegion *memory) @@ -49,19 +46,36 @@ CLMemory::CLMemory(ICLMemoryRegion *memory) _region = memory; } -ICLMemoryRegion *CLMemory::region() +ICLMemoryRegion *CLMemory::cl_region() +{ + return _region; +} + +ICLMemoryRegion *CLMemory::cl_region() const +{ + return _region; +} + +IMemoryRegion *CLMemory::region() { return _region; } -ICLMemoryRegion *CLMemory::region() const +IMemoryRegion *CLMemory::region() const { return _region; } -void CLMemory::create_empty_region() +void CLMemory::set_region(IMemoryRegion *region) +{ + auto cl_region = utils::cast::polymorphic_downcast<ICLMemoryRegion *>(region); + _region_owned = nullptr; + _region = cl_region; +} + +void CLMemory::set_owned_region(std::unique_ptr<IMemoryRegion> region) { - _region_owned = std::make_shared<CLBufferMemoryRegion>(cl::Context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, 0); + _region_owned = utils::cast::polymorphic_downcast_unique_ptr<ICLMemoryRegion>(std::move(region)); _region = _region_owned.get(); } } // namespace arm_compute
\ No newline at end of file |