diff --git a/HLTrigger/Timer/test/chrono/README.md b/HLTrigger/Timer/test/chrono/README.md deleted file mode 100644 index 716721ebd3575..0000000000000 --- a/HLTrigger/Timer/test/chrono/README.md +++ /dev/null @@ -1,80 +0,0 @@ -chrono -====== - -Timers based on different time sources, using the C++11 chrono interface. - - - -Intel Time Stamp Counter -======================== - -Some details on the TSC found in Intel processors, related serialising instructions, -and benchmarks, can be found at [http://download.intel.com/embedded/software/IA/324264.pdf] - -The ratio of TSC clock to bus clock can be read from `MSR_PLATFORM_INFO[15:8]`, see -Intel 64 and IA-32 Architectures Software Developer’s Manual, Vol. 3C 35-53 (pag. 2852) - - -Notes on chrono::duration -========================= - -A duration has a representation and a tick period (precision). - -``` - template class duration; -``` - -The representation is simply any arithmetic type, or an emulation of such a type. -The representation stores a count of ticks. This count is the only data member stored in a -duration. If the representation is floating point, it can store fractions of a tick to the -precision of the representation. - -The tick period is represented by a ratio (std::ratio) and is encoded into the duration's type, -not stored. The tick period only has an impact on the behavior of the duration when a conversion -between different duration's is attempted. The tick period is completely ignored when simply -doing arithmetic on durations of the same type. - -Note that the tick period is defined at *compile time* as an `std:ratio<>`, so it cannot be used to -optimally represent clocks with period known only at runtime (e.g. x86 TSC, OSX `mach_absolute_time`, -Windows `QueryPerformanceCounter`). - - -Notes on `native_duration` -========================== - -A `native_duration` has a representation and a tick period (precision). - -``` - template class native_duration; -``` - -As in an `std::chrono::duration`, the representation is simply any arithmetic type, or an emulation -of such a type, storing a count of ticks. This count is the only data member stored in a duration. -If the representation is floating point, it can store fractions of a tick to the precision of the -representation. - -The tick period is represented by an arbitrary class, responsible for converting any amount of -"native" ticks into a standard duration, and vice versa. - -Since the implementation requires some additions to the `std` namespace, `native_duration` and the -clocks using it are implemented in the `interface/native/` and `src/native/` subdirectories, and live -in the `native` namespace. - - -Precision of different representations -====================================== - -A single precision floating point number can represent all integers up to 2^24, or 16'777,216 (~16 millions). -It can store a time interval with nanosecond resolution up to ~16 ms. - -A double precision floating point number can represent all integers up to 2^53, or 9,007,199,254,740,992 (~9e15). -It can store a time interval with nanosecond resolution up to 9,000,000 seconds - slightly more than 100 days. - -A signed long integer can represent all integers up to 2^63-1, or 9,223,372,036,854,775,807 (~9e18). -It can store a time interval with nanosecond resolution up to 9,000,000,000 seconds - almost 300 years. - - -Sample outputs -============== - -Some sample outputs are available in the `doc/` directory. diff --git a/HLTrigger/Timer/test/chrono/doc/MacOS X 10.9.4 - Intel Core i7-3667U 2.00 GHz b/HLTrigger/Timer/test/chrono/doc/MacOS X 10.9.4 - Intel Core i7-3667U 2.00 GHz deleted file mode 100644 index 0e98406aefce8..0000000000000 --- a/HLTrigger/Timer/test/chrono/doc/MacOS X 10.9.4 - Intel Core i7-3667U 2.00 GHz +++ /dev/null @@ -1,153 +0,0 @@ -Darwin 13.3.0 x86_64 -For each timer the resolution reported is the MINIMUM (MEDIAN) (MEAN +/- its STDDEV) of the increments measured during the test. - -Performance of std::chrono::steady_clock - Average time per call: 40.9 ns - Clock tick period: 1.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 146.8 ns) (average: 1003.3 +/- 0.7 ns) - -Performance of std::chrono::system_clock - Average time per call: 40.6 ns - Clock tick period: 1.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 240.4 ns) (average: 1003.5 +/- 1.2 ns) - -Performance of std::chrono::high_resolution_clock - Average time per call: 41.6 ns - Clock tick period: 1.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 488.0 ns) (average: 1015.2 +/- 2.4 ns) - -Performance of gettimeofday() - Average time per call: 39.7 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 411.0 ns) (average: 1009.5 +/- 2.1 ns) - -Performance of times() (wall-clock time) - Average time per call: 612.8 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) - Average time per call: 657.5 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using double) - Average time per call: 619.1 ns - Clock tick period: n/a - Measured resolution: 9999990.5 ns (median: 9999990.5 ns) (sigma: 42.8 ns) (average: 9999998.3 +/- 5.5 ns) - -Performance of times() (cpu time) (using double) - Average time per call: 617.1 ns - Clock tick period: n/a - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using fixed math) - Average time per call: 616.1 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) (using fixed math) - Average time per call: 624.6 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of clock() - Average time per call: 350.2 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 300.0 ns) (average: 1075.8 +/- 0.5 ns) - -Performance of getrusage(RUSAGE_SELF) - Average time per call: 338.7 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 305.4 ns) (average: 1070.2 +/- 0.5 ns) - -Performance of host_get_clock_service(SYSTEM_CLOCK), clock_get_time(...) - Average time per call: 739.1 ns - Clock tick period: 1.0 ns - Measured resolution: 721.0 ns (median: 731.0 ns) (sigma: 166.1 ns) (average: 739.1 +/- 0.2 ns) - -Performance of host_get_clock_service(REALTIME_CLOCK), clock_get_time(...) - Average time per call: 743.1 ns - Clock tick period: 1.0 ns - Measured resolution: 722.0 ns (median: 733.0 ns) (sigma: 175.2 ns) (average: 743.1 +/- 0.2 ns) - -Performance of host_get_clock_service(CALENDAR_CLOCK), clock_get_time(...) - Average time per call: 759.8 ns - Clock tick period: 1.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 127.5 ns) (average: 1002.2 +/- 0.1 ns) - -Performance of mach_absolute_time() (using nanoseconds) - Average time per call: 21.2 ns - Clock tick period: 1.0 ns - Measured resolution: 20.0 ns (median: 21.0 ns) (sigma: 18.1 ns) (average: 21.2 +/- 0.1 ns) - -Performance of mach_absolute_time() (native) - Average time per call: 18.9 ns - Clock tick period: 1.0 ns - Measured resolution: 18.0 ns (median: 19.0 ns) (sigma: 14.0 ns) (average: 18.9 +/- 0.1 ns) - -Performance of thread_info(mach_thread_self(), THREAD_BASIC_INFO, ...) - Average time per call: 852.0 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 365.1 ns) (average: 1127.8 +/- 0.4 ns) - -Performance of RDTSC (2494.316 MHz) (using nanoseconds) - Average time per call: 8.7 ns - Clock tick period: 1.0 ns - Measured resolution: 7.0 ns (median: 9.0 ns) (sigma: 11.0 ns) (average: 8.7 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2494.316 MHz) (using nanoseconds) - Average time per call: 13.5 ns - Clock tick period: 1.0 ns - Measured resolution: 12.0 ns (median: 14.0 ns) (sigma: 13.7 ns) (average: 13.5 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2494.316 MHz) (using nanoseconds) - Average time per call: 22.3 ns - Clock tick period: 1.0 ns - Measured resolution: 21.0 ns (median: 22.0 ns) (sigma: 18.3 ns) (average: 22.3 +/- 0.1 ns) - -Performance of RDTSCP (2494.316 MHz) (using nanoseconds) - Average time per call: 12.3 ns - Clock tick period: 1.0 ns - Measured resolution: 10.0 ns (median: 12.0 ns) (sigma: 14.2 ns) (average: 12.3 +/- 0.1 ns) - -Performance of RDTSC (2494.316 MHz) (native) - Average time per call: 8.5 ns - Clock tick period: 0.4 ns - Measured resolution: 7.2 ns (median: 8.8 ns) (sigma: 17.4 ns) (average: 8.5 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2494.316 MHz) (native) - Average time per call: 12.1 ns - Clock tick period: 0.4 ns - Measured resolution: 9.6 ns (median: 11.6 ns) (sigma: 30.3 ns) (average: 12.1 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2494.316 MHz) (native) - Average time per call: 21.1 ns - Clock tick period: 0.4 ns - Measured resolution: 20.0 ns (median: 21.2 ns) (sigma: 26.9 ns) (average: 21.1 +/- 0.1 ns) - -Performance of RDTSCP (2494.316 MHz) (native) - Average time per call: 11.3 ns - Clock tick period: 0.4 ns - Measured resolution: 9.6 ns (median: 11.2 ns) (sigma: 17.2 ns) (average: 11.3 +/- 0.1 ns) - -Performance of boost::timer (wall-clock time) - Average time per call: 639.4 ns - Clock tick period: 1.0 ns - Measured resolution: 630.0 ns (median: 637.0 ns) (sigma: 100.4 ns) (average: 639.4 +/- 0.1 ns) - -Performance of boost::timer (cpu time) - Average time per call: 643.1 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of tbb::tick_count - Average time per call: 41.8 ns - Clock tick period: n/a - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 106.7 ns) (average: 1001.7 +/- 0.5 ns) - -Performance of omp_get_wtime - Average time per call: 47.2 ns - Clock tick period: n/a - Measured resolution: 953.7 ns (median: 953.7 ns) (sigma: 156.3 ns) (average: 1002.1 +/- 0.7 ns) - diff --git a/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 14.04 LTS - Intel Core i5-520M 2.40 GHz b/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 14.04 LTS - Intel Core i5-520M 2.40 GHz deleted file mode 100644 index 5ce45d81bc485..0000000000000 --- a/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 14.04 LTS - Intel Core i5-520M 2.40 GHz +++ /dev/null @@ -1,160 +0,0 @@ -Linux 3.13.0-35-generic x86_64 -glibc version: 2.19 -clock source: tsc -For each timer the resolution reported is the MINIMUM (MEDIAN) (MEAN +/- its STDDEV) of the increments measured during the test. - -Performance of std::chrono::steady_clock - Average time per call: 32.5 ns - Clock tick period: 1.0 ns - Measured resolution: 31.0 ns (median: 32.0 ns) (sigma: 48.3 ns) (average: 32.5 +/- 0.1 ns) - -Performance of std::chrono::system_clock - Average time per call: 32.4 ns - Clock tick period: 1.0 ns - Measured resolution: 31.0 ns (median: 32.0 ns) (sigma: 40.6 ns) (average: 32.4 +/- 0.1 ns) - -Performance of std::chrono::high_resolution_clock - Average time per call: 32.6 ns - Clock tick period: 1.0 ns - Measured resolution: 31.0 ns (median: 32.0 ns) (sigma: 46.7 ns) (average: 32.6 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_REALTIME) - Average time per call: 28.3 ns - Clock tick period: 1.0 ns - Measured resolution: 25.0 ns (median: 28.0 ns) (sigma: 35.2 ns) (average: 28.3 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_MONOTONIC) - Average time per call: 28.1 ns - Clock tick period: 1.0 ns - Measured resolution: 25.0 ns (median: 28.0 ns) (sigma: 93.1 ns) (average: 28.1 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_MONOTONIC_RAW) - Average time per call: 79.0 ns - Clock tick period: 1.0 ns - Measured resolution: 75.0 ns (median: 78.0 ns) (sigma: 47.4 ns) (average: 79.0 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_PROCESS_CPUTIME_ID) - Average time per call: 155.2 ns - Clock tick period: 1.0 ns - Measured resolution: 151.0 ns (median: 152.0 ns) (sigma: 51.3 ns) (average: 155.3 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_THREAD_CPUTIME_ID) - Average time per call: 165.7 ns - Clock tick period: 1.0 ns - Measured resolution: 109.0 ns (median: 146.0 ns) (sigma: 1851.9 ns) (average: 165.1 +/- 1.9 ns) - -Performance of gettimeofday() - Average time per call: 32.7 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 203.1 ns) (average: 1004.4 +/- 1.1 ns) - -Performance of times() (wall-clock time) - Average time per call: 60.1 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) - Average time per call: 161.5 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using double) - Average time per call: 48.5 ns - Clock tick period: n/a - Measured resolution: 9999997.9 ns (median: 10000001.6 ns) (sigma: 2.2 ns) (average: 9999999.8 +/- 1.1 ns) - -Performance of times() (cpu time) (using double) - Average time per call: 158.7 ns - Clock tick period: n/a - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using fixed math) - Average time per call: 49.6 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) (using fixed math) - Average time per call: 159.0 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of clock() - Average time per call: 162.4 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 111.7 ns) (average: 1003.9 +/- 0.3 ns) - -Performance of getrusage(RUSAGE_SELF) - Average time per call: 227.8 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 21000.0 ns) (sigma: 421117.4 ns) (average: 222668.6 +/- 13166.3 ns) - -Performance of getrusage(RUSAGE_THREAD) - Average time per call: 133.1 ns - Clock tick period: 1000.0 ns - Measured resolution: 2000.0 ns (median: 3998000.0 ns) (sigma: 1345941.7 ns) (average: 3302200.0 +/- 212812.1 ns) - -Performance of RDTSC (2394.414 MHz) (using nanoseconds) - Average time per call: 9.7 ns - Clock tick period: 1.0 ns - Measured resolution: 8.0 ns (median: 9.0 ns) (sigma: 42.8 ns) (average: 9.6 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2394.414 MHz) (using nanoseconds) - Average time per call: 15.8 ns - Clock tick period: 1.0 ns - Measured resolution: 15.0 ns (median: 15.0 ns) (sigma: 60.3 ns) (average: 15.8 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2394.414 MHz) (using nanoseconds) - Average time per call: 22.1 ns - Clock tick period: 1.0 ns - Measured resolution: 18.0 ns (median: 22.0 ns) (sigma: 24.6 ns) (average: 22.1 +/- 0.1 ns) - -Performance of RDTSCP (2394.414 MHz) (using nanoseconds) - Average time per call: 15.1 ns - Clock tick period: 1.0 ns - Measured resolution: 12.0 ns (median: 15.0 ns) (sigma: 33.3 ns) (average: 15.1 +/- 0.1 ns) - -Performance of run-time selected serialising RDTSC (2394.414 MHz) (using nanoseconds) - Average time per call: 17.2 ns - Clock tick period: 1.0 ns - Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 37.7 ns) (average: 17.2 +/- 0.1 ns) - -Performance of RDTSC (2394.414 MHz) (native) - Average time per call: 8.4 ns - Clock tick period: 0.4 ns - Measured resolution: 7.5 ns (median: 8.8 ns) (sigma: 33.9 ns) (average: 8.4 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2394.414 MHz) (native) - Average time per call: 11.1 ns - Clock tick period: 0.4 ns - Measured resolution: 8.8 ns (median: 11.3 ns) (sigma: 19.0 ns) (average: 11.1 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2394.414 MHz) (native) - Average time per call: 17.7 ns - Clock tick period: 0.4 ns - Measured resolution: 15.0 ns (median: 17.5 ns) (sigma: 31.3 ns) (average: 17.7 +/- 0.1 ns) - -Performance of RDTSCP (2394.414 MHz) (native) - Average time per call: 13.0 ns - Clock tick period: 0.4 ns - Measured resolution: 8.8 ns (median: 12.5 ns) (sigma: 43.6 ns) (average: 13.0 +/- 0.1 ns) - -Performance of boost::timer (wall-clock time) - Average time per call: 195.5 ns - Clock tick period: 1.0 ns - Measured resolution: 189.0 ns (median: 192.0 ns) (sigma: 70.7 ns) (average: 195.5 +/- 0.1 ns) - -Performance of boost::timer (cpu time) - Average time per call: 195.2 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of tbb::tick_count - Average time per call: 31.5 ns - Clock tick period: n/a - Measured resolution: 30.0 ns (median: 31.0 ns) (sigma: 34.3 ns) (average: 31.5 +/- 0.1 ns) - -Performance of omp_get_wtime - Average time per call: 39.3 ns - Clock tick period: n/a - Measured resolution: 36.0 ns (median: 39.0 ns) (sigma: 40.2 ns) (average: 39.3 +/- 0.1 ns) - diff --git a/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 16.04.02 LTS - Intel Core i7-6700HQ 2.60GHz b/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 16.04.02 LTS - Intel Core i7-6700HQ 2.60GHz deleted file mode 100644 index 4eb0dc6feb88c..0000000000000 --- a/HLTrigger/Timer/test/chrono/doc/Ubuntu Linux 16.04.02 LTS - Intel Core i7-6700HQ 2.60GHz +++ /dev/null @@ -1,257 +0,0 @@ -Linux 4.10.9-041009-lowlatency x86_64 -glibc version: 2.23 -clock source: tsc -boost version: 1.58.0 -tbb version: 9.2 (interface) 9.2 (runtime) -For each timer the resolution reported is the MINIMUM (MEDIAN) (MEAN +/- its STDDEV) of the increments measured during the test. - -Performance of std::chrono::steady_clock - Average time per call: 20.4 ns - Clock tick period: 1.0 ns - Measured resolution: 19.0 ns (median: 20.0 ns) (sigma: 60.1 ns) (average: 20.4 +/- 0.1 ns) - -Performance of std::chrono::system_clock - Average time per call: 22.4 ns - Clock tick period: 1.0 ns - Measured resolution: 18.0 ns (median: 21.0 ns) (sigma: 123.6 ns) (average: 22.4 +/- 0.1 ns) - -Performance of std::chrono::high_resolution_clock - Average time per call: 20.7 ns - Clock tick period: 1.0 ns - Measured resolution: 19.0 ns (median: 21.0 ns) (sigma: 38.5 ns) (average: 20.7 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_REALTIME) - Average time per call: 88.0 ns - Clock tick period: 1.0 ns - Measured resolution: 84.0 ns (median: 87.0 ns) (sigma: 141.7 ns) (average: 88.0 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_REALTIME_COARSE) - Average time per call: 72.8 ns - Clock tick period: 1.0 ns - Measured resolution: 1000007.0 ns (median: 1000007.0 ns) (sigma: 0.5 ns) (average: 1000007.3 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_MONOTONIC) - Average time per call: 87.2 ns - Clock tick period: 1.0 ns - Measured resolution: 84.0 ns (median: 86.0 ns) (sigma: 115.3 ns) (average: 87.2 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE) - Average time per call: 75.3 ns - Clock tick period: 1.0 ns - Measured resolution: 1000007.0 ns (median: 1000007.0 ns) (sigma: 0.5 ns) (average: 1000007.3 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_MONOTONIC_RAW) - Average time per call: 88.3 ns - Clock tick period: 1.0 ns - Measured resolution: 84.0 ns (median: 86.0 ns) (sigma: 182.3 ns) (average: 88.3 +/- 0.2 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_BOOTTIME) - Average time per call: 90.3 ns - Clock tick period: 1.0 ns - Measured resolution: 87.0 ns (median: 89.0 ns) (sigma: 131.5 ns) (average: 90.3 +/- 0.1 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID) - Average time per call: 148.0 ns - Clock tick period: 1.0 ns - Measured resolution: 141.0 ns (median: 145.0 ns) (sigma: 201.6 ns) (average: 148.0 +/- 0.2 ns) - -Performance of syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID) - Average time per call: 141.0 ns - Clock tick period: 1.0 ns - Measured resolution: 134.0 ns (median: 138.0 ns) (sigma: 207.1 ns) (average: 141.0 +/- 0.2 ns) - -Performance of clock_gettime(CLOCK_REALTIME) - Average time per call: 19.5 ns - Clock tick period: 1.0 ns - Measured resolution: 17.0 ns (median: 19.0 ns) (sigma: 56.5 ns) (average: 19.5 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_REALTIME_COARSE) - Average time per call: 5.1 ns - Clock tick period: 1.0 ns - Measured resolution: 1000007.0 ns (median: 1000007.0 ns) (sigma: 0.5 ns) (average: 1000007.4 +/- 0.2 ns) - -Performance of clock_gettime(CLOCK_MONOTONIC) - Average time per call: 19.1 ns - Clock tick period: 1.0 ns - Measured resolution: 17.0 ns (median: 19.0 ns) (sigma: 48.8 ns) (average: 19.1 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_MONOTONIC_COARSE) - Average time per call: 4.6 ns - Clock tick period: 1.0 ns - Measured resolution: 1000007.0 ns (median: 1000007.0 ns) (sigma: 0.5 ns) (average: 1000007.4 +/- 0.2 ns) - -Performance of clock_gettime(CLOCK_MONOTONIC_RAW) - Average time per call: 89.0 ns - Clock tick period: 1.0 ns - Measured resolution: 85.0 ns (median: 88.0 ns) (sigma: 135.9 ns) (average: 89.0 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_BOOTTIME) - Average time per call: 94.0 ns - Clock tick period: 1.0 ns - Measured resolution: 90.0 ns (median: 93.0 ns) (sigma: 131.5 ns) (average: 94.0 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_PROCESS_CPUTIME_ID) - Average time per call: 148.7 ns - Clock tick period: 1.0 ns - Measured resolution: 142.0 ns (median: 147.0 ns) (sigma: 140.5 ns) (average: 148.7 +/- 0.1 ns) - -Performance of clock_gettime(CLOCK_THREAD_CPUTIME_ID) - Average time per call: 142.5 ns - Clock tick period: 1.0 ns - Measured resolution: 135.0 ns (median: 140.0 ns) (sigma: 193.3 ns) (average: 142.5 +/- 0.2 ns) - -Performance of gettimeofday() - Average time per call: 20.4 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 322.3 ns) (average: 1007.7 +/- 2.3 ns) - -Performance of times() (wall-clock time) - Average time per call: 42.5 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) - Average time per call: 180.8 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using double) - Average time per call: 40.0 ns - Clock tick period: n/a - Measured resolution: 9999999.8 ns (median: 9999999.8 ns) (sigma: 0.5 ns) (average: 10000000.0 +/- 0.2 ns) - -Performance of times() (cpu time) (using double) - Average time per call: 174.3 ns - Clock tick period: n/a - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (wall-clock time) (using fixed math) - Average time per call: 40.3 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of times() (cpu time) (using fixed math) - Average time per call: 175.9 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of clock() - Average time per call: 150.3 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000.0 ns (median: 1000.0 ns) (sigma: 391.9 ns) (average: 1010.5 +/- 1.0 ns) - -Performance of getrusage(RUSAGE_SELF) - Average time per call: 231.9 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000000.0 ns (median: 1000000.0 ns) (sigma: 0.1 ns) (average: 1000000.0 +/- 0.1 ns) - -Performance of getrusage(RUSAGE_THREAD) - Average time per call: 143.6 ns - Clock tick period: 1000.0 ns - Measured resolution: 1000000.0 ns (median: 1000000.0 ns) (sigma: 0.1 ns) (average: 1000000.0 +/- 0.1 ns) - -Performance of RDTSC (2591.979 MHz) (using nanoseconds) - Average time per call: 7.3 ns - Clock tick period: 1.0 ns - Measured resolution: 6.0 ns (median: 7.0 ns) (sigma: 42.4 ns) (average: 7.3 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2591.979 MHz) (using nanoseconds) - Average time per call: 13.8 ns - Clock tick period: 1.0 ns - Measured resolution: 11.0 ns (median: 13.0 ns) (sigma: 88.0 ns) (average: 13.8 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2591.979 MHz) (using nanoseconds) - Average time per call: 21.6 ns - Clock tick period: 1.0 ns - Measured resolution: 19.0 ns (median: 21.0 ns) (sigma: 73.8 ns) (average: 21.6 +/- 0.1 ns) - -Performance of RDTSCP (2591.979 MHz) (using nanoseconds) - Average time per call: 12.9 ns - Clock tick period: 1.0 ns - Measured resolution: 11.0 ns (median: 13.0 ns) (sigma: 34.9 ns) (average: 12.9 +/- 0.1 ns) - -Performance of run-time selected serialising RDTSC (2591.979 MHz) (using nanoseconds) - Average time per call: 14.2 ns - Clock tick period: 1.0 ns - Measured resolution: 11.0 ns (median: 13.0 ns) (sigma: 103.2 ns) (average: 14.2 +/- 0.1 ns) - -Performance of RDTSC (2591.979 MHz) (native) - Average time per call: 7.2 ns - Clock tick period: 0.4 ns - Measured resolution: 6.2 ns (median: 6.9 ns) (sigma: 4.0 ns) (average: 7.2 +/- 0.1 ns) - -Performance of LFENCE; RDTSC (2591.979 MHz) (native) - Average time per call: 11.0 ns - Clock tick period: 0.4 ns - Measured resolution: 9.3 ns (median: 10.8 ns) (sigma: 24.4 ns) (average: 11.0 +/- 0.1 ns) - -Performance of MFENCE; RDTSC (2591.979 MHz) (native) - Average time per call: 19.2 ns - Clock tick period: 0.4 ns - Measured resolution: 17.0 ns (median: 18.5 ns) (sigma: 52.6 ns) (average: 19.2 +/- 0.1 ns) - -Performance of RDTSCP (2591.979 MHz) (native) - Average time per call: 10.7 ns - Clock tick period: 0.4 ns - Measured resolution: 9.3 ns (median: 10.8 ns) (sigma: 34.1 ns) (average: 10.7 +/- 0.1 ns) - -Performance of run-time selected serialising RDTSC (2591.979 MHz) (native) - Average time per call: 11.2 ns - Clock tick period: 0.4 ns - Measured resolution: 9.3 ns (median: 10.8 ns) (sigma: 47.5 ns) (average: 11.2 +/- 0.1 ns) - -Performance of boost::timer (wall-clock time) - Average time per call: 196.7 ns - Clock tick period: 1.0 ns - Measured resolution: 189.0 ns (median: 195.0 ns) (sigma: 171.4 ns) (average: 196.7 +/- 0.2 ns) - -Performance of boost::timer (cpu time) - Average time per call: 199.1 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of boost::chrono::steady_clock - Average time per call: 20.4 ns - Clock tick period: 1.0 ns - Measured resolution: 19.0 ns (median: 20.0 ns) (sigma: 70.3 ns) (average: 20.4 +/- 0.1 ns) - -Performance of boost::chrono::system_clock - Average time per call: 20.2 ns - Clock tick period: 1.0 ns - Measured resolution: 18.0 ns (median: 20.0 ns) (sigma: 34.6 ns) (average: 20.2 +/- 0.1 ns) - -Performance of boost::chrono::high_resolution_clock - Average time per call: 20.3 ns - Clock tick period: 1.0 ns - Measured resolution: 18.0 ns (median: 20.0 ns) (sigma: 50.7 ns) (average: 20.3 +/- 0.1 ns) - -Performance of boost::chrono::process_real_cpu_clock - Average time per call: 176.8 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of boost::chrono::process_user_cpu_clock - Average time per call: 172.9 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of boost::chrono::process_system_cpu_clock - Average time per call: 172.3 ns - Clock tick period: 1.0 ns - Measured resolution: 10000000.0 ns (median: 10000000.0 ns) (sigma: 0.1 ns) (average: 10000000.0 +/- 0.1 ns) - -Performance of boost::chrono::thread_clock - Average time per call: 144.5 ns - Clock tick period: 1.0 ns - Measured resolution: 137.0 ns (median: 142.0 ns) (sigma: 196.0 ns) (average: 144.5 +/- 0.2 ns) - -Performance of tbb::tick_count - Average time per call: 21.5 ns - Clock tick period: n/a - Measured resolution: 19.0 ns (median: 21.0 ns) (sigma: 58.8 ns) (average: 21.5 +/- 0.1 ns) - -Performance of omp_get_wtime - Average time per call: 25.9 ns - Clock tick period: n/a - Measured resolution: 24.0 ns (median: 26.0 ns) (sigma: 64.1 ns) (average: 25.9 +/- 0.1 ns) - diff --git a/HLTrigger/Timer/test/chrono/interface/boost_timer.h b/HLTrigger/Timer/test/chrono/interface/boost_timer.h deleted file mode 100644 index a5c83a2e19f17..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/boost_timer.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifdef HAVE_BOOST_TIMER - -#ifndef boost_timer_h -#define boost_timer_h - -// C++ headers -#include - -// BOOST headers -#include - -// based on boost::timer::cpu_timer -struct clock_boost_timer_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - static boost::timer::cpu_timer timer; - auto const & elapsed = timer.elapsed(); - - return time_point( std::chrono::nanoseconds(elapsed.user + elapsed.system) ); - } - -}; - - -// based on boost::timer::cpu_timer -struct clock_boost_timer_realtime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - static boost::timer::cpu_timer timer; - auto const & elapsed = timer.elapsed(); - - return time_point( std::chrono::nanoseconds(elapsed.wall) ); - } - -}; - -#endif // boost_timer_h - -#endif // HAVE_BOOST_TIMER diff --git a/HLTrigger/Timer/test/chrono/interface/mach_absolute_time.h b/HLTrigger/Timer/test/chrono/interface/mach_absolute_time.h deleted file mode 100644 index f75cbf3de8ed7..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/mach_absolute_time.h +++ /dev/null @@ -1,41 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -#ifndef mach_absolute_time_h -#define mach_absolute_time_h - -// C++ standard headers -#include - -// Darwin system headers -#include -#include -#define HAVE_MACH_ABSOLUTE_TIME - -#include "interface/mach_absolute_time_tick.h" - - -// mach_absolute_time-based clock -struct mach_absolute_time_clock -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - uint64_t ticks = mach_absolute_time(); - rep ns = mach_absolute_time_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - - -#endif // mach_absolute_time_h - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/interface/mach_absolute_time_tick.h b/HLTrigger/Timer/test/chrono/interface/mach_absolute_time_tick.h deleted file mode 100644 index 6ea2944db5c20..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/mach_absolute_time_tick.h +++ /dev/null @@ -1,99 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -#ifndef mach_absolute_time_tick_h -#define mach_absolute_time_tick_h - -// C++ standard headers -#include - -// Darwin system headers -#include -#include -#define HAVE_MACH_ABSOLUTE_TIME - - -// mach_absolute_time ticks as clock period -// XXX should it use unsigned integers ? -struct mach_absolute_time_tick { - static const double ticks_per_second; - static const double seconds_per_tick; - static const int64_t nanoseconds_per_tick_shifted; - static const int64_t ticks_per_nanosecond_shifted; - - static int64_t to_nanoseconds(int64_t ticks) noexcept - { - // round the shifted value away from 0, like round() does - // XXX should it honor fesetround instead ? - __int128_t shifted = (__int128_t) ticks * nanoseconds_per_tick_shifted; - __int128_t ns = (shifted >> 32) + ((shifted & 0xffffffff) >= 0x80000000); - return (int64_t) ns; - } - - static double to_seconds(double ticks) noexcept - { - return ticks / ticks_per_second; - } - - static int64_t from_nanoseconds(int64_t ns) noexcept { - // round the shifted value away from 0, like round() does - // XXX should it honor fesetround instead ? - __int128_t shifted = (__int128_t) ns * ticks_per_nanosecond_shifted; - __int128_t ticks = (shifted >> 32) + ((shifted & 0xffffffff) >= 0x80000000); - return (int64_t) ticks; - } - - static int64_t from_seconds(double seconds) noexcept { - // XXX use lrint intead of lround (honors fesetround) ? - return (int64_t) std::lround(seconds * ticks_per_second); - } - - template - static - typename std::enable_if< - std::chrono::treat_as_floating_point<_ToRep>::value, - std::chrono::duration<_ToRep, _ToPeriod>>::type - to_duration(double ticks) - { - std::chrono::duration d(to_seconds(ticks)); - return std::chrono::duration_cast>( d ); - } - - template - static - typename std::enable_if< - not std::chrono::treat_as_floating_point<_ToRep>::value, - std::chrono::duration<_ToRep, _ToPeriod>>::type - to_duration(int64_t ticks) - { - std::chrono::nanoseconds d(to_nanoseconds(ticks)); - return std::chrono::duration_cast>( d ); - } - - template - static - typename std::enable_if< - std::chrono::treat_as_floating_point<_FromRep>::value, - double>::type - from_duration(std::chrono::duration<_FromRep, _FromPeriod> d) - { - double s = std::chrono::duration_cast>(d).count(); - return from_seconds(s); - } - - template - static - typename std::enable_if< - not std::chrono::treat_as_floating_point<_FromRep>::value, - int64_t>::type - from_duration(std::chrono::duration<_FromRep, _FromPeriod> d) - { - int64_t ns = std::chrono::duration_cast(d).count(); - return from_nanoseconds(ns); - } - -}; - - -#endif // mach_absolute_time_tick_h - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/interface/mach_clock_get_time.h b/HLTrigger/Timer/test/chrono/interface/mach_clock_get_time.h deleted file mode 100644 index 767f1d1fc5b0a..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/mach_clock_get_time.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef mach_clock_get_time_h -#define mach_clock_get_time_h - -#if defined(__APPLE__) || defined(__MACH__) - -// Darwin system headers -#include -#include - -#ifdef SYSTEM_CLOCK -#define HAVE_MACH_SYSTEM_CLOCK -#endif // SYSTEM_CLOCK - -#ifdef REALTIME_CLOCK -#define HAVE_MACH_REALTIME_CLOCK -#endif // REALTIME_CLOCK - -#ifdef CALENDAR_CLOCK -#define HAVE_MACH_CALENDAR_CLOCK -#endif // CALENDAR_CLOCK - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - - -#ifdef HAVE_MACH_SYSTEM_CLOCK -// based on host_get_clock_service(SYSTEM_CLOCK) and clock_get_time(...) -struct mach_system_clock -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - mach_timespec_t t; - clock_get_time(clock_port, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -private: - static clock_serv_t get_clock_port() - { - clock_serv_t clock_port; - host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_port); - return clock_port; - } - - static const clock_serv_t clock_port; -}; -#endif // HAVE_MACH_SYSTEM_CLOCK - - -#ifdef HAVE_MACH_REALTIME_CLOCK -// based on host_get_clock_service(REALTIME_CLOCK) and clock_get_time(...) -struct mach_realtime_clock -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - mach_timespec_t t; - clock_get_time(clock_port, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -private: - static clock_serv_t get_clock_port() - { - clock_serv_t clock_port; - host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &clock_port); - return clock_port; - } - - static const clock_serv_t clock_port; -}; -#endif // HAVE_MACH_REALTIME_CLOCK - - -#ifdef HAVE_MACH_CALENDAR_CLOCK -// based on host_get_clock_service(CALENDAR_CLOCK) and clock_get_time(...) -struct mach_calendar_clock -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - mach_timespec_t t; - clock_get_time(clock_port, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -private: - static clock_serv_t get_clock_port() - { - clock_serv_t clock_port; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &clock_port); - return clock_port; - } - - static const clock_serv_t clock_port; -}; -#endif // HAVE_MACH_CALENDAR_CLOCK - -#endif // defined(__APPLE__) || defined(__MACH__) - -#endif // mach_clock_get_time_h diff --git a/HLTrigger/Timer/test/chrono/interface/mach_thread_info.h b/HLTrigger/Timer/test/chrono/interface/mach_thread_info.h deleted file mode 100644 index 681d9e61bdb9e..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/mach_thread_info.h +++ /dev/null @@ -1,43 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -#ifndef mach_thread_info_h -#define mach_thread_info_h - -// C++ standard headers -#include - -// Darwin system headers -#include -#include -#define HAVE_MACH_THREAD_INFO_CLOCK - -// based on thread_info(mach_thread_self(), THREAD_BASIC_INFO, ...) -struct mach_thread_info_clock -{ - typedef std::chrono::microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - thread_local mach_port_t thread_id = mach_thread_self(); - - thread_basic_info_data_t basic_info; - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; - if (KERN_SUCCESS == thread_info(thread_id, THREAD_BASIC_INFO, (thread_info_t) & basic_info, & count)) { - return time_point( std::chrono::seconds(basic_info.user_time.seconds + basic_info.system_time.seconds) + - std::chrono::microseconds(basic_info.user_time.microseconds + basic_info.system_time.microseconds) ); - } else { - return time_point(); - } - } - -}; - -#endif // mach_thread_info_h - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/interface/native/mach_absolute_time.h b/HLTrigger/Timer/test/chrono/interface/native/mach_absolute_time.h deleted file mode 100644 index dddeb080cdd75..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/native/mach_absolute_time.h +++ /dev/null @@ -1,46 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -#ifndef native_mach_absolute_time_h -#define native_mach_absolute_time_h - -// C++ standard headers -#include - -// Darwin system headers -#include -#include -#define HAVE_MACH_ABSOLUTE_TIME - -#include "interface/mach_absolute_time_tick.h" - -// for native_duration, etc. -#include "interface/native/native.h" - -namespace native { - - // mach_absolute_time-based clock (native) - struct mach_absolute_time_clock - { - // native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static constexpr bool is_available = true; - - static time_point now() noexcept - { - rep ticks = mach_absolute_time(); - time_point time = time_point(duration(ticks)); - return time; - } - - }; - -} // namespace native - -#endif // native_mach_absolute_time_h - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/interface/native/native.h b/HLTrigger/Timer/test/chrono/interface/native/native.h deleted file mode 100644 index e8e04b80148cd..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/native/native.h +++ /dev/null @@ -1,416 +0,0 @@ -// This file is adapted from the "chrono" include file of the GNU ISO C++ Library. - -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3, -// or (at your option) any later version. - -#ifndef native_h -#define native_h - -// C++ standard headers -#include - -namespace native { - - template > - struct native_duration; - - template - struct native_time_point; - - template - struct __is_native_duration - : std::false_type - { }; - - template - struct __is_native_duration> - : std::true_type - { }; - -} // namespace native - -namespace std { - - // 20.8.2.3 specialization of common_type (for native_duration) - template - struct common_type, - native::native_duration<_Rep2, _Period>> - { - private: - typedef typename common_type<_Rep1, _Rep2>::type __cr; - - public: - typedef native::native_duration<__cr, _Period> type; - }; - - // 20.8.2.3 specialization of common_type (for native_time_point) - template - struct common_type, - native::native_time_point<_Clock, _Dur2>> - { - private: - typedef typename common_type<_Dur1, _Dur2>::type __ct; - - public: - typedef chrono::time_point<_Clock, __ct> type; - }; - -} // namespace std - - -namespace native { - - // native_duration - template - struct native_duration - { - typedef _Rep rep; - typedef _Period period; - - // construction / copy / destructor - constexpr native_duration() : __r() { } - - constexpr native_duration(native_duration const &) = default; - - template ::value and - (std::chrono::treat_as_floating_point::value or not std::chrono::treat_as_floating_point<_Rep2>::value)>::type> - constexpr explicit native_duration(_Rep2 const & __rep) : - __r(static_cast(__rep)) - { } - - /* - * FIXME keep this, or force using duration_cast to convert to/from std::chrono:duration ? - template - constexpr explicit native_duration(std::chrono::duration<_FromRep, _FromPeriod> const & __dur) : - __r(static_cast(period::from_duration(__dur))) - { } - */ - - ~native_duration() = default; - - native_duration & operator=(native_duration const &) = default; - - // observer - constexpr rep - count() const - { return __r; } - - // arithmetic - constexpr native_duration - operator+() const - { return *this; } - - constexpr native_duration - operator-() const - { return native_duration(-__r); } - - native_duration & - operator++() - { - ++__r; - return *this; - } - - native_duration - operator++(int) - { return native_duration(__r++); } - - native_duration & - operator--() - { - --__r; - return *this; - } - - native_duration - operator--(int) - { return native_duration(__r--); } - - native_duration & - operator+=(native_duration const & __d) - { - __r += __d.count(); - return *this; - } - - native_duration & - operator-=(native_duration const & __d) - { - __r -= __d.count(); - return *this; - } - - native_duration & - operator*=(rep const & __rhs) - { - __r *= __rhs; - return *this; - } - - native_duration & - operator/=(rep const & __rhs) - { - __r /= __rhs; - return *this; - } - - // DR 934. - template - typename std::enable_if::value, native_duration &>::type - operator%=(rep const & __rhs) - { - __r %= __rhs; - return *this; - } - - template - typename std::enable_if::value, native_duration &>::type - operator%=(native_duration const & __d) - { - __r %= __d.count(); - return *this; - } - - // special values - static constexpr native_duration - zero() - { return native_duration(std::chrono::duration_values::zero()); } - - static constexpr native_duration - min() - { return native_duration(std::chrono::duration_values::min()); } - - static constexpr native_duration - max() - { return native_duration(std::chrono::duration_values::max()); } - - /* - * FIXME keep this, or force using duration_cast to convert to/from std::chrono:duration ? - // convert to chrono::duration - template - operator std::chrono::duration<_ToRep, _ToPeriod>() const - { - return period::template to_duration<_ToRep, _ToPeriod>(__r); - } - */ - - private: - rep __r; - }; - - - template - constexpr native_duration::type, _Period> - operator+(const native_duration<_Rep1, _Period>& __lhs, - const native_duration<_Rep2, _Period>& __rhs) - { - typedef typename std::common_type<_Rep1, _Rep2>::type __cd; - typedef native_duration<__cd, _Period> __dur; - return __dur(__cd(__lhs.count()) + __cd(__rhs.count())); - } - - template - constexpr native_duration::type, _Period> - operator-(const native_duration<_Rep1, _Period>& __lhs, - const native_duration<_Rep2, _Period>& __rhs) - { - typedef typename std::common_type<_Rep1, _Rep2>::type __cd; - typedef native_duration<__cd, _Period> __dur; - return __dur(__cd(__lhs.count()) - __cd(__rhs.count())); - } - -} // namespace native - - -/// specialisation of duration_cast -namespace std { - namespace chrono { - - template - constexpr typename enable_if<__is_duration<_ToDur>::value, _ToDur>::type - duration_cast(native::native_duration<_Rep, _Period> const & __d) - { - return _Period::template to_duration(__d.count()); - } - - template - constexpr typename enable_if::value, _ToDur>::type - duration_cast(duration<_Rep, _Period> const & __d) - { - return _ToDur(_ToDur::period::template from_duration<_Rep, _Period>(__d)); - } - - } // namespace -} // namespace - - -namespace native { - - /// native_time_point - template - struct native_time_point - { - typedef _Clock clock; - typedef _Dur duration; - typedef typename duration::rep rep; - typedef typename duration::period period; - - constexpr native_time_point() : __d(duration::zero()) - { } - - constexpr explicit native_time_point(duration const & __dur) : - __d(__dur) - { } - - // conversions - template - constexpr native_time_point(native_time_point const & __t) : - __d(__t.time_since_epoch()) - { } - - // observer - constexpr duration - time_since_epoch() const - { - return __d; - } - - // arithmetic - native_time_point & - operator+=(duration const & __dur) - { - __d += __dur; - return *this; - } - - native_time_point & - operator-=(duration const & __dur) - { - __d -= __dur; - return *this; - } - - // special values - static constexpr native_time_point - min() - { return native_time_point(duration::min()); } - - static constexpr native_time_point - max() - { return native_time_point(duration::max()); } - - private: - duration __d; - }; - - /* - /// time_point_cast - template - constexpr typename std::enable_if<__is_duration<_ToDur>::value, - native_time_point<_Clock, _ToDur>>::type - time_point_cast(const native_time_point<_Clock, _Dur>& __t) - { - typedef native_time_point<_Clock, _ToDur> __time_point; - return __time_point(duration_cast<_ToDur>(__t.time_since_epoch())); - } - - - template - constexpr native_time_point<_Clock, - typename std::common_type<_Dur1, duration<_Rep2, _Period2>>::type> - operator+(const native_time_point<_Clock, _Dur1>& __lhs, - const duration<_Rep2, _Period2>& __rhs) - { - typedef duration<_Rep2, _Period2> __dur2; - typedef typename std::common_type<_Dur1,__dur2>::type __ct; - typedef native_time_point<_Clock, __ct> __time_point; - return __time_point(__lhs.time_since_epoch() + __rhs); - } - - template - constexpr native_time_point<_Clock, - typename std::common_type, _Dur2>::type> - operator+(const duration<_Rep1, _Period1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { - typedef duration<_Rep1, _Period1> __dur1; - typedef typename std::common_type<__dur1,_Dur2>::type __ct; - typedef native_time_point<_Clock, __ct> __time_point; - return __time_point(__rhs.time_since_epoch() + __lhs); - } - */ - - template - constexpr native_time_point<_Clock, typename std::common_type<_Dur1, native_duration<_Rep2, _Period2>>::type> - operator-(const native_time_point<_Clock, _Dur1>& __lhs, - const native_duration<_Rep2, _Period2>& __rhs) - { - typedef native_duration<_Rep2, _Period2> __dur2; - typedef typename std::common_type<_Dur1,__dur2>::type __ct; - typedef native_time_point<_Clock, __ct> __time_point; - return __time_point(__lhs.time_since_epoch() -__rhs); - } - - template - constexpr native_time_point<_Clock, typename std::common_type<_Dur1, std::chrono::duration<_Rep2, _Period2>>::type> - operator-(const native_time_point<_Clock, _Dur1>& __lhs, - const std::chrono::duration<_Rep2, _Period2>& __rhs) - { - typedef std::chrono::duration<_Rep2, _Period2> __dur2; - typedef typename std::common_type<_Dur1,__dur2>::type __ct; - typedef native_time_point<_Clock, __ct> __time_point; - return __time_point(__lhs.time_since_epoch() -__rhs); - } - - template - constexpr typename std::common_type<_Dur1, _Dur2>::type - operator-(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } - - /* - template - constexpr bool - operator==(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } - - template - constexpr bool - operator!=(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return !(__lhs == __rhs); } - - template - constexpr bool - operator<(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } - - template - constexpr bool - operator<=(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return !(__rhs < __lhs); } - - template - constexpr bool - operator>(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return __rhs < __lhs; } - - template - constexpr bool - operator>=(const native_time_point<_Clock, _Dur1>& __lhs, - const native_time_point<_Clock, _Dur2>& __rhs) - { return !(__lhs < __rhs); } - */ - -} // namespace native - -#endif //native_h diff --git a/HLTrigger/Timer/test/chrono/interface/native/x86_tsc_clock.h b/HLTrigger/Timer/test/chrono/interface/native/x86_tsc_clock.h deleted file mode 100644 index d8381fd24bdbb..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/native/x86_tsc_clock.h +++ /dev/null @@ -1,136 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#ifndef native_x86_tsc_clock_h -#define native_x86_tsc_clock_h - -// C++ standard headers -#include - -// for rdtscp, rdtscp, lfence, mfence -#include - -#include "interface/x86_tsc.h" -#include "interface/x86_tsc_tick.h" -#include "interface/native/native.h" - -namespace native { - - // TSC-based clock with native duration, using rdtsc (non-serialising) - struct clock_rdtsc - { - // std::chrono-like native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef native_time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - rep ticks = rdtsc(); - duration d(ticks); - time_point t(d); - return t; - } - }; - - - // TSC-based clock with native duration, using lfence as serialising instruction - struct clock_rdtsc_lfence - { - // std::chrono-like native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef native_time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - _mm_lfence(); - rep ticks = rdtsc(); - duration d(ticks); - time_point t(d); - return t; - } - }; - - - // TSC-based clock with native duration, using mfence as serialising instruction - struct clock_rdtsc_mfence - { - // std::chrono-like native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef native_time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - _mm_mfence(); - rep ticks = rdtsc(); - duration d(ticks); - time_point t(d); - return t; - } - }; - - - // TSC-based clock with native duration, using rdtscp as serialising instruction - struct clock_rdtscp - { - // std::chrono-like native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef native_time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - unsigned int id; - rep ticks = rdtscp(& id); - duration d(ticks); - time_point t(d); - return t; - } - }; - - - // TSC-based clock, determining at run-time the best strategy to serialise the reads from the TSC - struct clock_serialising_rdtsc - { - // std::chrono-like native interface - typedef native_duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef native_time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - rep ticks = serialising_rdtsc(); - duration d(ticks); - time_point t(d); - return t; - } - }; - - -} // namespace native - -#endif // native_x86_tsc_clock_h - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/interface/omp_get_wtime.h b/HLTrigger/Timer/test/chrono/interface/omp_get_wtime.h deleted file mode 100644 index dbc9458e75262..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/omp_get_wtime.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __clang__ -// CLANG does not support OpenMP - -#ifndef omp_get_wtime_h -#define omp_get_wtime_h - -// C++ standard headers -#include - -// OpenMP headers -#include - -// OpenMP based clock -struct clock_omp_get_wtime -{ - // std::chrono interface - typedef std::chrono::duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - double seconds = omp_get_wtime(); - return time_point(duration( seconds )); - } -}; - -#endif // omp_get_wtime_h - -#endif // ! __clang__ diff --git a/HLTrigger/Timer/test/chrono/interface/posix_clock.h b/HLTrigger/Timer/test/chrono/interface/posix_clock.h deleted file mode 100644 index e456fd3fe2a43..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_clock.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef posix_clock_h -#define posix_clock_h - -// C++ standard headers -#include - -// POSIX standard headers -#include - -// based on clock() -struct clock_clock -{ - typedef std::chrono::duration> duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - clock_t time = clock(); - return time_point( duration( time )); - } - -}; - -#endif // posix_clock_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_clock_gettime.h b/HLTrigger/Timer/test/chrono/interface/posix_clock_gettime.h deleted file mode 100644 index 346171585a168..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_clock_gettime.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef posix_clock_gettime_h -#define posix_clock_gettime_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// check available capabilities -#if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS >= 0)) - -#define HAVE_POSIX_CLOCK_REALTIME - -#if (defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0)) -#define HAVE_POSIX_CLOCK_MONOTONIC -#endif // _POSIX_MONOTONIC_CLOCK - -#if (defined(_POSIX_CPUTIME) && (_POSIX_CPUTIME >= 0)) -#define HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID -#endif // _POSIX_CPUTIME - -#if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) -#define HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID -#endif // _POSIX_THREAD_CPUTIME - -#ifdef __linux__ -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -#define HAVE_POSIX_CLOCK_MONOTONIC_RAW -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) -#define HAVE_POSIX_CLOCK_REALTIME_COARSE -#define HAVE_POSIX_CLOCK_MONOTONIC_COARSE -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) -#define HAVE_POSIX_CLOCK_BOOTTIME -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) -#endif // __linux__ - -#endif // _POSIX_TIMERS - -#ifdef HAVE_POSIX_CLOCK_REALTIME -// based on clock_gettime(CLOCK_REALTIME, ...) -struct clock_gettime_realtime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_REALTIME, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_REALTIME - - -#ifdef HAVE_POSIX_CLOCK_REALTIME_COARSE -// based on clock_gettime(CLOCK_REALTIME_COARSE, ...) -struct clock_gettime_realtime_coarse -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_REALTIME_COARSE, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_REALTIME_COARSE - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC -// based on clock_gettime(CLOCK_MONOTONIC, ...) -struct clock_gettime_monotonic -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_MONOTONIC, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_MONOTONIC - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_COARSE -// based on clock_gettime(CLOCK_MONOTONIC_COARSE, ...) -struct clock_gettime_monotonic_coarse -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_MONOTONIC_COARSE, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_MONOTONIC_COARSE - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_RAW -// based on clock_gettime(CLOCK_MONOTONIC_RAW, ...) -struct clock_gettime_monotonic_raw -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static inline time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_MONOTONIC_RAW, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_MONOTONIC_RAW - - -#ifdef HAVE_POSIX_CLOCK_BOOTTIME -// based on clock_gettime(CLOCK_BOOTTIME, ...) -struct clock_gettime_boottime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static inline time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_BOOTTIME, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_BOOTTIME - - -#ifdef HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID -// based on clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) -struct clock_gettime_process_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; // FIXME can this be considered "steady" ? - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID - - -#ifdef HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID -// based on clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) -struct clock_gettime_thread_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; // FIXME can this be considered "steady" ? - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID - -#endif // posix_clock_gettime_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_getrusage.h b/HLTrigger/Timer/test/chrono/interface/posix_getrusage.h deleted file mode 100644 index 211d55add0e4a..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_getrusage.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef posix_getrusage_h -#define posix_getrusage_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// based on getrusage(RUSAGE_SELF, ...) -struct clock_getrusage_self -{ - typedef std::chrono::microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - rusage ru; - getrusage(RUSAGE_SELF, & ru); // XXX handle possible errors - - return time_point( std::chrono::microseconds( - ((int64_t) ru.ru_utime.tv_sec + (int64_t) ru.ru_stime.tv_sec) * 1000000ll + - (int64_t) ru.ru_utime.tv_usec + (int64_t) ru.ru_stime.tv_usec) ); - } - -}; - -#ifdef __linux__ -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) -#define HAVE_POSIX_CLOCK_GETRUSAGE_THREAD 1 - -// based on getrusage(RUSAGE_THREAD, ...) -struct clock_getrusage_thread -{ - typedef std::chrono::microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - rusage ru; - getrusage(RUSAGE_THREAD, & ru); // XXX handle possible errors - - return time_point( std::chrono::microseconds( - ((int64_t) ru.ru_utime.tv_sec + (int64_t) ru.ru_stime.tv_sec) * 1000000ll + - (int64_t) ru.ru_utime.tv_usec + (int64_t) ru.ru_stime.tv_usec) ); - } - -}; - -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) -#endif // defined(__linux__) - -#endif // posix_getrusage_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_gettimeofday.h b/HLTrigger/Timer/test/chrono/interface/posix_gettimeofday.h deleted file mode 100644 index 471daa798ffb1..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_gettimeofday.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef posix_gettimeofday_h -#define posix_gettimeofday_h - -// C++ standard headers -#include - -// POSIX standard headers -#include - -// based on gettimeofday(...) -struct clock_gettimeofday -{ - typedef std::chrono::microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static time_point now() noexcept - { - timeval t; - gettimeofday(&t, nullptr); // XXX handle possible errors - - return time_point( std::chrono::microseconds((int64_t) t.tv_sec * 1000000ll + (int64_t) t.tv_usec) ); - } - -}; - -#endif // posix_gettimeofday_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_times.h b/HLTrigger/Timer/test/chrono/interface/posix_times.h deleted file mode 100644 index 659d1d91310b4..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_times.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef posix_times_h -#define posix_times_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// Tested on Intel Core i5 with GCC 4.7.2 -// -// (time * 1000000000 / ticks_per_second) adds an overhead of almost 20 ns per call, so we pre-compute 1000000000 / ticks_per_second -// -// use a long for the ratio, check if it is accurate or not, and only if it is accurate use it instead of doing the division. -// When accurate, (time * nanoseconds_per_tick) can be done basically for free - - -// define macros to give hints on branch prediction -#ifndef likely -#define likely(cond) __builtin_expect(cond, 1) -#endif // likely - -#ifndef unlikely -#define unlikely(cond) __builtin_expect(cond, 0) -#endif // unlikely - - -// based on times() -struct clock_times_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const long ticks_per_second = sysconf(_SC_CLK_TCK); - static const long nanoseconds_per_tick = 1000000000l / ticks_per_second; - static const bool accurate = ((1000000000l % ticks_per_second) == 0); - - tms cputime; - times(& cputime); - clock_t time = cputime.tms_utime + cputime.tms_stime; - - int64_t ns = likely(accurate) ? time * nanoseconds_per_tick : time * 1000000000l / ticks_per_second; - return time_point( duration( ns )); - } - -}; - -// based on times() -struct clock_times_realtime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const long ticks_per_second = sysconf(_SC_CLK_TCK); - static const long nanoseconds_per_tick = 1000000000l / ticks_per_second; - static const bool accurate = ((1000000000l % ticks_per_second) == 0); - - clock_t time; -#ifdef __linux__ - time = times(nullptr); -#else - tms cputime; - time = times(& cputime); -#endif // __linux__ - - int64_t ns = likely(accurate) ? time * nanoseconds_per_tick : time * 1000000000l / ticks_per_second; - return time_point( duration( ns )); - } - -}; - -#endif // posix_times_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_times_d.h b/HLTrigger/Timer/test/chrono/interface/posix_times_d.h deleted file mode 100644 index 78e7dfe4f8fa1..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_times_d.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef posix_times_d_h -#define posix_times_d_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// based on times() -struct clock_times_cputime_d -{ - typedef std::chrono::duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const double ticks_per_second = sysconf(_SC_CLK_TCK); - static const double seconds_per_tick = 1. / ticks_per_second; - - tms cputime; - times(& cputime); - clock_t time = cputime.tms_utime + cputime.tms_stime; - - return time_point( duration( (double) time * seconds_per_tick ) ); - } - -}; - -// based on times() -struct clock_times_realtime_d -{ - typedef std::chrono::duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const double ticks_per_second = sysconf(_SC_CLK_TCK); - static const double seconds_per_tick = 1. / ticks_per_second; - - clock_t time; -#ifdef __linux__ - time = times(nullptr); -#else - tms cputime; - time = times(& cputime); -#endif // __linux__ - - return time_point( duration( (double) time * seconds_per_tick ) ); - } - -}; - - -#endif // posix_times_d_h diff --git a/HLTrigger/Timer/test/chrono/interface/posix_times_f.h b/HLTrigger/Timer/test/chrono/interface/posix_times_f.h deleted file mode 100644 index 59bed900514fc..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/posix_times_f.h +++ /dev/null @@ -1,89 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// 128-bit wide int is only available on x86 - -#ifndef posix_times_f_h -#define posix_times_f_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// Tested on Intel Core i5 with GCC 4.7.2 -// -// (time * 1000000000 / ticks_per_second) adds an overhead of almost 20 ns per call, so we pre-compute 1000000000 / ticks_per_second -// -// use a long long for the ratio, shifted left by 32 bits to store extra precision; -// then use a 128-bit wide multiplication instead of the division, and shift away the extra precision. -// Adds a very small overhead (order of 1-2 ns) with respect to the best case above - - -// define macros to give hints on branch prediction -#ifndef likely -#define likely(cond) __builtin_expect(cond, 1) -#endif // likely - -#ifndef unlikely -#define unlikely(cond) __builtin_expect(cond, 0) -#endif // unlikely - - -// based on times() -struct clock_times_cputime_f -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const long ticks_per_second = sysconf(_SC_CLK_TCK); - static const int64_t nanoseconds_per_tick = (1000000000ull << 32) / ticks_per_second; - - tms cputime; - times(& cputime); - clock_t time = cputime.tms_utime + cputime.tms_stime; - - __int128_t ns = ((__int128_t) time * nanoseconds_per_tick) >> 32; - return time_point( duration( ns )); - } - -}; - -// based on times() -struct clock_times_realtime_f -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static inline time_point now() noexcept - { - static const long ticks_per_second = sysconf(_SC_CLK_TCK); - static const int64_t nanoseconds_per_tick = (1000000000ull << 32) / ticks_per_second; - - clock_t time; -#ifdef __linux__ - time = times(nullptr); -#else - tms cputime; - time = times(& cputime); -#endif // __linux__ - - __int128_t ns = ((__int128_t) time * nanoseconds_per_tick) >> 32; - return time_point( duration( ns )); - } - -}; - -#endif // posix_times_f_h - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/interface/syscall_clock_gettime.h b/HLTrigger/Timer/test/chrono/interface/syscall_clock_gettime.h deleted file mode 100644 index 976205c2db780..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/syscall_clock_gettime.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef syscall_clock_gettime_h -#define syscall_clock_gettime_h - -// C++ standard headers -#include - -// POSIX standard headers -#include -#include - -// check available capabilities -#ifdef __linux__ -#include -#include - -#define HAVE_SYSCALL_CLOCK_REALTIME -#define HAVE_SYSCALL_CLOCK_MONOTONIC -#define HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID -#define HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -#define HAVE_SYSCALL_CLOCK_MONOTONIC_RAW -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) -#define HAVE_SYSCALL_CLOCK_REALTIME_COARSE -#define HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) -#define HAVE_SYSCALL_CLOCK_BOOTTIME -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) - -#ifdef HAVE_SYSCALL_CLOCK_REALTIME -// based on syscall(SYS_clock_gettime, CLOCK_REALTIME, ...) -struct clock_syscall_realtime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_REALTIME, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_REALTIME - - -#ifdef HAVE_SYSCALL_CLOCK_REALTIME_COARSE -// based on syscall(SYS_clock_gettime, CLOCK_REALTIME_COARSE, ...) -struct clock_syscall_realtime_coarse -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_REALTIME_COARSE, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_REALTIME_COARSE - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC -// based on syscall(SYS_clock_gettime, CLOCK_MONOTONIC, ...) -struct clock_syscall_monotonic -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE -// based on syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, ...) -struct clock_syscall_monotonic_coarse -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_RAW -// based on syscall(SYS_clock_gettime, CLOCK_MONOTONIC_RAW, ...) -struct clock_syscall_monotonic_raw -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static inline time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_MONOTONIC_RAW, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_RAW - - -#ifdef HAVE_SYSCALL_CLOCK_BOOTTIME -// based on syscall(SYS_clock_gettime, CLOCK_BOOTTIME, ...) -struct clock_syscall_boottime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = true; - static const bool is_available; - - static inline time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_BOOTTIME, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_BOOTTIME - - -#ifdef HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID -// based on syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID, ...) -struct clock_syscall_process_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; // FIXME can this be considered "steady" ? - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID - - -#ifdef HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID -// based on syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID, ...) -struct clock_syscall_thread_cputime -{ - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; // FIXME can this be considered "steady" ? - static const bool is_available; - - static time_point now() noexcept - { - timespec t; - syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &t); - - return time_point( std::chrono::seconds(t.tv_sec) + std::chrono::nanoseconds(t.tv_nsec) ); - } - -}; -#endif // HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID - -#endif // __linux__ - -#endif // syscall_clock_gettime_h diff --git a/HLTrigger/Timer/test/chrono/interface/tbb_tick_count.h b/HLTrigger/Timer/test/chrono/interface/tbb_tick_count.h deleted file mode 100644 index 86b0278fa1b4e..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/tbb_tick_count.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifdef HAVE_TBB - -#ifndef tbb_tick_count_h -#define tbb_tick_count_h - -// C++ standard headers -#include - -// TBB headers -#include - -// TBB tick_count based clock -struct clock_tbb_tick_count -{ - // std::chrono interface - typedef std::chrono::duration duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static constexpr bool is_steady = false; - - static const tbb::tick_count epoch; - - static time_point now() noexcept - { - // TBB tick_count does not expose its internal representation, only the the conversion of intervals to and from seconds - tbb::tick_count time = tbb::tick_count::now(); - tbb::tick_count::interval_t ticks = time - epoch; - return time_point(duration( ticks.seconds() )); - } - -}; - - -namespace std { - namespace chrono { - - /// duration_values - template <> - struct duration_values - { - static const tbb::tick_count::interval_t - zero() - { return tbb::tick_count::interval_t(); } - - // this is not well-defined, since the tick duration is only known at run-time - // 1.e9 seconds should be a safe value - static const tbb::tick_count::interval_t - max() - { return tbb::tick_count::interval_t(1.e9); } - - // this is not well-defined, since the tick duration is only known at run-time - // -1.e9 seconds should be a safe value - static const tbb::tick_count::interval_t - min() - { return tbb::tick_count::interval_t(-1.e9); } - }; - - } -} - -#endif // tbb_tick_count_h - -#endif // HAVE_TBB diff --git a/HLTrigger/Timer/test/chrono/interface/x86_tsc.h b/HLTrigger/Timer/test/chrono/interface/x86_tsc.h deleted file mode 100644 index d58f831b946d5..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/x86_tsc.h +++ /dev/null @@ -1,71 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#ifndef x86_tsc_h -#define x86_tsc_h - -#include - -#if defined __clang__ -// clang does not define the __rdtsc and __rdtscp intrinsic, although it does -// define __builtin_readcyclecounter() which is a likely replacement for __rdtsc() - -extern inline uint64_t rdtsc(void) -{ - uint32_t eax, edx; - asm("rdtsc" : "=a" (eax), "=d" (edx)); - return ((uint64_t) edx << 32) | (uint64_t) eax; -} - -extern inline uint64_t rdtscp(uint32_t *aux) -{ - uint32_t eax, edx; - uint64_t rcx; - asm("rdtscp" : "=a" (eax), "=d" (edx), "=c" (rcx)); - *aux = rcx; - return ((uint64_t) edx << 32) | (uint64_t) eax; -} - -#elif defined __GNUC__ -// GCC and ICC provide intrinsics for rdtsc and rdtscp -#include - -extern inline uint64_t rdtsc(void) -{ - return __rdtsc(); -} - -extern inline uint64_t rdtscp(uint32_t *aux) -{ - return __rdtscp(aux); -} - -#else -# error "Unsupported compiler" -#endif // __clang__ / __GNUC__ - -bool has_tsc(); -bool has_rdtscp(); -bool has_invariant_tsc(); -bool tsc_allowed(); - -double calibrate_tsc_hz(); - - -// IFUNC support requires GCC >= 4.6.0 and GLIBC >= 2.11.1 -#if ( defined __GNUC__ && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ) \ - and ( defined __GLIBC__ && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 11) ) - -// processor specific serialising access to the TSC -extern uint64_t serialising_rdtsc(void); - -#else - -// processor specific serialising access to the TSC -extern uint64_t (*serialising_rdtsc)(void); - -#endif // IFUNC support - -#endif // x86_tsc_h - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/interface/x86_tsc_clock.h b/HLTrigger/Timer/test/chrono/interface/x86_tsc_clock.h deleted file mode 100644 index 7ec8954ce0e06..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/x86_tsc_clock.h +++ /dev/null @@ -1,131 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#ifndef x86_tsc_clock_h -#define x86_tsc_clock_h - -// C++ standard headers -#include - -// for rdtscp, rdtscp, lfence, mfence -#include - -// for tsc_tick, etc. -#include "interface/x86_tsc.h" -#include "interface/x86_tsc_tick.h" - -// TSC-based clock, using rdtsc (non-serialising) -struct clock_rdtsc -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - int64_t ticks = rdtsc(); - rep ns = tsc_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - - -// TSC-based clock, using lfence as serialising instruction -struct clock_rdtsc_lfence -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - _mm_lfence(); - int64_t ticks = rdtsc(); - rep ns = tsc_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - -// TSC-based clock, using mfence as serialising instruction -struct clock_rdtsc_mfence -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - _mm_mfence(); - int64_t ticks = rdtsc(); - rep ns = tsc_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - - -// TSC-based clock, using rdtscp as serialising instruction -struct clock_rdtscp -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - unsigned int id; - int64_t ticks = rdtscp(& id); - rep ns = tsc_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - - -// TSC-based clock, determining at run-time the best strategy to serialise the reads from the TSC -struct clock_serialising_rdtsc -{ - // std::chrono interface - typedef std::chrono::nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef std::chrono::time_point time_point; - - static const bool is_steady; - static const bool is_available; - - static time_point now() noexcept - { - int64_t ticks = serialising_rdtsc(); - rep ns = tsc_tick::to_nanoseconds(ticks); - time_point time = time_point(duration(ns)); - return time; - } -}; - - -#endif // x86_tsc_clock_h - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/interface/x86_tsc_tick.h b/HLTrigger/Timer/test/chrono/interface/x86_tsc_tick.h deleted file mode 100644 index fa5c6194aff7f..0000000000000 --- a/HLTrigger/Timer/test/chrono/interface/x86_tsc_tick.h +++ /dev/null @@ -1,95 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#ifndef x86_tsc_tick_h -#define x86_tsc_tick_h - -// C++ standard headers -#include -#include - - -// TSC ticks as clock period -// XXX should it use unsigned integers ? -struct tsc_tick { - static const double ticks_per_second; - static const double seconds_per_tick; - static const int64_t nanoseconds_per_tick_shifted; - static const int64_t ticks_per_nanosecond_shifted; - - static int64_t to_nanoseconds(int64_t ticks) noexcept - { - // round the shifted value away from 0, like round() does - // XXX should it honor fesetround instead ? - __int128_t shifted = (__int128_t) ticks * nanoseconds_per_tick_shifted; - __int128_t ns = (shifted >> 32) + ((shifted & 0xffffffff) >= 0x80000000); - return (int64_t) ns; - } - - static double to_seconds(double ticks) noexcept - { - return ticks / ticks_per_second; - } - - static int64_t from_nanoseconds(int64_t ns) noexcept { - // round the shifted value away from 0, like round() does - // XXX should it honor fesetround instead ? - __int128_t shifted = (__int128_t) ns * ticks_per_nanosecond_shifted; - __int128_t ticks = (shifted >> 32) + ((shifted & 0xffffffff) >= 0x80000000); - return (int64_t) ticks; - } - - static int64_t from_seconds(double seconds) noexcept { - // XXX use lrint intead of lround (honors fesetround) ? - return (int64_t) std::lround(seconds * ticks_per_second); - } - - template - static - typename std::enable_if< - std::chrono::treat_as_floating_point<_ToRep>::value, - std::chrono::duration<_ToRep, _ToPeriod>>::type - to_duration(double ticks) - { - std::chrono::duration d(to_seconds(ticks)); - return std::chrono::duration_cast>( d ); - } - - template - static - typename std::enable_if< - not std::chrono::treat_as_floating_point<_ToRep>::value, - std::chrono::duration<_ToRep, _ToPeriod>>::type - to_duration(int64_t ticks) - { - std::chrono::nanoseconds d(to_nanoseconds(ticks)); - return std::chrono::duration_cast>( d ); - } - - template - static - typename std::enable_if< - std::chrono::treat_as_floating_point<_FromRep>::value, - double>::type - from_duration(std::chrono::duration<_FromRep, _FromPeriod> d) - { - double s = std::chrono::duration_cast>(d).count(); - return from_seconds(s); - } - - template - static - typename std::enable_if< - not std::chrono::treat_as_floating_point<_FromRep>::value, - int64_t>::type - from_duration(std::chrono::duration<_FromRep, _FromPeriod> d) - { - int64_t ns = std::chrono::duration_cast(d).count(); - return from_nanoseconds(ns); - } -}; - - -#endif // x86_tsc_tick_h - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/src/mach_absolute_time.cc b/HLTrigger/Timer/test/chrono/src/mach_absolute_time.cc deleted file mode 100644 index 83626d3fa5785..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/mach_absolute_time.cc +++ /dev/null @@ -1,41 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -// C++ standard headers -#include -#include - -// Darwin system headers -#include -#include - -#include "interface/mach_absolute_time.h" - -// read the calibration of mach_absolute_time -static -double calibrate_ticks_per_second() { - mach_timebase_info_data_t timebase_info; - mach_timebase_info(& timebase_info); - return 1.e9 * timebase_info.denom / timebase_info.numer; -} - -static -int64_t calibrate_nanoseconds_per_tick_shifted() { - mach_timebase_info_data_t timebase_info; - mach_timebase_info(& timebase_info); - return (1ll << 32) * timebase_info.numer / timebase_info.denom; -} - -static -int64_t calibrate_ticks_per_nanosecond_shifted() { - mach_timebase_info_data_t timebase_info; - mach_timebase_info(& timebase_info); - return (1ll << 32) * timebase_info.denom / timebase_info.numer; -} - -const double mach_absolute_time_tick::ticks_per_second = calibrate_ticks_per_second(); -const double mach_absolute_time_tick::seconds_per_tick = 1. / mach_absolute_time_tick::ticks_per_second; -const int64_t mach_absolute_time_tick::nanoseconds_per_tick_shifted = calibrate_nanoseconds_per_tick_shifted(); -const int64_t mach_absolute_time_tick::ticks_per_nanosecond_shifted = calibrate_ticks_per_nanosecond_shifted(); - - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/src/mach_clock_get_time.cc b/HLTrigger/Timer/test/chrono/src/mach_clock_get_time.cc deleted file mode 100644 index f8f2e9cba7dcf..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/mach_clock_get_time.cc +++ /dev/null @@ -1,25 +0,0 @@ -#if defined(__APPLE__) || defined(__MACH__) - -// Darwin system headers -#include -#include - -#include "interface/mach_clock_get_time.h" - -#ifdef HAVE_MACH_SYSTEM_CLOCK -// based on host_get_clock_service(SYSTEM_CLOCK) and clock_get_time(...) -const clock_serv_t mach_system_clock::clock_port = mach_system_clock::get_clock_port(); -#endif // HAVE_MACH_SYSTEM_CLOCK - -#ifdef HAVE_MACH_REALTIME_CLOCK -// based on host_get_clock_service(REALTIME_CLOCK) and clock_get_time(...) -const clock_serv_t mach_realtime_clock::clock_port = mach_realtime_clock::get_clock_port(); -#endif // HAVE_MACH_REALTIME_CLOCK - - -#ifdef HAVE_MACH_CALENDAR_CLOCK -// based on host_get_clock_service(CALENDAR_CLOCK) and clock_get_time(...) -const clock_serv_t mach_calendar_clock::clock_port = mach_calendar_clock::get_clock_port(); -#endif // HAVE_MACH_CALENDAR_CLOCK - -#endif // defined(__APPLE__) || defined(__MACH__) diff --git a/HLTrigger/Timer/test/chrono/src/native/x86_tsc_clock.cc b/HLTrigger/Timer/test/chrono/src/native/x86_tsc_clock.cc deleted file mode 100644 index eebc33d123369..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/native/x86_tsc_clock.cc +++ /dev/null @@ -1,26 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#include "interface/x86_tsc.h" -#include "interface/native/x86_tsc_clock.h" - -namespace native { - - const bool clock_rdtsc::is_available = has_tsc() and tsc_allowed(); - const bool clock_rdtsc::is_steady = has_invariant_tsc(); - - const bool clock_rdtsc_lfence::is_available = has_tsc() and tsc_allowed(); - const bool clock_rdtsc_lfence::is_steady = has_invariant_tsc(); - - const bool clock_rdtsc_mfence::is_available = has_tsc() and tsc_allowed(); - const bool clock_rdtsc_mfence::is_steady = has_invariant_tsc(); - - const bool clock_rdtscp::is_available = has_rdtscp() and tsc_allowed(); - const bool clock_rdtscp::is_steady = has_invariant_tsc(); - - const bool clock_serialising_rdtsc::is_available = has_tsc() and tsc_allowed(); - const bool clock_serialising_rdtsc::is_steady = has_invariant_tsc(); - -} // namespace native - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/src/posix_clock_gettime.cc b/HLTrigger/Timer/test/chrono/src/posix_clock_gettime.cc deleted file mode 100644 index b78d19fbc0ad8..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/posix_clock_gettime.cc +++ /dev/null @@ -1,42 +0,0 @@ -#include "interface/posix_clock_gettime.h" - -#include - -#ifdef HAVE_POSIX_CLOCK_REALTIME -const bool clock_gettime_realtime::is_available = (sysconf(_SC_TIMERS) > 0); -#endif // HAVE_POSIX_CLOCK_REALTIME - - -#ifdef HAVE_POSIX_CLOCK_REALTIME_COARSE -const bool clock_gettime_realtime_coarse::is_available = true; -#endif // HAVE_POSIX_CLOCK_REALTIME_COARSE - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC -const bool clock_gettime_monotonic::is_available = (sysconf(_SC_MONOTONIC_CLOCK) > 0); -#endif // HAVE_POSIX_CLOCK_MONOTONIC - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_COARSE -const bool clock_gettime_monotonic_coarse::is_available = true; -#endif // HAVE_POSIX_CLOCK_MONOTONIC_COARSE - - -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_RAW -const bool clock_gettime_monotonic_raw::is_available = true; -#endif // HAVE_POSIX_CLOCK_MONOTONIC_RAW - - -#ifdef HAVE_POSIX_CLOCK_BOOTTIME -const bool clock_gettime_boottime::is_available = true; -#endif // HAVE_POSIX_CLOCK_BOOTTIME - - -#ifdef HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID -const bool clock_gettime_process_cputime::is_available = (sysconf(_SC_CPUTIME) > 0); -#endif // HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID - - -#ifdef HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID -const bool clock_gettime_thread_cputime::is_available = (sysconf(_SC_THREAD_CPUTIME) > 0); -#endif // HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID diff --git a/HLTrigger/Timer/test/chrono/src/syscall_clock_gettime.cc b/HLTrigger/Timer/test/chrono/src/syscall_clock_gettime.cc deleted file mode 100644 index 9bcf058263cd0..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/syscall_clock_gettime.cc +++ /dev/null @@ -1,40 +0,0 @@ -#include "interface/syscall_clock_gettime.h" - -#ifdef HAVE_SYSCALL_CLOCK_REALTIME -const bool clock_syscall_realtime::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_REALTIME - - -#ifdef HAVE_SYSCALL_CLOCK_REALTIME_COARSE -const bool clock_syscall_realtime_coarse::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_REALTIME_COARSE - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC -const bool clock_syscall_monotonic::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE -const bool clock_syscall_monotonic_coarse::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE - - -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_RAW -const bool clock_syscall_monotonic_raw::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_RAW - - -#ifdef HAVE_SYSCALL_CLOCK_BOOTTIME -const bool clock_syscall_boottime::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_BOOTTIME - - -#ifdef HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID -const bool clock_syscall_process_cputime::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID - - -#ifdef HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID -const bool clock_syscall_thread_cputime::is_available = true; -#endif // HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID diff --git a/HLTrigger/Timer/test/chrono/src/tbb_tick_count.cc b/HLTrigger/Timer/test/chrono/src/tbb_tick_count.cc deleted file mode 100644 index 21f3729aa5ff3..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/tbb_tick_count.cc +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef HAVE_TBB - -#include "interface/tbb_tick_count.h" - -const tbb::tick_count clock_tbb_tick_count::epoch = tbb::tick_count::now(); - -#endif // HAVE_TBB diff --git a/HLTrigger/Timer/test/chrono/src/x86_tsc.cc b/HLTrigger/Timer/test/chrono/src/x86_tsc.cc deleted file mode 100644 index 85b9d573c02dc..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/x86_tsc.cc +++ /dev/null @@ -1,205 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -// C++ standard headers -#include -#include - -// for usleep -#include - -// for rdtsc, rdtscp, lfence, mfence, cpuid -#include -#include - -#ifdef __linux__ -#include -#include -#endif // __linux__ - -#include "interface/x86_tsc.h" - - -// CPUID, EAX = 0x01, EDX values -#ifndef bit_TSC -#define bit_TSC (1 << 4) -#endif - -// CPUID, EAX = 0x80000001, EDX values -#ifndef bit_RDTSCP -#define bit_RDTSCP (1 << 27) -#endif - -// CPUID, EAX = 0x80000007, EDX values -#ifndef bit_InvariantTSC -#define bit_InvariantTSC (1 << 8) -#endif - - -// check if the processor has a TSC (Time Stamp Counter) and supports the RDTSC instruction -bool has_tsc() { - unsigned int eax, ebx, ecx, edx; - if (__get_cpuid(0x01, & eax, & ebx, & ecx, & edx)) - return (edx & bit_TSC) != 0; - else - return false; -} - -// check if the processor supports RDTSCP serialising instruction -bool has_rdtscp() { - unsigned int eax, ebx, ecx, edx; - if (__get_cpuid(0x80000001, & eax, & ebx, & ecx, & edx)) - return (edx & bit_RDTSCP) != 0; - else - return false; -} - -// check if the processor supports the Invariant TSC feature (constant frequency TSC) -bool has_invariant_tsc() { - unsigned int eax, ebx, ecx, edx; - if (__get_cpuid(0x80000007, & eax, & ebx, & ecx, & edx)) - return (edx & bit_InvariantTSC) != 0; - else - return false; -} - -// Check if the RDTSC and RDTSCP instructions are allowed in user space. -// This is controlled by the x86 control register 4, bit 4 (CR4.TSD), but that is only readable by the kernel. -// On Linux, the flag can be read (and possibly set) via the prctl interface. -#ifdef __linux__ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) -#define _HAS_PR_TSC_ENABLE -#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) -#endif // __linux__ - -bool tsc_allowed() { -#if defined __linux__ and defined _HAS_PR_TSC_ENABLE - int tsc_val = 0; - prctl(PR_SET_TSC, PR_TSC_ENABLE); - prctl(PR_GET_TSC, & tsc_val); - return (tsc_val == PR_TSC_ENABLE); -#else - return true; -#endif -} - -#undef _HAS_PR_TSC_ENABLE - - -// calibrate TSC with respect to std::chrono::high_resolution_clock -double calibrate_tsc_hz() { - if (not has_tsc() or not tsc_allowed()) - return 0; - - constexpr unsigned int sample_size = 1000; // 1000 samples - constexpr unsigned int sleep_time = 1000; // 1 ms - unsigned long long ticks[sample_size]; - double times[sample_size]; - - auto reference = std::chrono::high_resolution_clock::now(); - for (unsigned int i = 0; i < sample_size; ++i) { - usleep(sleep_time); - ticks[i] = rdtsc(); - times[i] = std::chrono::duration_cast>( std::chrono::high_resolution_clock::now() - reference ).count(); - } - - double mean_x = 0, mean_y = 0; - for (unsigned int i = 0; i < sample_size; ++i) { - mean_x += (double) times[i]; - mean_y += (double) ticks[i]; - } - mean_x /= (double) sample_size; - mean_y /= (double) sample_size; - - double sigma_xy = 0, sigma_xx = 0; - for (unsigned int i = 0; i < sample_size; ++i) { - sigma_xx += (double) (times[i] - mean_x) * (double) (times[i] - mean_x); - sigma_xy += (double) (times[i] - mean_x) * (double) (ticks[i] - mean_y); - } - - // ticks per second - return sigma_xy / sigma_xx; -} - - -// new processors can use rdtscp; -uint64_t serialising_rdtscp(void) -{ - unsigned int id; - return rdtscp(& id); -} - -// older Intel processors can use lfence; rdtsc; -uint64_t serialising_rdtsc_lfence(void) -{ - _mm_lfence(); - return rdtsc(); -} - -// older AMD processors can use mfence; rdtsc; -uint64_t serialising_rdtsc_mfence(void) -{ - _mm_mfence(); - return rdtsc(); -} - -// very old processors do not have a TSC -uint64_t serialising_rdtsc_unimplemented(void) -{ - return 0; -} - - -namespace { - - inline constexpr - unsigned int _(const char b[4]) { - return * (unsigned int *)(b); - } - -} // namespace - -extern "C" { - - static uint64_t (*serialising_rdtsc_resolver(void))(void) - { - if (not tsc_allowed()) - return serialising_rdtsc_unimplemented; - - if (has_rdtscp()) - // if available, use the RDTSCP instruction - return serialising_rdtscp; - - if (has_tsc()) { - // if the TSC is available, chck the processor vendor - unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; - __get_cpuid(0x00, & eax, & ebx, & ecx, & edx); - if (ebx == _("Genu") and edx == _("ineI") and ecx == _("ntel")) - // for Intel processors, LFENCE can be used as a serialising instruction before RDTSC - return serialising_rdtsc_lfence; - else if (ebx == _("Auth") and edx == _("enti") and ecx == _("cAMD")) - // for AMD processors, MFENCE can be used as a serialising instruction before RDTSC - return serialising_rdtsc_mfence; - else - // for other processors, assume that MFENCE can be used as a serialising instruction before RDTSC - return serialising_rdtsc_mfence; - } - - return serialising_rdtsc_unimplemented; - } - -} - -// IFUNC support requires GCC >= 4.6.0 and GLIBC >= 2.11.1 -#if ( defined __GNUC__ && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ) \ - and ( defined __GLIBC__ && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 11) ) - -uint64_t serialising_rdtsc(void) __attribute__((ifunc("serialising_rdtsc_resolver"))) __attribute__((externally_visible)); - -#else - -uint64_t (*serialising_rdtsc)(void) = serialising_rdtsc_resolver(); - -#endif // IFUNC support - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/src/x86_tsc_clock.cc b/HLTrigger/Timer/test/chrono/src/x86_tsc_clock.cc deleted file mode 100644 index 4b7e4d99e3d39..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/x86_tsc_clock.cc +++ /dev/null @@ -1,22 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#include "interface/x86_tsc.h" -#include "interface/x86_tsc_clock.h" - -const bool clock_rdtsc::is_available = has_tsc() and tsc_allowed(); -const bool clock_rdtsc::is_steady = has_invariant_tsc(); - -const bool clock_rdtsc_lfence::is_available = has_tsc() and tsc_allowed(); -const bool clock_rdtsc_lfence::is_steady = has_invariant_tsc(); - -const bool clock_rdtsc_mfence::is_available = has_tsc() and tsc_allowed(); -const bool clock_rdtsc_mfence::is_steady = has_invariant_tsc(); - -const bool clock_rdtscp::is_available = has_rdtscp() and tsc_allowed(); -const bool clock_rdtscp::is_steady = has_invariant_tsc(); - -const bool clock_serialising_rdtsc::is_available = has_tsc() and tsc_allowed(); -const bool clock_serialising_rdtsc::is_steady = has_invariant_tsc(); - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/src/x86_tsc_tick.cc b/HLTrigger/Timer/test/chrono/src/x86_tsc_tick.cc deleted file mode 100644 index fe6747a14e5e5..0000000000000 --- a/HLTrigger/Timer/test/chrono/src/x86_tsc_tick.cc +++ /dev/null @@ -1,13 +0,0 @@ -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - -#include "interface/x86_tsc.h" -#include "interface/x86_tsc_tick.h" - -const double tsc_tick::ticks_per_second = calibrate_tsc_hz(); -const double tsc_tick::seconds_per_tick = 1. / tsc_tick::ticks_per_second; -const int64_t tsc_tick::nanoseconds_per_tick_shifted = (1000000000ll << 32) / tsc_tick::ticks_per_second; -//const int64_t tsc_tick::ticks_per_nanosecond_shifted = (int64_t) ((((__int128_t) tsc_tick::ticks_per_second) << 32) / 1000000000ll); -const int64_t tsc_tick::ticks_per_nanosecond_shifted = (int64_t) llrint(tsc_tick::ticks_per_second * 4.294967296); - -#endif // defined __x86_64__ or defined __i386__ diff --git a/HLTrigger/Timer/test/chrono/test/benchmark.h b/HLTrigger/Timer/test/chrono/test/benchmark.h deleted file mode 100644 index 52688c318a206..0000000000000 --- a/HLTrigger/Timer/test/chrono/test/benchmark.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef benchmark_h -#define benchmark_h - -// C++ headers -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// std chrono types -template -double to_seconds(std::chrono::duration duration) { - return std::chrono::duration_cast>(duration).count(); -} - -template -double to_nanoseconds(std::chrono::duration duration) { - return std::chrono::duration_cast>(duration).count(); -} - -#ifdef HAVE_BOOST_CHRONO -// boost headers -#include - -// boost chrono types -template -double to_seconds(boost::chrono::duration duration) { - return boost::chrono::duration_cast>(duration).count(); -} - -template -double to_nanoseconds(boost::chrono::duration duration) { - return boost::chrono::duration_cast>(duration).count(); -} -#endif // HAVE_BOOST_CHRONO - - -#if defined(__x86_64__) || defined(__i386__) - -// native chrono types -template -double to_seconds(native::native_duration duration) { - return std::chrono::duration_cast>(duration).count(); -} - -template -double to_nanoseconds(native::native_duration duration) { - return std::chrono::duration_cast>(duration).count(); -} - -#endif - -static constexpr unsigned int SIZE = 1000000; - - -double average(std::vector const & values) { - double sum = 0; - for (size_t i = 0; i < values.size(); ++i) - sum += values[i]; - return (sum / values.size()); -} - -double sigma(std::vector const & values) { - if (values.size() > 1) { - double sum = 0; - double avg = average(values); - for (size_t i = 0; i < values.size(); ++i) - sum += (values[i] - avg) * (values[i] - avg); - return std::sqrt( sum / (values.size()-1) ); - } else { - return std::numeric_limits::quiet_NaN(); - } -} - -double median(std::vector const & values) { - if (not values.empty()) { - std::vector v = values; - std::sort( v.begin(), v.end() ); - return v[v.size() / 2]; - } else { - return std::numeric_limits::quiet_NaN(); - } -} - - -class BenchmarkBase { -public: - BenchmarkBase() = default; - - explicit BenchmarkBase(std::string const & d) : - description(d) - { } - - virtual ~BenchmarkBase() { }; - - // perform the measurements - virtual void sample() = 0; - - void measure() { - sample(); - start = std::chrono::high_resolution_clock::now(); - sample(); - stop = std::chrono::high_resolution_clock::now(); - } - - // extract the characteristics of the timer from the measurements - virtual void compute() = 0; - - // print a report - virtual void report() = 0; - -protected: - std::chrono::high_resolution_clock::time_point start; - std::chrono::high_resolution_clock::time_point stop; - - // measured per-call overhead - double overhead; - - // measured resolution, in seconds - double resolution_min; // smallest of the steps - double resolution_median; // median of the steps - double resolution_average; // average of the steps - double resolution_avg_sig; // sigma of the average - double resolution_sigma; // sigma of the average - - // description - std::string description; -}; - - -template -class Benchmark : public BenchmarkBase { -public: - typedef C clock_type; - typedef typename clock_type::time_point time_point; - - Benchmark(std::string const & d) : - BenchmarkBase(d), - values() - { - } - - // take SIZE measurements - void sample() { - for (unsigned int i = 0; i < SIZE; ++i) - values[i] = clock_type::now(); - } - - // return the delta between two time_points, expressed in seconds - double delta(const time_point & start, const time_point & stop) const { - return to_seconds(stop - start); - } - - // extract the characteristics of the timer from the measurements - void compute() { - // per-call overhead - overhead = to_seconds(stop - start) / SIZE; - - // resolution (min, median and average of the increments) - std::vector steps; - steps.reserve(SIZE); - for (unsigned int i = 0; i < SIZE-1; ++i) { - double step = delta(values[i], values[i + 1]); - if (step > 0) - steps.push_back(step); - } - std::sort( steps.begin(), steps.end() ); - if (not steps.empty()) { - // measure resolution as the median of the steps - resolution_median = steps[steps.size() / 2]; - - // measure resolution as the first non-zero step - resolution_min = steps.front(); - - // measure the sigma of the steps - resolution_sigma = sigma(steps); - if (resolution_sigma < 1.e-10) - resolution_sigma = 1.e-10; - - // measure average of the steps, and its sigma - resolution_average = average(steps); - resolution_avg_sig = resolution_sigma / sqrt(steps.size()); - - // take into account limited accuracy - if (resolution_avg_sig < 1.e-10) - resolution_avg_sig = 1.e-10; - } - } - - // print a report - void report() { - std::cout << std::setprecision(1) << std::fixed; - std::cout << "Performance of " << description << std::endl; - std::cout << "\tAverage time per call: " << std::right << std::setw(10) << overhead * 1e9 << " ns" << std::endl; - if (not std::chrono::treat_as_floating_point::value) { - typename clock_type::duration tick(1); - double ns = to_nanoseconds(tick); - std::cout << "\tClock tick period: " << std::right << std::setw(10) << ns << " ns" << std::endl; - } else { - std::cout << "\tClock tick period: " << std::right << std::setw(10) << "n/a" << std::endl; - } - std::cout << "\tMeasured resolution: " << std::right << std::setw(10) << resolution_min * 1e9 << " ns (median: " << resolution_median * 1e9 << " ns) (sigma: " << resolution_sigma * 1e9 << " ns) (average: " << resolution_average * 1e9 << " +/- " << resolution_avg_sig * 1e9 << " ns)" << std::endl; - - /* - // warm up the cache - measure_work(1000, false); - - std::cout << "\tTiming measurements (1k):" << std::endl; - for (int i =0; i <10; ++i) - measure_work(1000); - std::cout << "\tTiming measurements (10k):" << std::endl; - for (int i =0; i <10; ++i) - measure_work(10000); - std::cout << "\tTiming measurements (100k):" << std::endl; - for (int i =0; i <10; ++i) - measure_work(100000); - */ - - std::cout << std::endl; - } - - // run some workload size times, taking a measurement around it - void measure_work(int size, bool verbose = true) const { - std::vector times(size, 0.); - for (int i = 0; i < size; ++i) { - typename clock_type::time_point t0 = clock_type::now(); - - volatile double x = M_PI; - for (int j = 0; j < 100; ++j) { - x = std::sqrt(x) * std::sqrt(x); - } - - typename clock_type::time_point t1 = clock_type::now(); - times[i] = delta(t0, t1); - } - - std::sort(times.begin(), times.end()); - - double avg = average(times); - double sig = sigma(times); - double min = times.front(); - double max = times.back(); - double med = times[times.size() / 2]; - if (verbose) { - std::cout << "\t\t[" << std::setw(10) << min * 1e9 << ".." << std::setw(10) << max * 1e9 << "] ns"; - std::cout << "\tavg: " << std::setw(10) << avg * 1e9 << " ns"; - std::cout << "\tmed: " << std::setw(10) << med * 1e9 << " ns"; - std::cout << "\tsig: " << std::setw(10) << sig * 1e9 << " ns"; - } - - // remove tails (values larger than twice the median) - auto limit = std::upper_bound(times.begin(), times.end(), med * 2); - std::vector filtered(times.begin(), limit); - - avg = average(filtered); - sig = sigma(filtered); - min = filtered.front(); - max = filtered.back(); - med = filtered[filtered.size() / 2]; - if (verbose) { - std::cout << "\t| [" << std::setw(10) << min * 1e9 << ".." << std::setw(10) << max * 1e9 << "] ns"; - std::cout << "\tavg: " << std::setw(10) << avg * 1e9 << " ns"; - std::cout << "\tmed: " << std::setw(10) << med * 1e9 << " ns"; - std::cout << "\tsig: " << std::setw(10) << sig * 1e9 << " ns"; - } - - std::cout << std::endl; - } - -protected: - time_point values[SIZE]; - -}; - -#endif //benchmark_h diff --git a/HLTrigger/Timer/test/chrono/test/chrono.cc b/HLTrigger/Timer/test/chrono/test/chrono.cc deleted file mode 100644 index 2ea0fdc7200c6..0000000000000 --- a/HLTrigger/Timer/test/chrono/test/chrono.cc +++ /dev/null @@ -1,319 +0,0 @@ -// macro to check for GCC version -#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) - -// C++ headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_BOOST_CHRONO -// boost headers -#include -#endif // HAVE_BOOST_CHRONO - -#if defined HAVE_BOOST_CHRONO || defined HAVE_BOOST_TIMER -// boost version -#include -#endif // defined HAVE_BOOST_CHRONO || defined HAVE_BOOST_TIMER - -#ifdef HAVE_TBB -// TBB version -#include -#endif // HAVE_TBB - -// for uname -#include - -#ifdef __linux__ -// for gnu_get_libc_version -#include -#endif // __linux__ - -// other clocks -#include "interface/syscall_clock_gettime.h" -#include "interface/posix_clock.h" -#include "interface/posix_clock_gettime.h" -#include "interface/posix_gettimeofday.h" -#include "interface/posix_times.h" -#include "interface/posix_times_f.h" -#include "interface/posix_times_d.h" -#include "interface/posix_getrusage.h" -#include "interface/mach_clock_get_time.h" -#include "interface/mach_absolute_time.h" -#include "interface/mach_thread_info.h" -#include "interface/x86_tsc_clock.h" -#include "interface/boost_timer.h" -#include "interface/tbb_tick_count.h" - -#ifndef __clang__ -// CLANG does not support OpenMP -#include "interface/omp_get_wtime.h" -#endif // ! __clang__ - -#include "interface/native/mach_absolute_time.h" -#include "interface/native/x86_tsc_clock.h" - -#include "benchmark.h" - - -void init_timers(std::vector & timers) -{ - // std::chrono timers -#if __clang__ || GCC_VERSION >= 40700 - // C++11 clock name - timers.push_back(new Benchmark("std::chrono::steady_clock")); -#else - // pre-C++11 clock name - timers.push_back(new Benchmark("std::chrono::monotonic_clock")); -#endif - timers.push_back(new Benchmark("std::chrono::system_clock")); - timers.push_back(new Benchmark("std::chrono::high_resolution_clock")); - - // syscall clock_gettime -#ifdef HAVE_SYSCALL_CLOCK_REALTIME - if (clock_syscall_realtime::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_REALTIME)")); -#endif // HAVE_SYSCALL_CLOCK_REALTIME -#ifdef HAVE_SYSCALL_CLOCK_REALTIME_COARSE - if (clock_syscall_realtime_coarse::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_REALTIME_COARSE)")); -#endif // HAVE_SYSCALL_CLOCK_REALTIME_COARSE -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC - if (clock_syscall_monotonic::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_MONOTONIC)")); -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE - if (clock_syscall_monotonic_coarse::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE)")); -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_COARSE -#ifdef HAVE_SYSCALL_CLOCK_MONOTONIC_RAW - if (clock_syscall_monotonic_raw::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_MONOTONIC_RAW)")); -#endif // HAVE_SYSCALL_CLOCK_MONOTONIC_RAW -#ifdef HAVE_SYSCALL_CLOCK_BOOTTIME - if (clock_syscall_boottime::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_BOOTTIME)")); -#endif // HAVE_SYSCALL_CLOCK_BOOTTIME -#ifdef HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID - if (clock_syscall_process_cputime::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID)")); -#endif // HAVE_SYSCALL_CLOCK_PROCESS_CPUTIME_ID -#ifdef HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID - if (clock_syscall_thread_cputime::is_available) - timers.push_back(new Benchmark("syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID)")); -#endif // HAVE_SYSCALL_CLOCK_THREAD_CPUTIME_ID - - // POSIX clock_gettime -#ifdef HAVE_POSIX_CLOCK_REALTIME - if (clock_gettime_realtime::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_REALTIME)")); -#endif // HAVE_POSIX_CLOCK_REALTIME -#ifdef HAVE_POSIX_CLOCK_REALTIME_COARSE - if (clock_gettime_realtime_coarse::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_REALTIME_COARSE)")); -#endif // HAVE_POSIX_CLOCK_REALTIME_COARSE -#ifdef HAVE_POSIX_CLOCK_MONOTONIC - if (clock_gettime_monotonic::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_MONOTONIC)")); -#endif // HAVE_POSIX_CLOCK_MONOTONIC -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_COARSE - if (clock_gettime_monotonic_coarse::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_MONOTONIC_COARSE)")); -#endif // HAVE_POSIX_CLOCK_MONOTONIC_COARSE -#ifdef HAVE_POSIX_CLOCK_MONOTONIC_RAW - if (clock_gettime_monotonic_raw::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_MONOTONIC_RAW)")); -#endif // HAVE_POSIX_CLOCK_MONOTONIC_RAW -#ifdef HAVE_POSIX_CLOCK_BOOTTIME - if (clock_gettime_boottime::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_BOOTTIME)")); -#endif // HAVE_POSIX_CLOCK_BOOTTIME -#ifdef HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID - if (clock_gettime_process_cputime::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_PROCESS_CPUTIME_ID)")); -#endif // HAVE_POSIX_CLOCK_PROCESS_CPUTIME_ID -#ifdef HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID - if (clock_gettime_thread_cputime::is_available) - timers.push_back(new Benchmark("clock_gettime(CLOCK_THREAD_CPUTIME_ID)")); -#endif // HAVE_POSIX_CLOCK_THREAD_CPUTIME_ID - - // POSIX gettimeofday - timers.push_back(new Benchmark("gettimeofday()")); - - // POSIX times - timers.push_back(new Benchmark("times() (wall-clock time)")); - timers.push_back(new Benchmark("times() (cpu time)")); - timers.push_back(new Benchmark("times() (wall-clock time) (using double)")); - timers.push_back(new Benchmark("times() (cpu time) (using double)")); -#if defined __x86_64__ or defined __i386__ -// 128-bit wide int is only available on x86 - timers.push_back(new Benchmark("times() (wall-clock time) (using fixed math)")); - timers.push_back(new Benchmark("times() (cpu time) (using fixed math)")); -#endif // defined __x86_64__ or defined __i386__ - - // POSIX clock - timers.push_back(new Benchmark("clock()")); - - // POSIX getrusage - timers.push_back(new Benchmark("getrusage(RUSAGE_SELF)")); -#ifdef HAVE_POSIX_CLOCK_GETRUSAGE_THREAD - timers.push_back(new Benchmark("getrusage(RUSAGE_THREAD)")); -#endif // HAVE_POSIX_CLOCK_GETRUSAGE_THREAD - - // MACH clock_get_time -#ifdef HAVE_MACH_SYSTEM_CLOCK - if (mach_system_clock::is_available) - timers.push_back(new Benchmark("host_get_clock_service(SYSTEM_CLOCK), clock_get_time(...)")); -#endif // HAVE_MACH_SYSTEM_CLOCK -#ifdef HAVE_MACH_REALTIME_CLOCK - if (mach_realtime_clock::is_available) - timers.push_back(new Benchmark("host_get_clock_service(REALTIME_CLOCK), clock_get_time(...)")); -#endif // HAVE_MACH_REALTIME_CLOCK -#ifdef HAVE_MACH_CALENDAR_CLOCK - if (mach_calendar_clock::is_available) - timers.push_back(new Benchmark("host_get_clock_service(CALENDAR_CLOCK), clock_get_time(...)")); -#endif // HAVE_MACH_CALENDAR_CLOCK -#ifdef HAVE_MACH_ABSOLUTE_TIME - if (mach_absolute_time_clock::is_available) { - timers.push_back(new Benchmark("mach_absolute_time() (using nanoseconds)")); - timers.push_back(new Benchmark("mach_absolute_time() (native)")); - } -#endif // HAVE_MACH_ABSOLUTE_TIME -#ifdef HAVE_MACH_THREAD_INFO_CLOCK - if (mach_thread_info_clock::is_available) - timers.push_back(new Benchmark("thread_info(mach_thread_self(), THREAD_BASIC_INFO, ...)")); -#endif // HAVE_MACH_THREAD_INFO_CLOCK - -#if defined __x86_64__ or defined __i386__ -// TSC is only available on x86 - - // read TSC clock frequency - std::stringstream buffer; - buffer << std::fixed << std::setprecision(3) << (tsc_tick::ticks_per_second / 1.e6) << " MHz"; - std::string tsc_freq = buffer.str(); - - // x86 DST-based clock (via std::chrono::nanosecond) - if (clock_rdtsc::is_available) - timers.push_back(new Benchmark("RDTSC (" + tsc_freq + ") (using nanoseconds)")); - if (clock_rdtsc_lfence::is_available) - timers.push_back(new Benchmark("LFENCE; RDTSC (" + tsc_freq + ") (using nanoseconds)")); - if (clock_rdtsc_mfence::is_available) - timers.push_back(new Benchmark("MFENCE; RDTSC (" + tsc_freq + ") (using nanoseconds)")); - if (clock_rdtscp::is_available) - timers.push_back(new Benchmark("RDTSCP (" + tsc_freq + ") (using nanoseconds)")); - if (clock_serialising_rdtsc::is_available) - timers.push_back(new Benchmark("run-time selected serialising RDTSC (" + tsc_freq + ") (using nanoseconds)")); - // x86 DST-based clock (native) - if (native::clock_rdtsc::is_available) - timers.push_back(new Benchmark("RDTSC (" + tsc_freq + ") (native)")); - if (native::clock_rdtsc_lfence::is_available) - timers.push_back(new Benchmark("LFENCE; RDTSC (" + tsc_freq + ") (native)")); - if (native::clock_rdtsc_mfence::is_available) - timers.push_back(new Benchmark("MFENCE; RDTSC (" + tsc_freq + ") (native)")); - if (native::clock_rdtscp::is_available) - timers.push_back(new Benchmark("RDTSCP (" + tsc_freq + ") (native)")); - if (native::clock_serialising_rdtsc::is_available) - timers.push_back(new Benchmark("run-time selected serialising RDTSC (" + tsc_freq + ") (native)")); - -#endif // defined __x86_64__ or defined __i386__ - -#ifdef HAVE_BOOST_TIMER - // boost timer clocks - timers.push_back(new Benchmark("boost::timer (wall-clock time)")); - timers.push_back(new Benchmark("boost::timer (cpu time)")); -#endif // HAVE_BOOST_TIMER - -#ifdef HAVE_BOOST_CHRONO - // boost chrono clocks - timers.push_back(new Benchmark("boost::chrono::steady_clock")); - timers.push_back(new Benchmark("boost::chrono::system_clock")); - timers.push_back(new Benchmark("boost::chrono::high_resolution_clock")); - #ifdef BOOST_CHRONO_HAS_PROCESS_CLOCKS - timers.push_back(new Benchmark("boost::chrono::process_real_cpu_clock")); - timers.push_back(new Benchmark("boost::chrono::process_user_cpu_clock")); - timers.push_back(new Benchmark("boost::chrono::process_system_cpu_clock")); - //timers.push_back(new Benchmark("boost::chrono::process_cpu_clock")); - #endif // BOOST_CHRONO_HAS_PROCESS_CLOCKS - #ifdef BOOST_CHRONO_HAS_THREAD_CLOCK - timers.push_back(new Benchmark("boost::chrono::thread_clock")); - #endif // BOOST_CHRONO_HAS_THREAD_CLOCK -#endif // HAVE_BOOST_CHRONO - -#ifdef HAVE_TBB - // TBB tick_count (this interface does not expose the underlying type, so it cannot easily be used to build a "native" clock interface) - timers.push_back(new Benchmark("tbb::tick_count")); -#endif // HAVE_TBB - -#ifndef __clang__ - // OpenMP timer - timers.push_back(new Benchmark("omp_get_wtime")); -#endif // ! __clang__ -} - - -std::string read_kernel_version() { - struct utsname names; - if (not uname(& names)) { - std::stringstream buffer; - buffer << names.sysname << " " << names.release << " " << names.machine; - return buffer.str(); - } else { - return std::string("unknown"); - } -} - - -#ifdef __linux__ -std::string read_glibc_version() { - std::string version( gnu_get_libc_version() ); - return version; -} - - -std::string read_clock_source() { - std::ifstream current_clocksource("/sys/devices/system/clocksource/clocksource0/current_clocksource"); - if (current_clocksource.good()) { - std::string value; - current_clocksource >> value; - return value; - } else { - return std::string("unknown"); - } -} -#endif // __linux__ - - -int main(void) { - std::vector timers; - init_timers(timers); - - std::cout << read_kernel_version() << std::endl; -#ifdef __linux__ - std::cout << "glibc version: " << read_glibc_version() << std::endl; - std::cout << "clock source: " << read_clock_source() << std::endl; -#endif // __linux__ -#if defined HAVE_BOOST_CHRONO || defined HAVE_BOOST_TIMER - std::cout << "boost version: " << (BOOST_VERSION / 100000) << '.' << (BOOST_VERSION / 100 % 1000) << '.' << (BOOST_VERSION % 100) << std::endl; -#endif // defined HAVE_BOOST_CHRONO || defined HAVE_BOOST_TIMER -#ifdef HAVE_TBB - std::cout << "tbb version: " << (TBB_INTERFACE_VERSION / 1000) << '.' << (TBB_INTERFACE_VERSION % 1000) << " (interface) " - << (tbb::TBB_runtime_interface_version() / 1000) << '.' << (tbb::TBB_runtime_interface_version() % 1000) << " (runtime)" << std::endl; -#endif // HAVE_TBB - - std::cout << "For each timer the resolution reported is the MINIMUM (MEDIAN) (MEAN +/- its STDDEV) of the increments measured during the test." << std::endl << std::endl; - - for (BenchmarkBase * timer: timers) { - timer->measure(); - timer->compute(); - timer->report(); - } - - return 0; -}