Skip to content

YAKL Timers

Matt Norman edited this page May 9, 2022 · 9 revisions

By default YAKL's timers use YAKL's own internal timer library. To override YAKL's timers to use another library, such as GPTL for instance, please use the following functions to override YAKL's timer calls with your own perferred code:

yakl::set_timer_init    ( std::function<void ()>             func );
yakl::set_timer_finalize( std::function<void ()>             func );
yakl::set_timer_start   ( std::function<void (char const *)> func );
yakl::set_timer_stop    ( std::function<void (char const *)> func );

To use YAKL's timers, please use yakl::timer_init(), yakl::timer_start("label"), yakl::timer_stop("label"), and yakl::timer_finalize().

yakl::timer_start("mylabel")
...
yakl::timer_stop("mylabel")

If you're using YAKL's internal timers, please be sure to set the CPP macro -DYAKL_PROFILE to turn them on and get output. If you've overriden YAKL's internal timers with your own, please to not set YAKL_PROFILE or YAKL_AUTO_PROFILE at this time. These will be enabled for external timers in the future, but for now, for external timers, please manually place timer_start() and timer_stop() for now.

To make profiling easier when using YAKL's internal timers, you can also pass -DYAKL_AUTO_PROFILE, and YAKL will wrap timer calls around every parallel_for call in the code using its name as a label. All parallel_for calls without a string name will be timed as "unlabeled".

Important: All timer calls involve an fence() operation to ensure GPU kernels are accurately timed. This can add significant overhead to latency-sensitive (small-workload) applications. Also, if you do not specify either -DYAKL_PROFILE or -DYAKL_AUTO_PROFILE, then all timer calls will become no-ops.

Clone this wiki locally