Commit 45624dd1 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Benchmarks running

parent a9cd985c
......@@ -41,6 +41,9 @@ set( ITADSPSources
# compiler settings
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
if( WIN32 )
list( APPEND VISTA_USE_PACKAGE_LIBRARIES Ws2_32 )
endif( )
endif( )
if( BUILD_SHARED_LIBS )
add_definitions( -DITA_DSP_EXPORT )
......
......@@ -35,6 +35,7 @@
#include <iostream>
#include <math.h>
#include <vector>
#include <stdio.h>
using namespace std;
const std::string sBMFilePath = "ITADSP_BM_SIMO_VDL.ini";
......@@ -51,24 +52,36 @@ struct ParameterSet
int iNumFrames;
float fDelayIncrementSample;
inline ParameterSet()
inline void SetSomeDefaults()
{
iNumCursors = 256;
#ifdef DEBUG
iNumFrames = 100;
#else
iNumFrames = 1e3;
#endif
};
inline void SetSomeDependentParameters()
{
iBlockLength = 32;
dSampleRate = 44.1e3;
fMaxReservedDelaySamples = 100 * iBlockLength;
fInitialDelaySamples = 10 * 2 * iBlockLength - 1;
iNumCursors = 256;
sWAVOutFilePath = "ITADSP_BM_SIMOVDL_L32.wav";
iInterpolationType = CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION;
iNumFrames = 1e6;
fDelayIncrementSample = 1.0f;
};
inline void WriteToINIFile( const std::string& sSection ) const
{
INIFileWriteDouble( sBMFilePath, sSection, "SampleRate", dSampleRate );
INIFileWriteDouble( sBMFilePath, sSection, "BlockTimeSeconds", iBlockLength / dSampleRate );
INIFileWriteString( sBMFilePath, sSection, "BlockTime", timeToString( iBlockLength / dSampleRate ) );
INIFileWriteInt( "BlockLength", iBlockLength );
INIFileWriteDouble( "SampleRate", dSampleRate );
INIFileWriteDouble( "MaxReservedDleaySamples", fMaxReservedDelaySamples );
INIFileWriteDouble( "InitialDelaySamples", fInitialDelaySamples );
INIFileWriteDouble( "DelayIncrementSample", fDelayIncrementSample );
INIFileWriteInt( "NumCursors", iNumCursors );
INIFileWriteInt( "NumFrames", iNumFrames );
INIFileWriteString( "WAVOutFilePath", sWAVOutFilePath );
INIFileWriteString( "InterpolationType", ( iInterpolationType == CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION ) ? "cubicspline" : "linear" );
INIFileWriteDouble( "BlockTimeSeconds", iBlockLength / dSampleRate );
INIFileWriteString( "BlockTime", timeToString( iBlockLength / dSampleRate ) );
};
};
......@@ -78,50 +91,65 @@ int main( int, char** )
{
cout << "Starting single-input multiple-output variable delay line benchmark" << endl;
INIFileUseFile( sBMFilePath );
ParameterSet pm;
pm.iNumFrames = 100;
// 32 samples block length
pm.iBlockLength = 32;
pm.fDelayIncrementSample = 1.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p1" );
pm.fDelayIncrementSample = 2.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p2" );
pm.fDelayIncrementSample = 4.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p4" );
pm.fDelayIncrementSample = 8.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p8" );
pm.fDelayIncrementSample = 16.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p16" );
pm.fDelayIncrementSample = -1.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n1" );
pm.fDelayIncrementSample = -2.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n2" );
pm.fDelayIncrementSample = -4.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n4" );
pm.fDelayIncrementSample = -8.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n8" );
pm.fDelayIncrementSample = -16.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n16" );
// 64 samples block length
pm.iBlockLength = 64;
pm.fDelayIncrementSample = 1.0f;
run_benchmark( pm, "Benchmark_L64_stretch_p1" );
cout << "Done." << endl;
pm.SetSomeDefaults();
for( auto BL : { 32, 64, 128, 265 } )
{
for( auto SI : { 1, 2, 4, 8, 16, 32, 64, 128 } )
{
for( auto IT : { CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION, CITASIMOVariableDelayLine::LINEAR_INTERPOLATION } )
{
if( BL < SI * 2 )
continue;
string sInterp = ( IT == CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION ) ? "cubicspline" : "linear";
// Streach
stringstream ss;
ss << "ITADSP_BM_SIMOVDL_L" << BL << "_stretch_" << SI << "_" << sInterp;
string sBMID = ss.str();
pm.iBlockLength = BL;
pm.fDelayIncrementSample = SI;
pm.iInterpolationType = IT;
pm.sWAVOutFilePath = sBMID + ".wav";
pm.SetSomeDependentParameters();
cout << "\tStarting " << sBMID << " ";
run_benchmark( pm, sBMID );
cout << "\tdone." << endl;
// Squeeze
ss = stringstream();
ss << "ITADSP_BM_SIMOVDL_L" << BL << "_squeeze_" << SI << "_" << sInterp;
sBMID = ss.str();
pm.iBlockLength = BL;
pm.fDelayIncrementSample = ( -1.0f ) * SI;
pm.iInterpolationType = IT;
pm.sWAVOutFilePath = sBMID + ".wav";
pm.SetSomeDependentParameters();
cout << "\tStarting " << sBMID << " ";
run_benchmark( pm, sBMID );
cout << "\tdone." << endl;
}
}
}
cout << "All done." << endl;
return 255;
}
void run_benchmark( const ParameterSet& pm, const std::string& sName )
{
INIFileUseSection( sName );
pm.WriteToINIFile( sName );
ITAStreamFunctionGenerator sinesignal( 1, pm.dSampleRate, pm.iBlockLength, ITAStreamFunctionGenerator::SINE, 500.0f, 0.9f, true );
ITADatasource* pIntputStream = &sinesignal;
CITASIMOVariableDelayLine* pSIMOVDL = new CITASIMOVariableDelayLine( pm.dSampleRate, pm.iBlockLength, pm.fMaxReservedDelaySamples, pm.iInterpolationType );
std::vector< int > viCursors;
for( int i = 0; i < pm.iNumCursors; i++ )
{
......@@ -129,7 +157,6 @@ void run_benchmark( const ParameterSet& pm, const std::string& sName )
pSIMOVDL->SetDelaySamples( viCursors[ i ], float( pm.iBlockLength * ( 50 + i ) ) );
}
ITAAudiofileProperties props_out;
props_out.iChannels = 1;
props_out.dSampleRate = pm.dSampleRate;
......@@ -144,7 +171,7 @@ void run_benchmark( const ParameterSet& pm, const std::string& sName )
ITASampleBuffer* psbInput = new ITASampleBuffer( pm.iBlockLength, true );
ITASampleFrame* psfOutput = new ITASampleFrame( pSIMOVDL->GetNumCursors(), pm.iBlockLength, true );
ITASampleFrame sfTemp( 1, pm.iBlockLength, true );
ITAStopWatch swBenchmark;
unsigned int n = 0;
......@@ -164,17 +191,21 @@ void run_benchmark( const ParameterSet& pm, const std::string& sName )
swBenchmark.start();
pSIMOVDL->ReadBlockAndIncrement( psfOutput );
swBenchmark.stop();
INIFileWriteDouble( "ComputationMean", swBenchmark.mean() );
INIFileWriteDouble( "ComputationStdDev", swBenchmark.std_deviation() );
INIFileWriteDouble( "ComputationMinimum", swBenchmark.minimum() );
INIFileWriteDouble( "ComputationMaximum", swBenchmark.maximum() );
sfTemp.zero();
for( int i = 0; i < psfOutput->GetNumChannels(); i++ )
sfTemp[0].add_buf( ( *psfOutput )[ i ] );
sfTemp[ 0 ].add_buf( ( *psfOutput )[ i ] );
writer_out->write( &sfTemp, sfTemp.GetLength() );
n++;
pIntputStream->IncrementBlockPointer();
if( n % ( pm.iNumFrames / 100 ) == 0 )
if( n % ( pm.iNumFrames / 10 ) == 0 )
cout << ".";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment