diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2018-04-20 15:46:21 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:49:54 +0000 |
commit | 9fb0cac961f70d1937c5fa3eafeaee1385c89768 (patch) | |
tree | 9a8847053f65631e050c231645549adb48c92fb8 /tests/validate_examples/RunExample.cpp | |
parent | fda901f0485371e8b6a807c8dd9614560a924793 (diff) | |
download | ComputeLibrary-9fb0cac961f70d1937c5fa3eafeaee1385c89768.tar.gz |
COMPMID-1081: Introduced test-wide instruments
Change-Id: I5831241f3fc503717cc51136453c2bf96d4b420b
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/128484
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validate_examples/RunExample.cpp')
-rw-r--r-- | tests/validate_examples/RunExample.cpp | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/tests/validate_examples/RunExample.cpp b/tests/validate_examples/RunExample.cpp index a7b18ce555..8b1c39b844 100644 --- a/tests/validate_examples/RunExample.cpp +++ b/tests/validate_examples/RunExample.cpp @@ -57,12 +57,19 @@ std::unique_ptr<AssetsLibrary> library; } // namespace test namespace utils { -static ValidateExample *g_example = nullptr; -template <bool validate> +static std::unique_ptr<ValidateExample> g_example = nullptr; +static std::vector<char *> g_example_argv = {}; + +template <bool validate> class ExampleTest : public arm_compute::test::framework::TestCase { public: ExampleTest() = default; + void do_setup() override + { + ARM_COMPUTE_ERROR_ON_NULLPTR(g_example.get()); + g_example->do_setup(g_example_argv.size(), &g_example_argv[0]); + } void do_run() override { g_example->do_run(); @@ -74,10 +81,11 @@ public: g_example->do_validate(); } g_example->do_teardown(); + g_example = nullptr; } }; -int run_example(int argc, char **argv, ValidateExample &example) +int run_example(int argc, char **argv, std::unique_ptr<ValidateExample> example) { framework::CommandLineParser parser; framework::CommonOptions options(parser); @@ -99,43 +107,18 @@ int run_example(int argc, char **argv, ValidateExample &example) } std::vector<std::unique_ptr<framework::Printer>> printers = options.create_printers(); - g_example = &example; - std::vector<char *> example_argv = {}; - example_argv.clear(); - example_argv.emplace_back(argv[0]); + g_example = std::move(example); + g_example_argv.clear(); + g_example_argv.emplace_back(argv[0]); for(auto &arg : example_args->value()) { - example_argv.emplace_back(const_cast<char *>(arg.c_str())); // NOLINT + g_example_argv.emplace_back(const_cast<char *>(arg.c_str())); // NOLINT } // Set number of threads in Scheduler Scheduler::get().set_num_threads(options.threads->value()); library = support::cpp14::make_unique<AssetsLibrary>("." /* Only using random values */, seed->value()); - // We need to do the setup here because framework.init() will need CL / GLES to be initialised - try - { - example.do_setup(example_argv.size(), &example_argv[0]); - } -#ifdef ARM_COMPUTE_CL - catch(cl::Error &err) - { - std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cerr << std::endl - << "ERROR " << err.what() << "(" << err.err() << ")" << std::endl; - std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - return 1; - } -#endif /* ARM_COMPUTE_CL */ - catch(std::runtime_error &err) - { - std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cerr << std::endl - << "ERROR " << err.what() << " " << (errno ? strerror(errno) : "") << std::endl; - std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - return 1; - } - if(options.log_level->value() > framework::LogLevel::NONE) { for(auto &p : printers) @@ -153,6 +136,10 @@ int run_example(int argc, char **argv, ValidateExample &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 @@ -162,7 +149,7 @@ int run_example(int argc, char **argv, ValidateExample &example) #endif /* ARM_COMPUTE_CL */ p->print_entry("Iterations", support::cpp11::to_string(options.iterations->value())); p->print_entry("Threads", support::cpp11::to_string(options.threads->value())); - example.print_parameters(*p); + g_example->print_parameters(*p); } } |