diff options
author | Pablo Tello <pablo.tello@arm.com> | 2019-09-24 11:03:47 +0100 |
---|---|---|
committer | Pablo Marquez <pablo.tello@arm.com> | 2019-10-15 14:05:55 +0000 |
commit | db8485ac24135f17e9882c76196924435abc064f (patch) | |
tree | dfe4ff6a50012ac93c6b1cf3fb29c099a7592522 /src/runtime/CL/CLMemoryRegion.cpp | |
parent | a046e164b96a8441b2fa14ef578f7db46a0e97da (diff) | |
download | ComputeLibrary-db8485ac24135f17e9882c76196924435abc064f.tar.gz |
COMPMID-2205: CL runtime context.
CL Interfaces implemented.
Concrete classes implemented.
One test (ActivationLayer) ported to the new interface.
Change-Id: I283808bec36ccfc2f13fe048c45cbbee698ce525
Signed-off-by: Pablo Tello <pablo.tello@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1998
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL/CLMemoryRegion.cpp')
-rw-r--r-- | src/runtime/CL/CLMemoryRegion.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/runtime/CL/CLMemoryRegion.cpp b/src/runtime/CL/CLMemoryRegion.cpp index 2976903c93..52906a893f 100644 --- a/src/runtime/CL/CLMemoryRegion.cpp +++ b/src/runtime/CL/CLMemoryRegion.cpp @@ -23,13 +23,18 @@ */ #include "arm_compute/runtime/CL/CLMemoryRegion.h" +#include "arm_compute/core/CL/CLCoreRuntimeContext.h" #include "arm_compute/core/Error.h" #include "arm_compute/runtime/CL/CLScheduler.h" namespace arm_compute { -ICLMemoryRegion::ICLMemoryRegion(cl::Context ctx, size_t size) - : IMemoryRegion(size), _ctx(std::move(ctx)), _mapping(nullptr), _mem() +ICLMemoryRegion::ICLMemoryRegion(CLCoreRuntimeContext *ctx, size_t size) + : IMemoryRegion(size), + _queue((ctx != nullptr) ? ctx->queue() : CLScheduler::get().queue()), + _ctx((ctx != nullptr) ? ctx->context() : CLScheduler::get().context()), + _mapping(nullptr), + _mem() { } @@ -54,17 +59,17 @@ std::unique_ptr<IMemoryRegion> ICLMemoryRegion::extract_subregion(size_t offset, return nullptr; } -CLBufferMemoryRegion::CLBufferMemoryRegion(cl::Context ctx, cl_mem_flags flags, size_t size) - : ICLMemoryRegion(std::move(ctx), size) +CLBufferMemoryRegion::CLBufferMemoryRegion(CLCoreRuntimeContext *ctx, cl_mem_flags flags, size_t size) + : ICLMemoryRegion(ctx, size) { if(_size != 0) { - _mem = cl::Buffer(_ctx, flags, _size); + _mem = cl::Buffer((ctx != nullptr) ? ctx->context() : CLScheduler::get().context(), flags, _size); } } -CLBufferMemoryRegion::CLBufferMemoryRegion(const cl::Buffer &buffer) - : ICLMemoryRegion(buffer.getInfo<CL_MEM_CONTEXT>(), buffer.getInfo<CL_MEM_SIZE>()) +CLBufferMemoryRegion::CLBufferMemoryRegion(const cl::Buffer &buffer, CLCoreRuntimeContext *ctx) + : ICLMemoryRegion(ctx, buffer.getInfo<CL_MEM_SIZE>()) { _mem = buffer; } @@ -88,15 +93,15 @@ void CLBufferMemoryRegion::unmap(cl::CommandQueue &q) _mapping = nullptr; } -ICLSVMMemoryRegion::ICLSVMMemoryRegion(cl::Context ctx, cl_mem_flags flags, size_t size, size_t alignment) - : ICLMemoryRegion(std::move(ctx), size), _ptr(nullptr) +ICLSVMMemoryRegion::ICLSVMMemoryRegion(CLCoreRuntimeContext *ctx, cl_mem_flags flags, size_t size, size_t alignment) + : ICLMemoryRegion(ctx, size), _ptr(nullptr) { if(size != 0) { - _ptr = clSVMAlloc(_ctx.get(), flags, size, alignment); + _ptr = clSVMAlloc((ctx != nullptr) ? ctx->context().get() : CLScheduler::get().context().get(), flags, size, alignment); if(_ptr != nullptr) { - _mem = cl::Buffer(_ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, _size, _ptr); + _mem = cl::Buffer((ctx != nullptr) ? ctx->context() : CLScheduler::get().context(), CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, _size, _ptr); } } } @@ -107,7 +112,7 @@ ICLSVMMemoryRegion::~ICLSVMMemoryRegion() { try { - clFinish(CLScheduler::get().queue().get()); + clFinish(_queue.get()); _mem = cl::Buffer(); clSVMFree(_ctx.get(), _ptr); } @@ -122,8 +127,8 @@ void *ICLSVMMemoryRegion::ptr() return _ptr; } -CLCoarseSVMMemoryRegion::CLCoarseSVMMemoryRegion(cl::Context ctx, cl_mem_flags flags, size_t size, size_t alignment) - : ICLSVMMemoryRegion(std::move(ctx), flags, size, alignment) +CLCoarseSVMMemoryRegion::CLCoarseSVMMemoryRegion(CLCoreRuntimeContext *ctx, cl_mem_flags flags, size_t size, size_t alignment) + : ICLSVMMemoryRegion(ctx, flags, size, alignment) { } @@ -142,8 +147,8 @@ void CLCoarseSVMMemoryRegion::unmap(cl::CommandQueue &q) _mapping = nullptr; } -CLFineSVMMemoryRegion::CLFineSVMMemoryRegion(cl::Context ctx, cl_mem_flags flags, size_t size, size_t alignment) - : ICLSVMMemoryRegion(std::move(ctx), flags, size, alignment) +CLFineSVMMemoryRegion::CLFineSVMMemoryRegion(CLCoreRuntimeContext *ctx, cl_mem_flags flags, size_t size, size_t alignment) + : ICLSVMMemoryRegion(ctx, flags, size, alignment) { } @@ -162,4 +167,4 @@ void CLFineSVMMemoryRegion::unmap(cl::CommandQueue &q) ARM_COMPUTE_UNUSED(q); _mapping = nullptr; } -} // namespace arm_compute
\ No newline at end of file +} // namespace arm_compute |