From df473eab0ab8a52e6b58e0f6442b39ba4c1d68ea Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 31 May 2018 18:53:52 +0100 Subject: COMPMID-1182: printf doesn't work Change-Id: I013d57f6e2becbd6d2d7700ce5fbbeca670443c4 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/133735 Tested-by: Jenkins Reviewed-by: Pablo Tello --- src/graph/GraphManager.cpp | 1 - src/graph/backends/CL/CLDeviceBackend.cpp | 15 +++++++++++---- src/graph/backends/GLES/GCDeviceBackend.cpp | 9 ++++++++- src/graph/detail/ExecutionHelpers.cpp | 8 -------- 4 files changed, 19 insertions(+), 14 deletions(-) (limited to 'src/graph') diff --git a/src/graph/GraphManager.cpp b/src/graph/GraphManager.cpp index a67e5b25d6..0ea3254faa 100644 --- a/src/graph/GraphManager.cpp +++ b/src/graph/GraphManager.cpp @@ -38,7 +38,6 @@ namespace graph GraphManager::GraphManager() : _workloads() { - detail::default_initialize_backends(); } void GraphManager::finalize_graph(Graph &graph, GraphContext &ctx, PassManager &pm, Target target) diff --git a/src/graph/backends/CL/CLDeviceBackend.cpp b/src/graph/backends/CL/CLDeviceBackend.cpp index 7f2be674f6..b235c3aa48 100644 --- a/src/graph/backends/CL/CLDeviceBackend.cpp +++ b/src/graph/backends/CL/CLDeviceBackend.cpp @@ -66,7 +66,7 @@ static detail::BackendRegistrar CLDeviceBackend_registrar(Targe static const std::string tuner_data_filename = "acl_tuner.csv"; CLDeviceBackend::CLDeviceBackend() - : _tuner(), _allocator(cl::Context::getDefault()) + : _initialized(false), _tuner(), _allocator(nullptr) { } @@ -96,11 +96,18 @@ void CLDeviceBackend::initialize_backend() CLScheduler::get().default_init(&_tuner); // Create allocator with new context - _allocator = CLBufferAllocator(); + _allocator = support::cpp14::make_unique(); } void CLDeviceBackend::setup_backend_context(GraphContext &ctx) { + // Force backend initialization + if(!_initialized) + { + initialize_backend(); + _initialized = true; + } + // Setup tuner set_kernel_tuning(ctx.config().use_tuner); @@ -124,7 +131,7 @@ bool CLDeviceBackend::is_backend_supported() IAllocator *CLDeviceBackend::backend_allocator() { - return &_allocator; + return _allocator.get(); } std::unique_ptr CLDeviceBackend::create_tensor(const Tensor &tensor) @@ -180,7 +187,7 @@ std::shared_ptr CLDeviceBackend::create_memory_mana auto pool_mgr = std::make_shared(); auto mm = std::make_shared(lifetime_mgr, pool_mgr); - mm->set_allocator(&_allocator); + mm->set_allocator(_allocator.get()); return mm; } diff --git a/src/graph/backends/GLES/GCDeviceBackend.cpp b/src/graph/backends/GLES/GCDeviceBackend.cpp index 770cca5d42..bfac31ac2e 100644 --- a/src/graph/backends/GLES/GCDeviceBackend.cpp +++ b/src/graph/backends/GLES/GCDeviceBackend.cpp @@ -53,7 +53,7 @@ namespace backends static detail::BackendRegistrar GCDeviceBackend_registrar(Target::GC); GCDeviceBackend::GCDeviceBackend() - : _allocator() + : _initialized(false), _allocator() { } @@ -65,6 +65,13 @@ void GCDeviceBackend::initialize_backend() void GCDeviceBackend::setup_backend_context(GraphContext &ctx) { + // Force backend initialization + if(!_initialized) + { + initialize_backend(); + _initialized = true; + } + // Setup a management backend if(ctx.memory_management_ctx(Target::GC) == nullptr) { diff --git a/src/graph/detail/ExecutionHelpers.cpp b/src/graph/detail/ExecutionHelpers.cpp index c370fdf916..d68092a2e7 100644 --- a/src/graph/detail/ExecutionHelpers.cpp +++ b/src/graph/detail/ExecutionHelpers.cpp @@ -35,14 +35,6 @@ namespace graph { namespace detail { -void default_initialize_backends() -{ - for(const auto &backend : backends::BackendRegistry::get().backends()) - { - backend.second->initialize_backend(); - } -} - void validate_all_nodes(Graph &g) { auto &nodes = g.nodes(); -- cgit v1.2.1