| 220 | |
| 221 | template <bool output_timestamps> |
| 222 | Instrument::MeasurementsMap OpenCLClock<output_timestamps>::test_measurements() const |
| 223 | { |
| 224 | MeasurementsMap measurements; |
| 225 | |
| 226 | if (output_timestamps) |
| 227 | { |
| 228 | // The OpenCL clock and the wall clock are not in sync, so we use |
| 229 | // this trick to calculate the offset between the two clocks: |
| 230 | ::cl::Event event; |
| 231 | cl_ulong now_gpu; |
| 232 | |
| 233 | // Enqueue retrieve current CPU clock and enqueue a dummy marker |
| 234 | std::chrono::high_resolution_clock::time_point now_cpu = std::chrono::high_resolution_clock::now(); |
| 235 | CLScheduler::get().queue().enqueueMarker(&event); |
| 236 | |
| 237 | CLScheduler::get().queue().finish(); |
| 238 | //Access the time at which the marker was enqueued: |
| 239 | event.getProfilingInfo(CL_PROFILING_COMMAND_QUEUED, &now_gpu); |
| 240 | |
| 241 | measurements.emplace("Now Wall clock", Measurement(now_cpu.time_since_epoch().count() / 1000, "us")); |
| 242 | measurements.emplace("Now OpenCL", Measurement(now_gpu / static_cast<cl_ulong>(_scale_factor), _unit)); |
| 243 | } |
| 244 | |
| 245 | return measurements; |
| 246 | } |
| 247 | |
| 248 | } // namespace framework |
| 249 | } // namespace test |
no test coverage detected