diff options
Diffstat (limited to 'tests/framework/instruments')
22 files changed, 214 insertions, 72 deletions
diff --git a/tests/framework/instruments/Instrument.h b/tests/framework/instruments/Instrument.h index 301ca2fc1b..1770a492ac 100644 --- a/tests/framework/instruments/Instrument.h +++ b/tests/framework/instruments/Instrument.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,8 +24,6 @@ #ifndef ARM_COMPUTE_TEST_INSTRUMENT #define ARM_COMPUTE_TEST_INSTRUMENT -#include "support/MemorySupport.h" - #include "../Utils.h" #include "Measurement.h" @@ -119,6 +117,15 @@ public: return MeasurementsMap(); } + /** Return JSON formatted instrument header string. + * + * @return JSON formatted string + */ + virtual std::string instrument_header() const + { + return std::string{}; + } + /** Return the latest test measurements. * * @return the latest test measurements. @@ -135,7 +142,7 @@ protected: template <typename T, ScaleFactor scale> inline std::unique_ptr<Instrument> Instrument::make_instrument() { - return support::cpp14::make_unique<T>(scale); + return std::make_unique<T>(scale); } } // namespace framework diff --git a/tests/framework/instruments/Instruments.cpp b/tests/framework/instruments/Instruments.cpp index 2288124a21..7834feaa44 100644 --- a/tests/framework/instruments/Instruments.cpp +++ b/tests/framework/instruments/Instruments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/Instruments.h b/tests/framework/instruments/Instruments.h index 8adf501c18..d80032a032 100644 --- a/tests/framework/instruments/Instruments.h +++ b/tests/framework/instruments/Instruments.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,12 +24,12 @@ #ifndef ARM_COMPUTE_TEST_INSTRUMENTS #define ARM_COMPUTE_TEST_INSTRUMENTS -#if !defined(BARE_METAL) +#if !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) #include "MaliCounter.h" #include "OpenCLMemoryUsage.h" #include "OpenCLTimer.h" #include "PMUCounter.h" -#endif /* !defined(BARE_METAL) */ +#endif /* !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) */ #include "SchedulerTimer.h" #include "WallClockTimer.h" diff --git a/tests/framework/instruments/InstrumentsStats.cpp b/tests/framework/instruments/InstrumentsStats.cpp index 8f7d8a18e3..2bb9eed97d 100644 --- a/tests/framework/instruments/InstrumentsStats.cpp +++ b/tests/framework/instruments/InstrumentsStats.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/InstrumentsStats.h b/tests/framework/instruments/InstrumentsStats.h index f1085aafb8..aa2008ace3 100644 --- a/tests/framework/instruments/InstrumentsStats.h +++ b/tests/framework/instruments/InstrumentsStats.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/MaliCounter.cpp b/tests/framework/instruments/MaliCounter.cpp index 354c899253..a7557fc94c 100644 --- a/tests/framework/instruments/MaliCounter.cpp +++ b/tests/framework/instruments/MaliCounter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/MaliCounter.h b/tests/framework/instruments/MaliCounter.h index 94ef93fdb5..c2d1849423 100644 --- a/tests/framework/instruments/MaliCounter.h +++ b/tests/framework/instruments/MaliCounter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/Measurement.h b/tests/framework/instruments/Measurement.h index 5c62977b91..2ec68d424b 100644 --- a/tests/framework/instruments/Measurement.h +++ b/tests/framework/instruments/Measurement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018,2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -209,10 +209,10 @@ struct Measurement /** Stored value */ union - { - double floating_point; - long long int integer; - } v; + { + double floating_point; + long long int integer; + } v; bool is_floating_point; /**< Is the stored value floating point or integer ? */ }; diff --git a/tests/framework/instruments/OpenCLMemoryUsage.cpp b/tests/framework/instruments/OpenCLMemoryUsage.cpp index 7b08e2d85b..5ed2013f3d 100644 --- a/tests/framework/instruments/OpenCLMemoryUsage.cpp +++ b/tests/framework/instruments/OpenCLMemoryUsage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 ARM Limited. + * Copyright (c) 2018-2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/OpenCLMemoryUsage.h b/tests/framework/instruments/OpenCLMemoryUsage.h index 7593c01e63..07b6544f51 100644 --- a/tests/framework/instruments/OpenCLMemoryUsage.h +++ b/tests/framework/instruments/OpenCLMemoryUsage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/OpenCLTimer.cpp b/tests/framework/instruments/OpenCLTimer.cpp index ca4c13ce61..e9f945bd95 100644 --- a/tests/framework/instruments/OpenCLTimer.cpp +++ b/tests/framework/instruments/OpenCLTimer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019, 2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -54,7 +54,13 @@ std::string OpenCLClock<output_timestamps>::id() const template <bool output_timestamps> OpenCLClock<output_timestamps>::OpenCLClock(ScaleFactor scale_factor) - : _kernels(), _real_function(nullptr), _real_graph_function(nullptr), _prefix(), _timer_enabled(false) + : _kernels(), + _real_function(nullptr), +#ifdef ARM_COMPUTE_GRAPH_ENABLED + _real_graph_function(nullptr), +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ + _prefix(), + _timer_enabled(false) { auto q = CLScheduler::get().queue(); cl_command_queue_properties props = q.getInfo<CL_QUEUE_PROPERTIES>(); @@ -91,19 +97,17 @@ void OpenCLClock<output_timestamps>::test_start() { // Start intercepting enqueues: ARM_COMPUTE_ERROR_ON(_real_function != nullptr); - ARM_COMPUTE_ERROR_ON(_real_graph_function != nullptr); - _real_function = CLSymbols::get().clEnqueueNDRangeKernel_ptr; - _real_graph_function = graph::TaskExecutor::get().execute_function; - auto interceptor = [this]( - cl_command_queue command_queue, - cl_kernel kernel, - cl_uint work_dim, - const size_t *gwo, - const size_t *gws, - const size_t *lws, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) + _real_function = CLSymbols::get().clEnqueueNDRangeKernel_ptr; + auto interceptor = [this]( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t *gwo, + const size_t *gws, + const size_t *lws, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) { if(this->_timer_enabled) { @@ -138,7 +142,11 @@ void OpenCLClock<output_timestamps>::test_start() return this->_real_function(command_queue, kernel, work_dim, gwo, gws, lws, num_events_in_wait_list, event_wait_list, event); } }; + CLSymbols::get().clEnqueueNDRangeKernel_ptr = interceptor; +#ifdef ARM_COMPUTE_GRAPH_ENABLED + ARM_COMPUTE_ERROR_ON(_real_graph_function != nullptr); + _real_graph_function = graph::TaskExecutor::get().execute_function; // Start intercepting tasks: auto task_interceptor = [this](graph::ExecutionTask & task) { @@ -153,9 +161,8 @@ void OpenCLClock<output_timestamps>::test_start() this->_real_graph_function(task); this->_prefix = ""; }; - - CLSymbols::get().clEnqueueNDRangeKernel_ptr = interceptor; graph::TaskExecutor::get().execute_function = task_interceptor; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ } template <bool output_timestamps> @@ -175,9 +182,11 @@ void OpenCLClock<output_timestamps>::test_stop() { // Restore real function CLSymbols::get().clEnqueueNDRangeKernel_ptr = _real_function; + _real_function = nullptr; +#ifdef ARM_COMPUTE_GRAPH_ENABLED graph::TaskExecutor::get().execute_function = _real_graph_function; _real_graph_function = nullptr; - _real_function = nullptr; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ } template <bool output_timestamps> diff --git a/tests/framework/instruments/OpenCLTimer.h b/tests/framework/instruments/OpenCLTimer.h index b094ef44cb..1812272435 100644 --- a/tests/framework/instruments/OpenCLTimer.h +++ b/tests/framework/instruments/OpenCLTimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018, 2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -67,9 +67,11 @@ private: }; std::list<kernel_info> _kernels; std::function<decltype(clEnqueueNDRangeKernel)> _real_function; - std::function<decltype(graph::execute_task)> _real_graph_function; - std::string _prefix; - bool _timer_enabled; +#ifdef ARM_COMPUTE_GRAPH_ENABLED + std::function<decltype(graph::execute_task)> _real_graph_function; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ + std::string _prefix; + bool _timer_enabled; #endif /* ARM_COMPUTE_CL */ private: diff --git a/tests/framework/instruments/PMU.cpp b/tests/framework/instruments/PMU.cpp index 053c70a83f..bb2c70e215 100644 --- a/tests/framework/instruments/PMU.cpp +++ b/tests/framework/instruments/PMU.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/PMU.h b/tests/framework/instruments/PMU.h index ef4a9a0dd0..c392a0ac66 100644 --- a/tests/framework/instruments/PMU.h +++ b/tests/framework/instruments/PMU.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/PMUCounter.cpp b/tests/framework/instruments/PMUCounter.cpp index df059fbc4e..18821b5d6f 100644 --- a/tests/framework/instruments/PMUCounter.cpp +++ b/tests/framework/instruments/PMUCounter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/PMUCounter.h b/tests/framework/instruments/PMUCounter.h index 0719b10864..7dddbbf6fa 100644 --- a/tests/framework/instruments/PMUCounter.h +++ b/tests/framework/instruments/PMUCounter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/SchedulerTimer.cpp b/tests/framework/instruments/SchedulerTimer.cpp index 9e8bba28e8..b753485351 100644 --- a/tests/framework/instruments/SchedulerTimer.cpp +++ b/tests/framework/instruments/SchedulerTimer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,8 +26,9 @@ #include "Instruments.h" #include "WallClockTimer.h" #include "arm_compute/core/CPP/ICPPKernel.h" -#include "arm_compute/core/utils/misc/Cast.h" +#include "arm_compute/graph/DataLayerVisitor.h" #include "arm_compute/graph/INode.h" +#include "support/Cast.h" namespace arm_compute { @@ -53,8 +54,10 @@ class Interceptor final : public IScheduler { public: /** Default constructor. */ - Interceptor(std::list<struct SchedulerClock<output_timestamps>::kernel_info> &kernels, IScheduler &real_scheduler, ScaleFactor scale_factor) - : _kernels(kernels), _real_scheduler(real_scheduler), _timer(scale_factor), _prefix() + Interceptor(std::list<struct SchedulerClock<output_timestamps>::kernel_info> &kernels, + std::map<std::string, SchedulerTimer::LayerData> &layers, IScheduler &real_scheduler, + ScaleFactor scale_factor) + : _kernels(kernels), _layer_data_map(layers), _real_scheduler(real_scheduler), _timer(scale_factor), _prefix() { } @@ -63,6 +66,11 @@ public: _real_scheduler.set_num_threads(num_threads); } + void set_num_threads_with_affinity(unsigned int num_threads, BindFunc func) override + { + _real_scheduler.set_num_threads_with_affinity(num_threads, func); + } + unsigned int num_threads() const override { return _real_scheduler.num_threads(); @@ -86,6 +94,19 @@ public: _kernels.push_back(std::move(info)); } + void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) override + { + _timer.start(); + _real_scheduler.schedule_op(kernel, hints, window, tensors); + _timer.stop(); + + typename SchedulerClock<output_timestamps>::kernel_info info; + info.name = kernel->name(); + info.prefix = _prefix; + info.measurements = _timer.measurements(); + _kernels.push_back(std::move(info)); + } + void run_tagged_workloads(std::vector<Workload> &workloads, const char *tag) override { _timer.start(); @@ -108,14 +129,24 @@ protected: private: std::list<struct SchedulerClock<output_timestamps>::kernel_info> &_kernels; - IScheduler &_real_scheduler; - WallClock<output_timestamps> _timer; - std::string _prefix; + std::map<std::string, SchedulerTimer::LayerData> &_layer_data_map; + IScheduler &_real_scheduler; + WallClock<output_timestamps> _timer; + std::string _prefix; }; template <bool output_timestamps> SchedulerClock<output_timestamps>::SchedulerClock(ScaleFactor scale_factor) - : _kernels(), _real_scheduler(nullptr), _real_scheduler_type(), _real_graph_function(nullptr), _scale_factor(scale_factor), _interceptor(nullptr), _scheduler_users() + : _kernels(), + _layer_data_map(), + _real_scheduler(nullptr), + _real_scheduler_type(), +#ifdef ARM_COMPUTE_GRAPH_ENABLED + _real_graph_function(nullptr), +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ + _scale_factor(scale_factor), + _interceptor(nullptr), + _scheduler_users() { if(instruments_info != nullptr) { @@ -126,6 +157,7 @@ SchedulerClock<output_timestamps>::SchedulerClock(ScaleFactor scale_factor) template <bool output_timestamps> void SchedulerClock<output_timestamps>::test_start() { +#ifdef ARM_COMPUTE_GRAPH_ENABLED // Start intercepting tasks: ARM_COMPUTE_ERROR_ON(_real_graph_function != nullptr); _real_graph_function = graph::TaskExecutor::get().execute_function; @@ -138,6 +170,13 @@ void SchedulerClock<output_timestamps>::test_start() if(task.node != nullptr && !task.node->name().empty()) { scheduler->set_prefix(task.node->name() + "/"); + + if(_layer_data_map.find(task.node->name()) == _layer_data_map.end()) + { + arm_compute::graph::DataLayerVisitor dlv = {}; + task.node->accept(dlv); + _layer_data_map[task.node->name()] = dlv.layer_data(); + } } else { @@ -152,6 +191,7 @@ void SchedulerClock<output_timestamps>::test_start() scheduler->set_prefix(""); } }; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ ARM_COMPUTE_ERROR_ON(_real_scheduler != nullptr); _real_scheduler_type = Scheduler::get_type(); @@ -159,9 +199,11 @@ void SchedulerClock<output_timestamps>::test_start() if(_real_scheduler_type != Scheduler::Type::CUSTOM) { _real_scheduler = &Scheduler::get(); - _interceptor = std::make_shared<Interceptor<output_timestamps>>(_kernels, *_real_scheduler, _scale_factor); + _interceptor = std::make_shared<Interceptor<output_timestamps>>(_kernels, _layer_data_map, *_real_scheduler, _scale_factor); Scheduler::set(std::static_pointer_cast<IScheduler>(_interceptor)); +#ifdef ARM_COMPUTE_GRAPH_ENABLED graph::TaskExecutor::get().execute_function = task_interceptor; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ // Create an interceptor for each scheduler // TODO(COMPID-2638) : Allow multiple schedulers, now it assumes the same scheduler is used. @@ -170,7 +212,7 @@ void SchedulerClock<output_timestamps>::test_start() { if(user != nullptr && user->scheduler() != nullptr) { - user->intercept_scheduler(support::cpp14::make_unique<Interceptor<output_timestamps>>(_kernels, *user->scheduler(), _scale_factor)); + user->intercept_scheduler(std::make_unique<Interceptor<output_timestamps>>(_kernels, _layer_data_map, *user->scheduler(), _scale_factor)); } }); } @@ -187,10 +229,12 @@ void SchedulerClock<output_timestamps>::test_stop() { // Restore real scheduler Scheduler::set(_real_scheduler_type); - _real_scheduler = nullptr; - _interceptor = nullptr; + _real_scheduler = nullptr; + _interceptor = nullptr; +#ifdef ARM_COMPUTE_GRAPH_ENABLED graph::TaskExecutor::get().execute_function = _real_graph_function; _real_graph_function = nullptr; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ // Restore schedulers std::for_each(std::begin(_scheduler_users), std::end(_scheduler_users), @@ -239,6 +283,36 @@ Instrument::MeasurementsMap SchedulerClock<output_timestamps>::measurements() co return measurements; } +template <bool output_timestamps> +std::string SchedulerClock<output_timestamps>::instrument_header() const +{ + std::string output{ "" }; + output += R"("layer_data" : {)"; + for(auto i_it = _layer_data_map.cbegin(), i_end = _layer_data_map.cend(); i_it != i_end; ++i_it) + { + output += "\"" + i_it->first + "\" : {"; + if(i_it->second.size() != 0) + { + // Print for each entry in layer + for(auto entry_it = i_it->second.cbegin(), entry_end = i_it->second.cend(); entry_it != entry_end; ++entry_it) + { + output += "\"" + entry_it->first + "\" : \"" + entry_it->second + "\""; + if(std::next(entry_it) != entry_end) + { + output += ","; + } + } + } + output += "}"; + if(std::next(i_it) != i_end) + { + output += ","; + } + } + output += "}"; + return output; +} + } // namespace framework } // namespace test } // namespace arm_compute diff --git a/tests/framework/instruments/SchedulerTimer.h b/tests/framework/instruments/SchedulerTimer.h index ea64b227eb..c437f2717c 100644 --- a/tests/framework/instruments/SchedulerTimer.h +++ b/tests/framework/instruments/SchedulerTimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2019,2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -63,6 +63,7 @@ template <bool output_timestamps> class SchedulerClock : public Instrument { public: + using LayerData = std::map<std::string, std::string>; /** Construct a Scheduler timer. * * @param[in] scale_factor Measurement scale factor. @@ -85,6 +86,7 @@ public: void start() override; void test_stop() override; Instrument::MeasurementsMap measurements() const override; + std::string instrument_header() const override; /** Kernel information */ struct kernel_info @@ -95,13 +97,16 @@ public: }; private: - std::list<kernel_info> _kernels; - IScheduler *_real_scheduler; - Scheduler::Type _real_scheduler_type; + std::list<kernel_info> _kernels; + std::map<std::string, LayerData> _layer_data_map; + IScheduler *_real_scheduler; + Scheduler::Type _real_scheduler_type; +#ifdef ARM_COMPUTE_GRAPH_ENABLED std::function<decltype(graph::execute_task)> _real_graph_function; - ScaleFactor _scale_factor; - std::shared_ptr<IScheduler> _interceptor; - std::vector<ISchedulerUser *> _scheduler_users; +#endif /* ARM_COMPUTE_GRAPH_ENABLED */ + ScaleFactor _scale_factor; + std::shared_ptr<IScheduler> _interceptor; + std::vector<ISchedulerUser *> _scheduler_users; }; using SchedulerTimer = SchedulerClock<false>; diff --git a/tests/framework/instruments/WallClockTimer.cpp b/tests/framework/instruments/WallClockTimer.cpp index 0e21ac71fb..763fb9ab27 100644 --- a/tests/framework/instruments/WallClockTimer.cpp +++ b/tests/framework/instruments/WallClockTimer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -48,13 +48,44 @@ std::string WallClock<output_timestamps>::id() const template <bool output_timestamps> void WallClock<output_timestamps>::start() { +#if defined(BARE_METAL) + uint64_t tmp; + uint64_t retval; + + __asm __volatile( + "mrs %[tmp], pmcr_el0\n" + "orr %[tmp], %[tmp], #1\n" + "msr pmcr_el0, %[tmp]\n" + "mrs %[tmp], pmcntenset_el0\n" + "orr %[tmp], %[tmp], #1<<31\n" + "msr pmcntenset_el0, %[tmp]\n" + "mrs %[retval], pmccntr_el0\n" + : [tmp] "=r"(tmp), [retval] "=r"(retval)); + + _start = retval; +#else // !defined(BARE_METAL) _start = std::chrono::system_clock::now(); +#endif // defined(BARE_METAL) } template <bool output_timestamps> void WallClock<output_timestamps>::stop() { +#if defined(BARE_METAL) + uint64_t tmp; + uint64_t retval; + + __asm __volatile( + "mrs %[retval], pmccntr_el0\n" + "mov %[tmp], #0x3f\n" + "orr %[tmp], %[tmp], #1<<31\n" + "msr pmcntenclr_el0, %[tmp]\n" + : [tmp] "=r"(tmp), [retval] "=r"(retval)); + + _stop = retval; +#else // !defined(BARE_METAL) _stop = std::chrono::system_clock::now(); +#endif // defined(BARE_METAL) } template <bool output_timestamps> @@ -63,14 +94,23 @@ Instrument::MeasurementsMap WallClock<output_timestamps>::measurements() const MeasurementsMap measurements; if(output_timestamps) { - // _start / _stop are in ns, so divide by an extra 1000: +#if defined(BARE_METAL) + measurements.emplace("[start]Wall clock time", Measurement(_start / static_cast<uint64_t>(_scale_factor), _unit)); + measurements.emplace("[end]Wall clock time", Measurement(_stop / static_cast<uint64_t>(_scale_factor), _unit)); +#else // !defined(BARE_METAL) measurements.emplace("[start]Wall clock time", Measurement(_start.time_since_epoch().count() / static_cast<uint64_t>(1000 * _scale_factor), _unit)); measurements.emplace("[end]Wall clock time", Measurement(_stop.time_since_epoch().count() / static_cast<uint64_t>(1000 * _scale_factor), _unit)); +#endif // defined(BARE_METAL) } else { +#if defined(BARE_METAL) + const double delta = _stop - _start; + measurements.emplace("Wall clock time", Measurement(delta / static_cast<double>(1000 * _scale_factor), _unit)); +#else // !defined(BARE_METAL) const auto delta = std::chrono::duration_cast<std::chrono::microseconds>(_stop - _start); measurements.emplace("Wall clock time", Measurement(delta.count() / _scale_factor, _unit)); +#endif // defined(BARE_METAL) } return measurements; } diff --git a/tests/framework/instruments/WallClockTimer.h b/tests/framework/instruments/WallClockTimer.h index fb047aa7e4..b1d7531f4e 100644 --- a/tests/framework/instruments/WallClockTimer.h +++ b/tests/framework/instruments/WallClockTimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -70,9 +70,14 @@ public: MeasurementsMap measurements() const override; private: - std::chrono::system_clock::time_point _start{}; +#if defined(BARE_METAL) + uint64_t _start {}; + uint64_t _stop{}; +#else // !defined(BARE_METAL) + std::chrono::system_clock::time_point _start {}; std::chrono::system_clock::time_point _stop{}; - float _scale_factor{}; +#endif // defined(BARE_METAL) + float _scale_factor {}; }; using WallClockTimer = WallClock<false>; diff --git a/tests/framework/instruments/hwc.hpp b/tests/framework/instruments/hwc.hpp index 8c48e0ca45..5d12a40217 100644 --- a/tests/framework/instruments/hwc.hpp +++ b/tests/framework/instruments/hwc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/framework/instruments/hwc_names.hpp b/tests/framework/instruments/hwc_names.hpp index cbcb0e788e..c39f3bba7a 100644 --- a/tests/framework/instruments/hwc_names.hpp +++ b/tests/framework/instruments/hwc_names.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -44,7 +44,7 @@ enum /* * "Short names" for hardware counters used by Streamline. Counters names are * stored in accordance with their memory layout in the binary counter block - * emitted by the Mali GPU. Each "master" in the GPU emits a fixed-size block + * emitted by the Arm® Mali™ GPU. Each "master" in the GPU emits a fixed-size block * of 64 counters, and each GPU implements the same set of "masters" although * the counters each master exposes within its block of 64 may vary. * |