CMSIS-DSP: Testing framework

Added some calibration to remove overhead in the benchmark measurement process.
Reorganized one test to move some initialization code outside of the test.
pull/19/head
Christophe Favergeon 6 years ago
parent dc60f80ccd
commit 69f0f0f7bc

@ -134,6 +134,7 @@ set(FRAMEWORKSRC
FrameworkSource/FPGA.cpp
FrameworkSource/Timing.cpp
FrameworkSource/Generators.cpp
FrameworkSource/Calibrate.cpp
)
# Change behavior of configBoot for scatter file
# We use the linker files from older test framework because bigger sections are needed.

@ -0,0 +1,10 @@
#include "Test.h"
#include "Pattern.h"
class Calibrate:public Client::Suite
{
public:
Calibrate(Testing::testID_t id);
void empty();
void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
};

@ -44,6 +44,8 @@ namespace Client
IO *m_io;
PatternMgr *m_mgr;
Testing::RunningMode m_runningMode;
Testing::cycles_t calibration = 0;
};
}

@ -0,0 +1,20 @@
#include "Calibrate.h"
Calibrate::Calibrate(Testing::testID_t id):Client::Suite(id)
{
}
void Calibrate::empty()
{
}
void Calibrate::setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
}
void Calibrate::tearDown(Testing::testID_t,Client::PatternMgr *mgr)
{
}

@ -36,6 +36,7 @@
#include "Error.h"
#include "Timing.h"
#include "arm_math.h"
#include "Calibrate.h"
namespace Client
{
@ -54,6 +55,36 @@ namespace Client
}
initCycleMeasurement();
/*
For calibration :
Calibration means, in this context, removing the overhad of calling
a C++ function pointer from the cycle measurements.
*/
Calibrate c((Testing::testID_t)0);
Client::Suite *s=(Client::Suite *)&c;
Client::test t = (Client::test)&Calibrate::empty;
cycleMeasurementStart();
#ifdef EXTBENCH
startSection();
#endif
for(int i=0;i < 20;i++)
{
(s->*t)();
}
#ifdef EXTBENCH
stopSection();
#endif
#ifndef EXTBENCH
calibration=getCycles() / 20;
#endif
cycleMeasurementStop();
}
// Testing.
@ -152,7 +183,7 @@ namespace Client
stopSection();
#endif
#ifndef EXTBENCH
cycles=getCycles();
cycles=getCycles()-calibration;
#endif
cycleMeasurementStop();
}

@ -13,5 +13,9 @@ class BasicMathsBenchmarksF32:public Client::Suite
Client::LocalPattern<float32_t> output;
int nb;
float32_t *inp1;
float32_t *inp2;
float32_t *outp;
};

@ -3,14 +3,9 @@
void BasicMathsBenchmarksF32::vec_mult_f32()
{
float32_t *inp1=input1.ptr();
float32_t *inp2=input2.ptr();
float32_t *outp=output.ptr();
{
arm_mult_f32(inp1,inp2,outp,this->nb);
arm_mult_f32(this->inp1,this->inp2,this->outp,this->nb);
}
@ -111,6 +106,19 @@
output.create(this->nb,BasicMathsBenchmarksF32::OUT_SAMPLES_F32_ID,mgr);
switch(id)
{
case BasicMathsBenchmarksF32::VEC_MULT_F32_1:
/* This an overhead doing this because ptr() function is doing lot of checks
to ensure patterns are fresh.
So for small benchmark lengths it is better doing it in the setUp function
*/
this->inp1=input1.ptr();
this->inp2=input2.ptr();
this->outp=output.ptr();
break;
}
}

@ -235,6 +235,11 @@ def getCyclesFromTrace(trace):
return(TestScripts.ParseTrace.getCycles(trace))
def analyseResult(root,results,embedded,benchmark,trace,formatter):
calibration = 0
if trace:
# First cycle in the trace is the calibration data
# The noramlisation factor must be coherent with the C code one.
calibration = int(getCyclesFromTrace(trace) / 20)
formatter.start()
path = []
state = NORMAL
@ -348,7 +353,7 @@ def analyseResult(root,results,embedded,benchmark,trace,formatter):
maybeCycles = m.group(4)
if maybeCycles == "t":
cycles = getCyclesFromTrace(trace)
cycles = getCyclesFromTrace(trace) - calibration
else:
cycles = int(maybeCycles)

Loading…
Cancel
Save