diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-09 10:58:40 +0000 |
---|---|---|
committer | Pablo Marquez <pablo.tello@arm.com> | 2018-11-12 09:58:02 +0000 |
commit | e7f4a432775eb215c9da7ade1ee2710f67641068 (patch) | |
tree | 98e9d636009e68d0f79d122b51bb4b6eab76bcad /tests/framework/instruments | |
parent | 0cf77981fadb883b97efec112e115450873e64c3 (diff) | |
download | ComputeLibrary-e7f4a432775eb215c9da7ade1ee2710f67641068.tar.gz |
COMPMID-1777: Output 'now' measurements in OpenCLTimer at the beginning of the test.
This is needed in order to calculate the offset between OpenCL timestamps and Wall Clock timestamps as they're using different clocks
Change-Id: I874b2a475bf98fd664a1e3e15045c80f0181af47
Diffstat (limited to 'tests/framework/instruments')
-rw-r--r-- | tests/framework/instruments/OpenCLTimer.cpp | 27 | ||||
-rw-r--r-- | tests/framework/instruments/OpenCLTimer.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/framework/instruments/OpenCLTimer.cpp b/tests/framework/instruments/OpenCLTimer.cpp index b23b8a8878..c443aade56 100644 --- a/tests/framework/instruments/OpenCLTimer.cpp +++ b/tests/framework/instruments/OpenCLTimer.cpp @@ -202,6 +202,33 @@ Instrument::MeasurementsMap OpenCLClock<output_timestamps>::measurements() const return measurements; } +template <bool output_timestamps> +Instrument::MeasurementsMap OpenCLClock<output_timestamps>::test_measurements() const +{ + MeasurementsMap measurements; + + if(output_timestamps) + { + // The OpenCL clock and the wall clock are not in sync, so we use + // this trick to calculate the offset between the two clocks: + ::cl::Event event; + cl_ulong now_gpu; + + // Enqueue retrieve current CPU clock and enqueue a dummy marker + std::chrono::high_resolution_clock::time_point now_cpu = std::chrono::high_resolution_clock::now(); + CLScheduler::get().queue().enqueueMarker(&event); + + CLScheduler::get().queue().finish(); + //Access the time at which the marker was enqueued: + event.getProfilingInfo(CL_PROFILING_COMMAND_QUEUED, &now_gpu); + + measurements.emplace("Now Wall clock", Measurement(now_cpu.time_since_epoch().count() / 1000, "us")); + measurements.emplace("Now OpenCL", Measurement(now_gpu / static_cast<cl_ulong>(_scale_factor), _unit)); + } + + return measurements; +} + template class OpenCLClock<true>; template class OpenCLClock<false>; } // namespace framework diff --git a/tests/framework/instruments/OpenCLTimer.h b/tests/framework/instruments/OpenCLTimer.h index 8722e6b348..b094ef44cb 100644 --- a/tests/framework/instruments/OpenCLTimer.h +++ b/tests/framework/instruments/OpenCLTimer.h @@ -56,6 +56,7 @@ public: void stop() override; void test_stop() override; MeasurementsMap measurements() const override; + MeasurementsMap test_measurements() const override; private: #ifdef ARM_COMPUTE_CL |