From d828b46667459bdf93d409f5a1bc3afc19c81baf Mon Sep 17 00:00:00 2001 From: Mirko leonardo Serra laban Date: Thu, 19 Nov 2020 16:22:59 +0000 Subject: Fix segfault at validate_cl_gemm Fixes segfault when exiting the program. Change-Id: I20757f700842e6c1de9112d2915d539513434c6d Signed-off-by: Mirko leonardo Serra laban Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4484 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Georgios Pinitas --- tests/validate_examples/RunExample.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/validate_examples') diff --git a/tests/validate_examples/RunExample.cpp b/tests/validate_examples/RunExample.cpp index b6ff8832dd..aca4ddcc7c 100644 --- a/tests/validate_examples/RunExample.cpp +++ b/tests/validate_examples/RunExample.cpp @@ -28,6 +28,7 @@ #include "ValidateExample.h" #include "arm_compute/runtime/Scheduler.h" +#include "arm_compute/runtime/CL/CLHelpers.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/framework/Framework.h" @@ -149,6 +150,15 @@ int run_example(int argc, char **argv, std::unique_ptr example) } } +#ifdef ARM_COMPUTE_CL + if(opencl_is_available()) + { + auto ctx_dev_err = create_opencl_context_and_device(); + ARM_COMPUTE_ERROR_ON_MSG(std::get<2>(ctx_dev_err) != CL_SUCCESS, "Failed to create OpenCL context"); + CLScheduler::get().default_init_with_context(std::get<1>(ctx_dev_err), std::get<0>(ctx_dev_err), nullptr); + } +#endif /* ARM_COMPUTE_CL */ + if(options.log_level->value() >= framework::LogLevel::CONFIG) { for(auto &p : printers) @@ -159,10 +169,6 @@ int run_example(int argc, char **argv, std::unique_ptr example) #ifdef ARM_COMPUTE_CL if(opencl_is_available()) { - if(!CLScheduler::get().is_initialised()) - { - CLScheduler::get().default_init(); - } p->print_entry("CL_DEVICE_VERSION", CLKernelLibrary::get().get_device_version()); } else -- cgit v1.2.1