From db8485ac24135f17e9882c76196924435abc064f Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Tue, 24 Sep 2019 11:03:47 +0100 Subject: 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 Reviewed-on: https://review.mlplatform.org/c/1998 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- src/runtime/CL/CLBufferAllocator.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/runtime/CL/CLBufferAllocator.cpp') diff --git a/src/runtime/CL/CLBufferAllocator.cpp b/src/runtime/CL/CLBufferAllocator.cpp index 84789e70d2..ed27320650 100644 --- a/src/runtime/CL/CLBufferAllocator.cpp +++ b/src/runtime/CL/CLBufferAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -22,25 +22,35 @@ * SOFTWARE. */ #include "arm_compute/runtime/CL/CLBufferAllocator.h" -#include "arm_compute/runtime/CL/CLMemoryRegion.h" +#include "arm_compute/core/CL/CLCoreRuntimeContext.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/Error.h" +#include "arm_compute/runtime/CL/CLMemoryRegion.h" +#include "arm_compute/runtime/CL/CLScheduler.h" #include "support/ToolchainSupport.h" #include -using namespace arm_compute; - -CLBufferAllocator::CLBufferAllocator(cl::Context context) - : _context(std::move(context)) +namespace arm_compute +{ +CLBufferAllocator::CLBufferAllocator(CLCoreRuntimeContext *ctx) + : _ctx(ctx) { } void *CLBufferAllocator::allocate(size_t size, size_t alignment) { ARM_COMPUTE_UNUSED(alignment); - cl_mem buf = clCreateBuffer(_context.get(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size, nullptr, nullptr); + cl_mem buf; + if(_ctx == nullptr) + { + buf = clCreateBuffer(CLScheduler::get().context().get(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size, nullptr, nullptr); + } + else + { + buf = clCreateBuffer(_ctx->context().get(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size, nullptr, nullptr); + } return static_cast(buf); } @@ -53,5 +63,6 @@ void CLBufferAllocator::free(void *ptr) std::unique_ptr CLBufferAllocator::make_region(size_t size, size_t alignment) { ARM_COMPUTE_UNUSED(alignment); - return arm_compute::support::cpp14::make_unique(_context, CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size); + return arm_compute::support::cpp14::make_unique(_ctx, CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size); } +} // namespace arm_compute -- cgit v1.2.1