Skip to content

Commit

Permalink
Add 'reference-fir' and 'test-fir' targets in impulse-tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Aug 9, 2024
1 parent 0bc92e5 commit 305460d
Show file tree
Hide file tree
Showing 93 changed files with 127,257 additions and 5 deletions.
7 changes: 4 additions & 3 deletions compiler/generator/fir/fir_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ void FIRCodeContainer::dumpMemory(ostream* dst)
*dst << "Total heap size = " << heap_counter3.fSizeBytes + total_heap_size << " bytes"
<< endl;
*dst << "Stack size in compute = " << stack_counter.fSizeBytes << " bytes"
<< "\n\n";
<< endl;

*dst << "======= Variable access in Control ==========" << endl << endl;
*dst << endl << "======= Variable access in Control ==========" << endl << endl;
{
StructInstVisitor struct_visitor;
fDeclarationInstructions->accept(&struct_visitor);
Expand All @@ -240,7 +240,8 @@ void FIRCodeContainer::dumpMemory(ostream* dst)
<< endl;
}
}
*dst << "======= Variable access in compute control ==========" << endl << endl;

*dst << endl << "======= Variable access in compute control ==========" << endl << endl;
{
StructInstVisitor struct_visitor;
fDeclarationInstructions->accept(&struct_visitor);
Expand Down
7 changes: 7 additions & 0 deletions tests/impulse-tests/Make.ref
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reffiles := $(patsubst dsp/%.dsp, $(refdir)/%.ir, $(dspfiles))
boxfiles := $(patsubst dsp/%.dsp, $(refdir)/%.box, $(dspfiles))
sigfiles := $(patsubst dsp/%.dsp, $(refdir)/%.sig, $(dspfiles))
typefiles := $(patsubst dsp/%.dsp, $(refdir)/%.type, $(dspfiles))
firfiles := $(patsubst dsp/%.dsp, $(refdir)/%.fir, $(dspfiles))
cppfiles := $(patsubst dsp/%.dsp, $(refdir)/%.cpp1, $(dspfiles))

listintermediate = $(dspfiles:dsp/%.dsp=$1/%) $(dspfiles:dsp/%.dsp=$1/%.cpp) $(dspfiles:dsp/%.dsp=$1/vec/%) $(dspfiles:dsp/%.dsp=$1/vec/%.cpp) $(dspfiles:dsp/%.dsp=$1/sched/%) $(dspfiles:dsp/%.dsp=$1/sched/%.cpp)
Expand All @@ -47,6 +48,8 @@ reference-signal: $(sigfiles)

reference-type: $(typefiles)

reference-fir: $(firfiles)

reference-cpp: $(cppfiles)

help:
Expand Down Expand Up @@ -85,6 +88,10 @@ $(refdir)/%.sig: dsp/%.dsp
$(refdir)/%.type: dsp/%.dsp
$(FAUST) $(FAUSTOPTIONS) -norm2 $< > $@ ; echo $<

# rules for reference-fir
$(refdir)/%.fir: dsp/%.dsp
$(FAUST) -lang fir $(FAUSTOPTIONS) $< > $@ ; echo $<

# rules for reference-cpp
$(refdir)/%.cpp1: dsp/%.dsp
$(FAUST) $(FAUSTOPTIONS) $< > $@ ; echo $<
Expand Down
12 changes: 10 additions & 2 deletions tests/impulse-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ reference-signal:
reference-type:
cd reference && rm -f *.type
export FAUST_DEBUG=FAUST_DTREE; $(MAKE) -f Make.ref reference-type FAUSTOPTIONS="-I dsp"

reference-fir:
cd reference && rm -f *.fir
export FAUST_DEBUG=FAUST_DTREE; $(MAKE) -f Make.ref reference-fir FAUSTOPTIONS="-I dsp"

reference-cpp:
cd reference && rm -f *.cpp1
Expand All @@ -449,11 +453,15 @@ test-signal-wn:
test-signal:
export FAUST_DEBUG=FAUST_DTREE; cd dsp && ./sig-script *.dsp

test-type:
export FAUST_DEBUG=FAUST_DTREE; cd dsp && ./type-script *.dsp

test-fir:
export FAUST_DEBUG=FAUST_DTREE; cd dsp && ./fir-script *.dsp

test-cpp:
export FAUST_DEBUG=FAUST_DTREE; cd dsp && ./cpp-script *.dsp

test-type:
export FAUST_DEBUG=FAUST_DTREE; cd dsp && ./type-script *.dsp

#########################################################################
# Benchmark using faustbench-llvm and faustbench
Expand Down
6 changes: 6 additions & 0 deletions tests/impulse-tests/dsp/fir-script
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
for f in $@
do
echo "Processing $f file..."
faust -lang fir $f -o ${f%.dsp}.fir
diff ${f%.dsp}.fir ../reference/${f%.dsp}.fir ; echo Done
done
211 changes: 211 additions & 0 deletions tests/impulse-tests/reference/APF.fir
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
======= Container "mydsp" ==========

======= External types declaration ==========

DeclareStructTypeInst(StructType<"Soundfile",("void*", fBuffers)("int*", fLength)("int*", fSR)("int*", fOffset)("int", fChannels)("int", fParts)("int", fIsDouble)>)

======= Sub container begin ==========

======= Sub container end ==========

======= User Interface begin ==========

BlockInst
OpenVerticalBox("APF")
AddHorizontalSlider("Freq", fHslider0, 1e+03f, 1e+02f, 1e+04f, 1.0f)
AddHorizontalSlider("Q", fHslider1, 1.0f, 0.01f, 1e+02f, 0.01f)
CloseboxInst
EndBlockInst

======= User Interface end ==========

======= Global declarations begin ==========

BlockInst
DeclareFunInst("float", "max_f", "float", dummy0, "float", dummy1)
DeclareFunInst("float", "min_f", "float", dummy0, "float", dummy1)
DeclareFunInst("float", "sinf", "float", dummy0)
DeclareFunInst("float", "cosf", "float", dummy0)
EndBlockInst

======= Global declarations end ==========

======= DSP struct begin ==========

DeclareStructTypeInst(StructType<"mydsp",("int", fSampleRate)("float", fConst0)("FAUSTFLOAT", fHslider0)("FAUSTFLOAT", fHslider1)("float[3]", fRec0)>)

======= DSP struct end ==========

DeclareFunInst("int", "getNumInputs")
BlockInst
RetInst(Int32(1))
EndBlockInst
EndDeclare

DeclareFunInst("int", "getNumOutputs")
BlockInst
RetInst(Int32(1))
EndBlockInst
EndDeclare

======= Init begin ==========

BlockInst
StoreVarInst(Address(fSampleRate, kStruct), LoadVarInst(Address(sample_rate, kFunArgs)))
StoreVarInst(Address(fConst0, kStruct), BinopInst("/", Float(6.2831855f), FunCallInst("min_f", Float(1.92e+05f), FunCallInst("max_f", Float(1.0f), CastInst("float", LoadVarInst(Address(fSampleRate, kStruct)))))))
EndBlockInst

======= Init end ==========

======= ResetUI begin ==========

BlockInst
StoreVarInst(Address(fHslider0, kStruct), CastInst("FAUSTFLOAT", Double(1e+03f)))
StoreVarInst(Address(fHslider1, kStruct), CastInst("FAUSTFLOAT", Double(1.0f)))
EndBlockInst

======= ResetUI end ==========

======= Clear begin ==========

BlockInst
ForLoopInst
DeclareVarInst("int", l0, kLoop, Int32(0))
BinopInst("<", LoadVarInst(Address(l0, kLoop)), Int32(3))
StoreVarInst(Address(l0, kLoop), BinopInst("+", LoadVarInst(Address(l0, kLoop)), Int32(1)))
BlockInst
StoreVarInst(Address(fRec0, kStruct)[LoadVarInst(Address(l0, kLoop))], Float(0.0f))
EndBlockInst
EndForLoopInst
EndBlockInst

======= Clear end ==========

======= Compute control begin ==========

Instructions complexity : Load = 9 Store = 0 Binop = 7 [ { Real(*) = 3 } { Real(+) = 1 } { Real(-) = 1 } { Real(/) = 2 } ] Mathop = 4 [ { cosf = 1 } { max_f = 2 } { sinf = 1 } ] Numbers = 9 Declare = 7 Cast = 2 Select = 0 Loop = 0

BlockInst
DeclareVarInst("FAUSTFLOAT*", input0, kStack, LoadVarInst(Address(inputs, kFunArgs)[Int32(0)]))
DeclareVarInst("FAUSTFLOAT*", output0, kStack, LoadVarInst(Address(outputs, kFunArgs)[Int32(0)]))
DeclareVarInst("float", fSlow0, kStack, BinopInst("*", LoadVarInst(Address(fConst0, kStruct)), FunCallInst("max_f", Float(0.0f), CastInst("float", LoadVarInst(Address(fHslider0, kStruct))))))
DeclareVarInst("float", fSlow1, kStack, BinopInst("*", Float(0.5f), BinopInst("/", FunCallInst("sinf", LoadVarInst(Address(fSlow0, kStack))), FunCallInst("max_f", Float(0.001f), CastInst("float", LoadVarInst(Address(fHslider1, kStruct)))))))
DeclareVarInst("float", fSlow2, kStack, BinopInst("/", Float(1.0f), BinopInst("+", LoadVarInst(Address(fSlow1, kStack)), Float(1.0f))))
DeclareVarInst("float", fSlow3, kStack, BinopInst("-", Float(1.0f), LoadVarInst(Address(fSlow1, kStack))))
DeclareVarInst("float", fSlow4, kStack, BinopInst("*", Float(2.0f), FunCallInst("cosf", LoadVarInst(Address(fSlow0, kStack)))))
EndBlockInst

======= Compute control end ==========

======= Compute DSP begin ==========

Instructions complexity : Load = 19 Store = 5 Binop = 11 [ { Int(+) = 1 } { Int(<) = 1 } { Real(*) = 5 } { Real(+) = 1 } { Real(-) = 3 } ] Mathop = 0 Numbers = 11 Declare = 2 Cast = 2 Select = 0 Loop = 1

ForLoopInst
DeclareVarInst("int", i0, kLoop, Int32(0))
BinopInst("<", LoadVarInst(Address(i0, kLoop)), LoadVarInst(Address(count, kFunArgs)))
StoreVarInst(Address(i0, kLoop), BinopInst("+", LoadVarInst(Address(i0, kLoop)), Int32(1)))
BlockInst
DeclareVarInst("float", fTemp0, kStack, BinopInst("*", LoadVarInst(Address(fSlow4, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(1)])))
StoreVarInst(Address(fRec0, kStruct)[Int32(0)], BinopInst("-", CastInst("float", LoadVarInst(Address(input0, kStack)[LoadVarInst(Address(i0, kLoop))])), BinopInst("*", LoadVarInst(Address(fSlow2, kStack)), BinopInst("-", BinopInst("*", LoadVarInst(Address(fSlow3, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(2)])), LoadVarInst(Address(fTemp0, kStack))))))
StoreVarInst(Address(output0, kStack)[LoadVarInst(Address(i0, kLoop))], CastInst("FAUSTFLOAT", BinopInst("+", LoadVarInst(Address(fRec0, kStruct)[Int32(2)]), BinopInst("*", LoadVarInst(Address(fSlow2, kStack)), BinopInst("-", BinopInst("*", LoadVarInst(Address(fSlow3, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(0)])), LoadVarInst(Address(fTemp0, kStack)))))))
StoreVarInst(Address(fRec0, kStruct)[Int32(2)], LoadVarInst(Address(fRec0, kStruct)[Int32(1)]))
StoreVarInst(Address(fRec0, kStruct)[Int32(1)], LoadVarInst(Address(fRec0, kStruct)[Int32(0)]))
EndBlockInst
EndForLoopInst

======= Compute DSP end ==========

======= Post compute DSP begin ==========

BlockInst
EndBlockInst

======= Post compute DSP end ==========

======= Flatten FIR begin ==========

BlockInst
========== Declaration part ==========
DeclareFunInst("float", "max_f", "float", dummy0, "float", dummy1)
DeclareFunInst("float", "min_f", "float", dummy0, "float", dummy1)
DeclareFunInst("float", "sinf", "float", dummy0)
DeclareFunInst("float", "cosf", "float", dummy0)
DeclareVarInst("int", fSampleRate, kStruct)
DeclareVarInst("float", fConst0, kStruct)
DeclareVarInst("FAUSTFLOAT", fHslider0, kStruct)
DeclareVarInst("FAUSTFLOAT", fHslider1, kStruct)
DeclareVarInst("float", fRec0[3], kStruct)
========== Init method ==========
StoreVarInst(Address(fSampleRate, kStruct), LoadVarInst(Address(sample_rate, kFunArgs)))
StoreVarInst(Address(fConst0, kStruct), BinopInst("/", Float(6.2831855f), FunCallInst("min_f", Float(1.92e+05f), FunCallInst("max_f", Float(1.0f), CastInst("float", LoadVarInst(Address(fSampleRate, kStruct)))))))
StoreVarInst(Address(fHslider0, kStruct), CastInst("FAUSTFLOAT", Double(1e+03f)))
StoreVarInst(Address(fHslider1, kStruct), CastInst("FAUSTFLOAT", Double(1.0f)))
ForLoopInst
DeclareVarInst("int", l0, kLoop, Int32(0))
BinopInst("<", LoadVarInst(Address(l0, kLoop)), Int32(3))
StoreVarInst(Address(l0, kLoop), BinopInst("+", LoadVarInst(Address(l0, kLoop)), Int32(1)))
BlockInst
StoreVarInst(Address(fRec0, kStruct)[LoadVarInst(Address(l0, kLoop))], Float(0.0f))
EndBlockInst
EndForLoopInst
========== Static init method ==========
========== Subcontainers ==========
========== Control ==========
========== Compute control ==========
DeclareVarInst("FAUSTFLOAT*", input0, kStack, LoadVarInst(Address(inputs, kFunArgs)[Int32(0)]))
DeclareVarInst("FAUSTFLOAT*", output0, kStack, LoadVarInst(Address(outputs, kFunArgs)[Int32(0)]))
DeclareVarInst("float", fSlow0, kStack, BinopInst("*", LoadVarInst(Address(fConst0, kStruct)), FunCallInst("max_f", Float(0.0f), CastInst("float", LoadVarInst(Address(fHslider0, kStruct))))))
DeclareVarInst("float", fSlow1, kStack, BinopInst("*", Float(0.5f), BinopInst("/", FunCallInst("sinf", LoadVarInst(Address(fSlow0, kStack))), FunCallInst("max_f", Float(0.001f), CastInst("float", LoadVarInst(Address(fHslider1, kStruct)))))))
DeclareVarInst("float", fSlow2, kStack, BinopInst("/", Float(1.0f), BinopInst("+", LoadVarInst(Address(fSlow1, kStack)), Float(1.0f))))
DeclareVarInst("float", fSlow3, kStack, BinopInst("-", Float(1.0f), LoadVarInst(Address(fSlow1, kStack))))
DeclareVarInst("float", fSlow4, kStack, BinopInst("*", Float(2.0f), FunCallInst("cosf", LoadVarInst(Address(fSlow0, kStack)))))
========== Compute DSP ==========
ForLoopInst
DeclareVarInst("int", i0, kLoop, Int32(0))
BinopInst("<", LoadVarInst(Address(i0, kLoop)), LoadVarInst(Address(count, kFunArgs)))
StoreVarInst(Address(i0, kLoop), BinopInst("+", LoadVarInst(Address(i0, kLoop)), Int32(1)))
BlockInst
DeclareVarInst("float", fTemp0, kStack, BinopInst("*", LoadVarInst(Address(fSlow4, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(1)])))
StoreVarInst(Address(fRec0, kStruct)[Int32(0)], BinopInst("-", CastInst("float", LoadVarInst(Address(input0, kStack)[LoadVarInst(Address(i0, kLoop))])), BinopInst("*", LoadVarInst(Address(fSlow2, kStack)), BinopInst("-", BinopInst("*", LoadVarInst(Address(fSlow3, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(2)])), LoadVarInst(Address(fTemp0, kStack))))))
StoreVarInst(Address(output0, kStack)[LoadVarInst(Address(i0, kLoop))], CastInst("FAUSTFLOAT", BinopInst("+", LoadVarInst(Address(fRec0, kStruct)[Int32(2)]), BinopInst("*", LoadVarInst(Address(fSlow2, kStack)), BinopInst("-", BinopInst("*", LoadVarInst(Address(fSlow3, kStack)), LoadVarInst(Address(fRec0, kStruct)[Int32(0)])), LoadVarInst(Address(fTemp0, kStack)))))))
StoreVarInst(Address(fRec0, kStruct)[Int32(2)], LoadVarInst(Address(fRec0, kStruct)[Int32(1)]))
StoreVarInst(Address(fRec0, kStruct)[Int32(1)], LoadVarInst(Address(fRec0, kStruct)[Int32(0)]))
EndBlockInst
EndForLoopInst
========== Post compute DSP ==========
EndBlockInst

======= Flatten FIR end ==========

======= Object memory footprint ==========

Heap size int = 4 bytes
Heap size int* = 0 bytes
Heap size real = 24 bytes
Total heap size = 28 bytes
Stack size in compute = 36 bytes

======= Variable access in Control ==========

Field = fSampleRate size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fConst0 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fHslider0 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fHslider1 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fRec0 size = 3 size_bytes = 12 read = 0 write = 0 ratio = 0

======= Variable access in compute control ==========

Field = fSampleRate size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fConst0 size = 1 size_bytes = 4 read = 1 write = 0 ratio = 1
Field = fHslider0 size = 1 size_bytes = 4 read = 1 write = 0 ratio = 1
Field = fHslider1 size = 1 size_bytes = 4 read = 1 write = 0 ratio = 1
Field = fRec0 size = 3 size_bytes = 12 read = 0 write = 0 ratio = 0

======= Variable access in compute DSP ==========

Field = fSampleRate size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fConst0 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fHslider0 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fHslider1 size = 1 size_bytes = 4 read = 0 write = 0 ratio = 0
Field = fRec0 size = 3 size_bytes = 12 read = 6 write = 3 ratio = 3
Loading

0 comments on commit 305460d

Please sign in to comment.