From 7ae80a928564eba96c4fef0b91b1c50e1647fb8d Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 25 Oct 2019 18:25:17 +0100 Subject: COMPMID-2549: Add GLES Runtime Context interfaces. * Creates interfaces and concrete classes * Ports GCActivationalLayer * Adapts test framework and relevant tests Change-Id: Ide36cd65ebf185958db3c4a5bebd630fcb2f39b3 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/2199 Reviewed-by: Pablo Marquez Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins --- tests/framework/Framework.cpp | 2 +- tests/framework/ParametersLibrary.cpp | 19 ++++++++++++++++--- tests/framework/ParametersLibrary.h | 15 +++++++++++---- tests/main.cpp | 20 +++++++++++++++----- 4 files changed, 43 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/framework/Framework.cpp b/tests/framework/Framework.cpp index 5d1600e083..0b2ded8a3c 100644 --- a/tests/framework/Framework.cpp +++ b/tests/framework/Framework.cpp @@ -576,7 +576,7 @@ bool Framework::run() } if(parameters) { - parameters->set_gpu_ctx(std::move(cl_ctx)); + parameters->set_cl_ctx(std::move(cl_ctx)); } } #endif // ARM_COMPUTE_CL diff --git a/tests/framework/ParametersLibrary.cpp b/tests/framework/ParametersLibrary.cpp index 65a09eeb64..4af4179bda 100644 --- a/tests/framework/ParametersLibrary.cpp +++ b/tests/framework/ParametersLibrary.cpp @@ -32,9 +32,14 @@ void ParametersLibrary::set_cpu_ctx(std::unique_ptr cpu_ctx) _cpu_ctx = std::move(cpu_ctx); } -void ParametersLibrary::set_gpu_ctx(std::unique_ptr gpu_ctx) +void ParametersLibrary::set_cl_ctx(std::unique_ptr cl_ctx) { - _gpu_ctx = std::move(gpu_ctx); + _cl_ctx = std::move(cl_ctx); +} + +void ParametersLibrary::set_gc_ctx(std::unique_ptr gc_ctx) +{ + _gc_ctx = std::move(gc_ctx); } template <> @@ -47,8 +52,16 @@ typename ContextType::type *ParametersLibrary::get_ctx() template <> typename ContextType::type *ParametersLibrary::get_ctx() { - return static_cast::type *>(_gpu_ctx.get()); + return static_cast::type *>(_cl_ctx.get()); } #endif /* ARM_COMPUTE_CL */ + +#if ARM_COMPUTE_GC +template <> +typename ContextType::type *ParametersLibrary::get_ctx() +{ + return static_cast::type *>(_gc_ctx.get()); +} +#endif /* ARM_COMPUTE_GC */ } // namespace test } // namespace arm_compute diff --git a/tests/framework/ParametersLibrary.h b/tests/framework/ParametersLibrary.h index 4079ab25b9..d5039fc26c 100644 --- a/tests/framework/ParametersLibrary.h +++ b/tests/framework/ParametersLibrary.h @@ -31,6 +31,7 @@ #include "arm_compute/runtime/CL/CLTensor.h" #endif /* ARM_COMPUTE_CL */ #ifdef ARM_COMPUTE_GC +#include "arm_compute/runtime/GLES_COMPUTE/GCRuntimeContext.h" #include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h" #endif /* ARM_COMPUTE_GC */ @@ -64,7 +65,7 @@ struct ContextType template <> struct ContextType { - using type = IRuntimeContext; + using type = GCRuntimeContext; }; #endif /* ARM_COMPUTE_GC */ @@ -81,9 +82,14 @@ public: void set_cpu_ctx(std::unique_ptr cpu_ctx); /** Set gpu context to be used by the tests * - * @param[in] gpu_ctx GPU context to use + * @param[in] cl_ctx GPU context to use + */ + void set_cl_ctx(std::unique_ptr cl_ctx); + /** Set gpu context to be used by the tests + * + * @param[in] gc_ctx GPU context to use */ - void set_gpu_ctx(std::unique_ptr gpu_ctx); + void set_gc_ctx(std::unique_ptr gc_ctx); /** Get context given a tensor type * * @tparam TensorType @@ -98,7 +104,8 @@ public: private: std::unique_ptr _cpu_ctx{ nullptr }; - std::unique_ptr _gpu_ctx{ nullptr }; + std::unique_ptr _cl_ctx{ nullptr }; + std::unique_ptr _gc_ctx{ nullptr }; }; } // namespace test } // namespace arm_compute diff --git a/tests/main.cpp b/tests/main.cpp index 415dba0405..5757249188 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -92,10 +92,6 @@ bool file_exists(const std::string &filename) int main(int argc, char **argv) { -#ifdef ARM_COMPUTE_GC - GCScheduler::get().default_init(); -#endif /* ARM_COMPUTE_GC */ - framework::Framework &framework = framework::Framework::get(); utils::CommandLineParser parser; @@ -173,6 +169,20 @@ int main(int argc, char **argv) parameters = support::cpp14::make_unique(); parameters->set_cpu_ctx(std::move(cpu_ctx)); +#ifdef ARM_COMPUTE_GC + // Setup OpenGL context + { + auto gles_ctx = support::cpp14::make_unique(); + ARM_COMPUTE_ERROR_ON(gles_ctx == nullptr); + { + // Legacy singletons API: This has been deprecated and the singletons will be removed + // Setup singleton for backward compatibility + GCScheduler::get().default_init(); + } + parameters->set_gc_ctx(std::move(gles_ctx)); + }; +#endif /* ARM_COMPUTE_GC */ + #ifdef ARM_COMPUTE_CL CLTuner cl_tuner(false); // Create GPU context @@ -186,7 +196,7 @@ int main(int argc, char **argv) // Setup singleton for backward compatibility CLScheduler::get().init(gpu_scheduler->context(), gpu_scheduler->queue(), cl_ctx->kernel_library().get_device(), &cl_tuner); } - parameters->set_gpu_ctx(std::move(cl_ctx)); + parameters->set_cl_ctx(std::move(cl_ctx)); if(enable_tuner->is_set()) { -- cgit v1.2.1