Commit bb8209fd authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Applied Clang format

parent 9250c5d3
---
---
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignEscapedNewlines: Left
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
......@@ -15,37 +18,40 @@ AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BinPackArguments: 'true'
BinPackParameters: 'true'
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
ColumnLimit: '170'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'true'
DisableFormat: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'true'
IndentPPDirectives: AfterHash
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: Always
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: 'false'
SpaceInEmptyParentheses: 'true'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
......@@ -56,17 +62,4 @@ Standard: Auto
TabWidth: '4'
UseTab: ForIndentation
SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
# Headers in "" with extension.
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
Priority: 3
# Headers in <> with extension.
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
Priority: 2
# Headers in <> without extension.
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
Priority: 1
...
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2021
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Benchmark uniform partitioned convolution
*
*/
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2021
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Benchmark uniform partitioned convolution
*
*/
#include <ITAUPConvolution.h>
#include <ITAUPFilter.h>
#include <ITAStringUtils.h>
#include <ITAAudiofileWriter.h>
#include <ITAConfigUtils.h>
#include <ITAFileDataSource.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITAStopWatch.h>
#include <ITAConfigUtils.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAFileDataSource.h>
#include <ITAStreamInfo.h>
#include <ITAStringUtils.h>
#include <ITAUPConvolution.h>
#include <ITAUPFilter.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <vector>
using namespace std;
......@@ -50,7 +47,7 @@ struct ParameterSet
int iFilterLength;
int iScalingApproximation;
inline void SetSomeDefaults()
inline void SetSomeDefaults( )
{
dSampleRate = 44.1e3;
#ifdef DEBUG
......@@ -61,7 +58,7 @@ struct ParameterSet
iScalingApproximation = 64;
};
inline void WriteToINIFile() const
inline void WriteToINIFile( ) const
{
INIFileWriteInt( "BlockLength", iBlockLength );
INIFileWriteDouble( "SampleRate", dSampleRate );
......@@ -81,9 +78,9 @@ int main( int, char** )
pbfImpulse = new ITASampleBuffer( int( 1000 * 44.1e3 ), true );
srand( 100 );
int iLength = pbfImpulse->GetLength();
int iLength = pbfImpulse->GetLength( );
for( unsigned int i = 0; i < iLength; i++ )
pbfImpulse->GetData()[ i ] = ( float ) rand() / RAND_MAX;
pbfImpulse->GetData( )[i] = (float)rand( ) / RAND_MAX;
cout << "Starting uniformly partitioned block convolution benchmark" << endl;
......@@ -91,20 +88,20 @@ int main( int, char** )
INIFileUseFile( "ITAConvolution_BM_UPConv.ini" );
ParameterSet pm;
pm.SetSomeDefaults();
pm.SetSomeDefaults( );
for( auto BL : { 32, 64, 128, 256 } )
for( auto BL: { 32, 64, 128, 256 } )
{
for( auto BM : { 1, 2, 4, 8, 16 } )
for( auto BM: { 1, 2, 4, 8, 16 } )
{
stringstream ss;
ss << "ITAConvolution_BM_NUPConv_L" << BL << "_M" << BL*BM;
string sBMID = ss.str();
pm.iBlockLength = BL;
pm.iFilterLength = BL*BM;
ss << "ITAConvolution_BM_NUPConv_L" << BL << "_M" << BL * BM;
string sBMID = ss.str( );
pm.iBlockLength = BL;
pm.iFilterLength = BL * BM;
pm.sWAVOutFilePath = sBMID + ".wav";
cout << "\tStarting " << sBMID << " ";
//run_benchmark( pm, sBMID );
// run_benchmark( pm, sBMID );
cout << "\tdone." << endl;
}
}
......@@ -112,15 +109,15 @@ int main( int, char** )
INIFileUseFile( "ITAConvolution_BM_UPConv_ScalingBehavior.ini" );
for( auto BL : { 256 } )
for( auto BL: { 256 } )
{
for( auto BM : { 1, 2, 4, 8, 16, 32, 64, 128, 512, 1024, 2048, 4096, 8182 } )
for( auto BM: { 1, 2, 4, 8, 16, 32, 64, 128, 512, 1024, 2048, 4096, 8182 } )
{
stringstream ss;
ss << "ITAConvolution_BM_NUPConv_ScalingBehavior_L" << BL << "_M" << BL*BM;
string sBMID = ss.str();
pm.iBlockLength = BL;
pm.iFilterLength = BL*BM;
ss << "ITAConvolution_BM_NUPConv_ScalingBehavior_L" << BL << "_M" << BL * BM;
string sBMID = ss.str( );
pm.iBlockLength = BL;
pm.iFilterLength = BL * BM;
pm.sWAVOutFilePath = sBMID + ".wav";
cout << "\tStarting " << sBMID << " ";
run_benchmark( pm, sBMID );
......@@ -137,24 +134,25 @@ int main( int, char** )
void run_benchmark( const ParameterSet& pm, const std::string& sName )
{
INIFileUseSection( sName );
pm.WriteToINIFile();
pm.WriteToINIFile( );
ITAStreamFunctionGenerator sinesignal( 1, pm.dSampleRate, pm.iBlockLength, ITAStreamFunctionGenerator::SINE, 500.0f, 0.9f, true );
ITADatasource* pIntputStream = &sinesignal;
ITAUPConvolution* pFIRFilterEnginge = new ITAUPConvolution( pm.iBlockLength, pm.iFilterLength );
ITAUPFilter* pFIRFilter = pFIRFilterEnginge->RequestFilter();;
pFIRFilter->Load( pbfImpulse->GetData(), std::min( pbfImpulse->GetLength(), pm.iFilterLength ) );
ITAUPFilter* pFIRFilter = pFIRFilterEnginge->RequestFilter( );
;
pFIRFilter->Load( pbfImpulse->GetData( ), std::min( pbfImpulse->GetLength( ), pm.iFilterLength ) );
pFIRFilterEnginge->ExchangeFilter( pFIRFilter );
pFIRFilter->Release();
pFIRFilter->Release( );
ITAAudiofileProperties props_out;
props_out.iChannels = 1;
props_out.dSampleRate = pm.dSampleRate;
props_out.eQuantization = ITAQuantization::ITA_FLOAT;
props_out.eDomain = ITADomain::ITA_TIME_DOMAIN;
props_out.iLength = pm.iNumFrames * ( unsigned int ) ( pm.iBlockLength );
props_out.iChannels = 1;
props_out.iChannels = 1;
props_out.dSampleRate = pm.dSampleRate;
props_out.eQuantization = ITAQuantization::ITA_FLOAT;
props_out.eDomain = ITADomain::ITA_TIME_DOMAIN;
props_out.iLength = pm.iNumFrames * (unsigned int)( pm.iBlockLength );
props_out.iChannels = 1;
ITAAudiofileWriter* writer_out = ITAAudiofileWriter::create( pm.sWAVOutFilePath, props_out );
ITAStreamInfo oState;
......@@ -170,20 +168,20 @@ void run_benchmark( const ParameterSet& pm, const std::string& sName )
// Add new samples
psbInput->write( pIntputStream->GetBlockPointer( 0, &oState ), pm.iBlockLength );
swBenchmark.start();
pFIRFilterEnginge->Process( psbInput->GetData(), sfTemp[ 0 ].GetData() );
swBenchmark.stop();
swBenchmark.start( );
pFIRFilterEnginge->Process( psbInput->GetData( ), sfTemp[0].GetData( ) );
swBenchmark.stop( );
INIFileWriteDouble( "ComputationMean", swBenchmark.mean() );
INIFileWriteDouble( "ComputationStdDev", swBenchmark.std_deviation() );
INIFileWriteDouble( "ComputationMinimum", swBenchmark.minimum() );
INIFileWriteDouble( "ComputationMaximum", swBenchmark.maximum() );
INIFileWriteDouble( "ComputationScalingApproximation", swBenchmark.mean() * pm.iScalingApproximation );
INIFileWriteDouble( "ComputationMean", swBenchmark.mean( ) );
INIFileWriteDouble( "ComputationStdDev", swBenchmark.std_deviation( ) );
INIFileWriteDouble( "ComputationMinimum", swBenchmark.minimum( ) );
INIFileWriteDouble( "ComputationMaximum", swBenchmark.maximum( ) );
INIFileWriteDouble( "ComputationScalingApproximation", swBenchmark.mean( ) * pm.iScalingApproximation );
writer_out->write( &sfTemp, sfTemp.GetLength() );
writer_out->write( &sfTemp, sfTemp.GetLength( ) );
n++;
pIntputStream->IncrementBlockPointer();
pIntputStream->IncrementBlockPointer( );
if( n % ( pm.iNumFrames / 10 ) == 0 )
cout << ".";
......
#include "NUPCFilterComponentBenchmark.h"
#include <cmath>
#include <ITAFastMath.h>
#include <ITAHPT.h>
#include <ITANUPConvolution.h>
#include <stdio.h>
#include <ITAStopWatch.h>
#include <cmath>
#include <cstdlib>
#include <stdio.h>
#include <time.h>
#include <vector>
#include <ITAHPT.h>
#include <ITAStopWatch.h>
using namespace std;
// Puffergren welche von Interesse sind (0 signalisiert das Ende der Liste}
unsigned int buffersizes[] = { 64, 128, 256, 512, 0 };
//unsigned int buffersizes[] = {256, 0};
// unsigned int buffersizes[] = {256, 0};
// IR-Lngen in Sekunden welche von Interesse sind (0 signalisiert das Ende der Liste}
//double ir_durations[] = {1.0, 0};
//double ir_durations[] = {0.1, 0.25, 0.5, 1.0, 1.5, 2.0, 0};
// double ir_durations[] = {1.0, 0};
// double ir_durations[] = {0.1, 0.25, 0.5, 1.0, 1.5, 2.0, 0};
double ir_durations[] = { 0.1, 0.25, 0.5, 1.0, 1.5, 2.0, 3.0, 5.0, 7.5, 10.0, 15.0, 20.0, 30.0, 0 };
// IR-Lngen fr segmentierten Test
......@@ -28,73 +26,75 @@ double segload_ir_durations[] = { 0.5, 1.0, 1.5, 2.0, 3.0, 5.0, 7.5, 10.0, 15.0,
// Lnge des ersten Segments (Samples)
unsigned int first_part_length = 7000; // Samples
const double samplerate = 44100.0;
const double samplerate = 44100.0;
void benchmarkFilterComponentCreation()
void benchmarkFilterComponentCreation( )
{
vector<double> vIRDurations;
unsigned int i = 0;
while( ir_durations[ i ] != 0 ) vIRDurations.push_back( ir_durations[ i++ ] );
while( ir_durations[i] != 0 )
vIRDurations.push_back( ir_durations[i++] );
vector<unsigned int> vBuffersizes;
i = 0;
while( buffersizes[ i ] != 0 ) vBuffersizes.push_back( buffersizes[ i++ ] );
while( buffersizes[i] != 0 )
vBuffersizes.push_back( buffersizes[i++] );
unsigned int n = 30;
ITAHPT_init();
ITAHPT_init( );
unsigned int j;
unsigned int k; // Schleifenzhler
unsigned int b; // Puffergre
double d; // Dauer der Impulsantwort
unsigned int k; // Schleifenzhler
unsigned int b; // Puffergre
double d; // Dauer der Impulsantwort
ITAStopWatch sw;
vector< vector<double> > results;
vector<vector<double> > results;
// Zufallsgenerator initialisieren
srand( ( unsigned int ) time( NULL ) );
srand( (unsigned int)time( NULL ) );
for( i = 0; i < vBuffersizes.size(); i++ )
for( i = 0; i < vBuffersizes.size( ); i++ )
{
b = vBuffersizes[ i ];
b = vBuffersizes[i];
vector<double> v;
for( j = 0; j < vIRDurations.size(); j++ )
for( j = 0; j < vIRDurations.size( ); j++ )
{
d = vIRDurations[ j ];
d = vIRDurations[j];
// Anzahl der Samples der IR bestimmen
unsigned int l = ( unsigned int ) ceil( d*samplerate );
unsigned int l = (unsigned int)ceil( d * samplerate );
// Falter erzeugen
ITANUPC::IConvolution* pConv = ITANUPC::IConvolution::create( samplerate, 1, b, l );
float* pfLeft = fm_falloc( l, false );
float* pfRight = fm_falloc( l, false );
float* pfLeft = fm_falloc( l, false );
float* pfRight = fm_falloc( l, false );
// Speicher mit Zufallszahlen initialisieren
for( k = 0; k < l; k++ )
pfLeft[ k ] = pfRight[ k ] = ( float ) rand() / ( float ) RAND_MAX;
pfLeft[k] = pfRight[k] = (float)rand( ) / (float)RAND_MAX;
// Filterkomponente erzeugen
ITANUPC::C* pFC = pConv->createFilterComponent( 0, l, 0, 0, 0, 0 );
// Mess-Vorlauf zur Einspielung des Systems
for( k = 0; k < 3; k++ );
for( k = 0; k < 3; k++ )
;
{
sw.start();
sw.start( );
ITANUPC::CFilterComponent* pFC = pConv->createFilterComponent( 0, l, pfLeft, l, pfRight, l );
sw.stop();
pFC->destroy();
sw.stop( );
pFC->destroy( );
}
// Eigentliche Messschleife:
sw.reset();
sw.reset( );
for( k = 0; k < n; k++ )
{
sw.start();
sw.start( );
ITANUPC::CFilterComponent* pFC = pConv->createFilterComponent( 0, l, pfLeft, l, pfRight, l );
sw.stop();
pFC->destroy();
sw.stop( );
pFC->destroy( );
}
// Speicher freigeben und Falter lschen
......@@ -103,10 +103,10 @@ void benchmarkFilterComponentCreation()
delete pConv;
// Infos ausgeben
printf( "\nbs = %d, dur = %0.2f s = %d samples\nmin = %0.12f s\navg = %0.12f s\nmax = %0.12f s\ncyc = %d\n\n",
b, d, l, sw.minimum(), sw.mean(), sw.maximum(), sw.cycles() );
printf( "\nbs = %d, dur = %0.2f s = %d samples\nmin = %0.12f s\navg = %0.12f s\nmax = %0.12f s\ncyc = %d\n\n", b, d, l, sw.minimum( ), sw.mean( ),
sw.maximum( ), sw.cycles( ) );
v.push_back( sw.mean() );
v.push_back( sw.mean( ) );
}
results.push_back( v );
}
......@@ -114,62 +114,64 @@ void benchmarkFilterComponentCreation()
// Ergebnisse ausgeben
printf( "\n\n\nErzeugen von FCs:\n\n" );
printf( "IRL / BS \t" );
for( j = 0; j < vBuffersizes.size(); j++ ) printf( "%6d \t", vBuffersizes[ j ] );
for( j = 0; j < vBuffersizes.size( ); j++ )
printf( "%6d \t", vBuffersizes[j] );
printf( "\n" );
for( i = 0; i < vIRDurations.size(); i++ )
for( i = 0; i < vIRDurations.size( ); i++ )
{
printf( "%0.3f s \t", vIRDurations[ i ] );
for( j = 0; j < vBuffersizes.size(); j++ ) printf( "%0.6f s \t", results[ j ][ i ] );
printf( "%0.3f s \t", vIRDurations[i] );
for( j = 0; j < vBuffersizes.size( ); j++ )
printf( "%0.6f s \t", results[j][i] );
printf( "\n" );
}
}
void benchmarkFilterComponentLoad() {
void benchmarkFilterComponentLoad( )
{
vector<double> vIRDurations;
unsigned int i = 0;
while( ir_durations[ i ] != 0 )
vIRDurations.push_back( ir_durations[ i++ ] );
while( ir_durations[i] != 0 )
vIRDurations.push_back( ir_durations[i++] );
vector<unsigned int> vBuffersizes;
i = 0;
while( buffersizes[ i ] != 0 )
vBuffersizes.push_back( buffersizes[ i++ ] );
while( buffersizes[i] != 0 )
vBuffersizes.push_back( buffersizes[i++] );
unsigned int n = 30;
ITAHPT_init();
ITAHPT_init( );
unsigned int j;
unsigned int k; // Schleifenzhler
unsigned int b; // Puffergre
double d; // Dauer der Impulsantwort
unsigned int k; // Schleifenzhler
unsigned int b; // Puffergre
double d; // Dauer der Impulsantwort
ITAStopWatch sw;
vector< vector<double> > results;
vector<vector<double> > results;
// Zufallsgenerator initialisieren
srand( time( NULL ) );
for( i = 0; i < vBuffersizes.size(); i++ )
for( i = 0; i < vBuffersizes.size( ); i++ )
{
b = vBuffersizes[ i ];
b = vBuffersizes[i];
vector<double> v;
for( j = 0; j < vIRDurations.size(); j++ )
for( j = 0; j < vIRDurations.size( ); j++ )
{
d = vIRDurations[ j ];
d = vIRDurations[j];
// Anzahl der Samples der IR bestimmen
unsigned int l = ( unsigned int ) ceil( d*samplerate );
unsigned int l = (unsigned int)ceil( d * samplerate );
// Falter erzeugen
ITANUPC::IConvolution* pConv = ITANUPC::IConvolution::create( NULL, samplerate, b, l );
float* pfLeft = fm_falloc( l, false );
float* pfRight = fm_falloc( l, false );
float* pfLeft = fm_falloc( l, false );
float* pfRight = fm_falloc( l, false );
// Speicher mit Zufallszahlen initialisieren
for( k = 0; k < l; k++ )
pfLeft[ k ] = pfRight[ k ] = ( float ) rand() / ( float ) RAND_MAX;
pfLeft[k] = pfRight[k] = (float)rand( ) / (float)RAND_MAX;
// Filterkomponente erzeugen
ITANUPC::CFilterComponent* pFC = pConv->createFilterComponent( 0, l, 0, 0, 0, 0 );
......@@ -177,18 +179,18 @@ void benchmarkFilterComponentLoad() {
// Mess-Vorlauf zur Einspielung des Systems
for( k = 0; k < 3; k++ )
{
sw.start();
sw.start( );
pFC->load( pfLeft, l, pfRight, l );
sw.stop();
sw.stop( );
}
// Eigentliche Messschleife:
sw.reset();
for( k = 0; k < n; k++ )
sw.reset( );
for( k = 0; k < n; k++ )
{
sw.start();
sw.start( );
pFC->load( pfLeft, l, pfRight, l );
sw.stop();
sw.stop( );
}
// Speicher freigeben und Falter lschen
......@@ -197,10 +199,10 @@ void benchmarkFilterComponentLoad() {
delete pConv;
// Infos ausgeben
printf( "\nbs = %d, dur = %0.2f s = %d samples\nmin = %0.12f s\navg = %0.12f s\nmax = %0.12f s\ncyc = %d\n\n",
b, d, l, sw.minimum(), sw.mean(), sw.maximum(), sw.cycles() );
printf( "\nbs = %d, dur = %0.2f s = %d samples\nmin = %0.12f s\navg = %0.12f s\nmax = %0.12f s\ncyc = %d\n\n", b, d, l, sw.minimum( ), sw.mean( ),
sw.maximum( ), sw.cycles( ) );
v.push_back( sw.mean() );
v.push_back( sw.mean( ) );
}
results.push_back( v );
}
......@@ -208,60 +210,64 @@ void benchmarkFilterComponentLoad() {
// Ergebnisse ausgeben
printf( "\n\n\nLaden von FCs:\n\n" );
printf( "IRL / BS \t" );
for( j = 0; j < vBuffersizes.size(); j++ ) printf( "%6d \t", vBuffersizes[ j ] );
for( j = 0; j < vBuffersizes.size( ); j++ )
printf( "%6d \t", vBuffersizes[j] );
printf( "\n" );
for( i = 0; i < vIRDurations.size(); i++ )
for( i = 0; i < vIRDurations.size( ); i++ )
{
printf( "%0.3f s \t", vIRDurations[ i ] );
for( j = 0; j < vBuffersizes.size(); j++ ) printf( "%0.6f s \t", results[ j ][ i ] );
printf( "%0.3f s \t", vIRDurations[i] );
for( j = 0; j < vBuffersizes.size( ); j++ )
printf( "%0.6f s \t", results[j][i] );
printf( "\n" );
}
}
void benchmarkFilterComponentSegLoad()
void benchmarkFilterComponentSegLoad( )
{
vector<double> vIRDurations;