CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
128 lines
2.7 KiB
C++
128 lines
2.7 KiB
C++
/*!
|
|
******************************************************************************
|
|
*
|
|
* \file
|
|
*
|
|
* \brief RAJA header file for simple class that can be used to
|
|
* time code sections.
|
|
*
|
|
* \author Rich Hornung, Center for Applied Scientific Computing, LLNL
|
|
* \author Jeff Keasler, Applications, Simulations And Quality, LLNL
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
|
|
#ifndef RAJA_Timer_HXX
|
|
#define RAJA_Timer_HXX
|
|
|
|
#if defined(RAJA_USE_CYCLE)
|
|
# include "./cycle.h"
|
|
typedef ticks TimeType;
|
|
|
|
#elif defined(RAJA_USE_CLOCK)
|
|
# include <time.h>
|
|
typedef clock_t TimeType;
|
|
|
|
#elif defined(RAJA_USE_GETTIME)
|
|
# include <time.h>
|
|
typedef timespec TimeType;
|
|
|
|
#else
|
|
# error RAJA_TIMER_TYPE is undefined!
|
|
|
|
#endif
|
|
|
|
namespace RAJA
|
|
{
|
|
/*!
|
|
******************************************************************************
|
|
*
|
|
* \brief Simple timer class to time code sections.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
class Timer
|
|
{
|
|
public:
|
|
#if defined(RAJA_USE_CYCLE) || defined(RAJA_USE_CLOCK)
|
|
Timer()
|
|
: telapsed(0)
|
|
{
|
|
;
|
|
}
|
|
#endif
|
|
#if defined(RAJA_USE_GETTIME)
|
|
Timer()
|
|
: telapsed(0)
|
|
, stime_elapsed(0)
|
|
, nstime_elapsed(0)
|
|
{
|
|
;
|
|
}
|
|
#endif
|
|
|
|
#if defined(RAJA_USE_CYCLE)
|
|
void start() { tstart = getticks(); }
|
|
void stop()
|
|
{
|
|
tstop = getticks();
|
|
set_elapsed();
|
|
}
|
|
|
|
long double elapsed() { return static_cast<long double>(telapsed); }
|
|
#endif
|
|
|
|
#if defined(RAJA_USE_CLOCK)
|
|
void start() { tstart = clock(); }
|
|
void stop()
|
|
{
|
|
tstop = clock();
|
|
set_elapsed();
|
|
}
|
|
|
|
long double elapsed() { return static_cast<long double>(telapsed) / CLOCKS_PER_SEC; }
|
|
#endif
|
|
|
|
#if defined(RAJA_USE_GETTIME)
|
|
|
|
# if 0
|
|
void start() { clock_gettime(CLOCK_REALTIME, &tstart); }
|
|
void stop() { clock_gettime(CLOCK_REALTIME, &tstop); set_elapsed(); }
|
|
# else
|
|
void start() { clock_gettime(CLOCK_MONOTONIC, &tstart); }
|
|
void stop()
|
|
{
|
|
clock_gettime(CLOCK_MONOTONIC, &tstop);
|
|
set_elapsed();
|
|
}
|
|
# endif
|
|
|
|
long double elapsed() { return (stime_elapsed + nstime_elapsed); }
|
|
|
|
#endif
|
|
|
|
private:
|
|
TimeType tstart;
|
|
TimeType tstop;
|
|
long double telapsed;
|
|
|
|
#if defined(RAJA_USE_CYCLE) || defined(RAJA_USE_CLOCK)
|
|
void set_elapsed() { telapsed += (tstop - tstart); }
|
|
|
|
#elif defined(RAJA_USE_GETTIME)
|
|
long double stime_elapsed;
|
|
long double nstime_elapsed;
|
|
|
|
void set_elapsed()
|
|
{
|
|
stime_elapsed += static_cast<long double>(tstop.tv_sec - tstart.tv_sec);
|
|
nstime_elapsed +=
|
|
static_cast<long double>(tstop.tv_nsec - tstart.tv_nsec) / 1000000000.0;
|
|
}
|
|
#endif
|
|
};
|
|
|
|
} // namespace RAJA
|
|
|
|
#endif // closing endif for header file include guard
|