PhoenixMicroBenchmark
1.3.0
Toolset for function micro-benchmarking
Toggle main menu visibility
Loading...
Searching...
No Matches
PFunctionTimer_impl.h
Go to the documentation of this file.
1
2
/***************************************
3
Auteur : Pierre Aubert
4
Mail : pierre.aubert@lapp.in2p3.fr
5
Licence : CeCILL-C
6
****************************************/
7
8
#ifndef __PFUNCTIONTIMER_IMPL_H__
9
#define __PFUNCTIONTIMER_IMPL_H__
10
11
#include "
pin_thread_to_core.h
"
12
#include "
micro_benchmark_ns.h
"
13
#include "
PFunctionTimer.h
"
14
16
18
template
<
class
T>
19
[[gnu::always_inline]]
inline
void
benchmark_doNotOptimize
(T & value) {
20
#if defined(__clang__)
21
asm
volatile
(
""
:
"+r,m"
(value) : :
"memory"
);
22
#else
23
asm
volatile
(
""
:
"+m,r"
(value) : :
"memory"
);
24
#endif
25
}
26
28
32
template
<
typename
_Callable,
typename
... _Args>
33
void
PFunctionTimer::evalPerf
(_Callable&& __f, _Args&&... __args){
34
PIN_THREAD_TO_CORE
35
int
dummy = 0;
36
::benchmark_doNotOptimize
(dummy);
37
for
(
size_t
i(0lu); i <
p_nbMeasure
; ++i){
38
//Start chrono
39
HiPeTime
startNs =
phoenix_getTime
();
40
size_t
startCy =
phoenix_rdtsc
();
41
//Call function
42
::benchmark_doNotOptimize
(dummy);
43
__f(__args...);
44
//Compute ellapsed time
45
size_t
ellapsedTimeCy(
phoenix_rdtsc
() - startCy);
46
p_vecEllapsedTimeNs
[i] = (double)ellapsedTimeCy;
47
NanoSecs
elapsedTimeNs(
phoenix_getTime
() - startNs);
48
double
fullNs((
double
)elapsedTimeNs.count());
49
p_vecEllapsedTimeCycle
[i] = fullNs;
50
}
51
}
52
53
//{Finally we close the header :
54
#endif
55
PFunctionTimer.h
benchmark_doNotOptimize
void benchmark_doNotOptimize(T &value)
Prevent compiler from optimising a loop.
Definition
PFunctionTimer_impl.h:19
PFunctionTimer::p_vecEllapsedTimeNs
std::vector< double > p_vecEllapsedTimeNs
Ellapsed time of the function in nanoseconds.
Definition
PFunctionTimer.h:46
PFunctionTimer::p_nbMeasure
size_t p_nbMeasure
Number of performance measures we want on this function.
Definition
PFunctionTimer.h:41
PFunctionTimer::p_vecEllapsedTimeCycle
std::vector< double > p_vecEllapsedTimeCycle
Ellapsed time of the function in cycles.
Definition
PFunctionTimer.h:48
PFunctionTimer::evalPerf
void evalPerf(_Callable &&__f, _Args &&... __args)
Method which evaluate performance of the given function.
Definition
PFunctionTimer_impl.h:33
phoenix_getTime
HiPeTime phoenix_getTime()
Get the current time.
Definition
micro_benchmark_ns.cpp:12
micro_benchmark_ns.h
NanoSecs
std::chrono::nanoseconds NanoSecs
Definition
micro_benchmark_ns.h:13
HiPeTime
std::chrono::time_point< std::chrono::steady_clock > HiPeTime
Definition
micro_benchmark_ns.h:16
phoenix_rdtsc
long unsigned int phoenix_rdtsc(void)
pin_thread_to_core.h
PIN_THREAD_TO_CORE
#define PIN_THREAD_TO_CORE
Definition
pin_thread_to_core.h:13
src
PFunctionTimer_impl.h
Generated by
1.17.0