Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement ec and cm flag for rust #1072

Open
wants to merge 6 commits into
base: master-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,15 @@ void InstructionsCompiler::compileMultiSignal(Tree L)
string name;
if (gGlobal->gOutputLang == "rust") {
name = subst("*output$0", T(index));
pushComputeDSPMethod(IB::genStoreStackVar(name, res));
if (gGlobal->gComputeMix) {
// take the cpp code and remove the the loop
ValueInst* res1 = IB::genAdd(res, IB::genLoadStackVar(name));
pushComputeDSPMethod(IB::genStoreStackVar(name, res1));
} else {
pushComputeDSPMethod(IB::genStoreStackVar(name, res));
}


} else if (gGlobal->gOutputLang == "jax") {
res = CS(sig);
string result_var = "_result" + to_string(index);
Expand Down
11 changes: 11 additions & 0 deletions compiler/generator/rust/rust_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,17 @@ void RustCodeContainer::produceClass()
// Parameter getter/setter
produceParameterGetterSetter(n + 1, parameterLookup);

// Control
if (gGlobal->gExtControl) {
tab(n + 1, *fOut);
tab(n + 1, *fOut);
*fOut << "fn control(&mut self) {";
tab(n + 2, *fOut);
generateControlDeclarations(&fCodeProducer);
back(1, *fOut);
*fOut << "}";
}

// Compute
generateCompute(n + 1);
generateComputeInterface(n + 1);
Expand Down
4 changes: 2 additions & 2 deletions compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,9 @@ bool global::processCmdline(int argc, const char* argv[])
"backends\n");
}

if (gExtControl && gOutputLang != "cpp" && gOutputLang != "c" && gOutputLang != "cmajor") {
if (gExtControl && gOutputLang != "cpp" && gOutputLang != "c" && gOutputLang != "cmajor" && gOutputLang != "rust") {
throw faustexception(
"ERROR : '-ec' option can only be used with 'cpp', 'c' or 'cmajor' "
"ERROR : '-ec' option can only be used with 'cpp', 'c', 'cmajor' or 'rust' "
"backends\n");
}

Expand Down
5 changes: 3 additions & 2 deletions tests/impulse-tests/Make.interp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ help:
@echo " 'interp' (default): check the double output using the interp backend"
@echo
@echo "Options:"
@echo " 'outdir' : define the output directory (default to 'llvm')"
@echo " 'outdir' : define the output directory (default to 'llvm')"
@echo " 'FAUSTOPTIONS' : define additional faust options (empty by default)"
@echo " 'precision' : define filesCompare expected precision (empty by default)"

Expand All @@ -62,7 +62,8 @@ impulseinterp: $(SRCDIR)/impulseinterp.cpp $(LIB)
#########################################################################
# rules for interp

# Specific rule to test 'control' primitive that currently uses the -lang ocpp backend (still compiling in scalar mode...)
# Specific rule to test 'control' primitive that currently uses the -lang ocpp backend
# (still compiling in scalar mode...)
ir/$(outdir)/control.ir: dsp/control.dsp reference/control.ir
@echo "Cannot be tested with the Interp backend"

Expand Down
142 changes: 41 additions & 101 deletions tests/impulse-tests/Make.rust
Original file line number Diff line number Diff line change
Expand Up @@ -20,109 +20,49 @@ precision ?= # filesCompare precision (empty by default)
.PHONY: test
.DELETE_ON_ERROR:

alldspfiles := $(wildcard dsp/*.dsp)
allirfiles = $(alldspfiles:dsp/%.dsp=ir/rust/%.ir)

all: filesCompare

# Currently this lists all dependencies manually to allow for easily enabling/disabling
# individual test cases. Later this can be replaced by the wildcard dependency:
# all: $(allirfiles)

all: ir/rust/APF.ir
all: ir/rust/BPF.ir
all: ir/rust/HPF.ir
all: ir/rust/LPF.ir
all: ir/rust/UITester.ir
all: ir/rust/bandfilter.ir
all: ir/rust/bargraph.ir
all: ir/rust/bs.ir
all: ir/rust/capture.ir
all: ir/rust/carre_volterra.ir
all: ir/rust/comb_bug_exp.ir
all: ir/rust/comb_delay1.ir
all: ir/rust/comb_delay2.ir
all: ir/rust/constant.ir
all: ir/rust/cubic_distortion.ir
all: ir/rust/dbmeter.ir
all: ir/rust/delays.ir
all: ir/rust/echo_bug.ir
all: ir/rust/echo.ir
all: ir/rust/freeverb.ir
all: ir/rust/gate_compressor.ir
all: ir/rust/harpe.ir
all: ir/rust/highShelf.ir
all: ir/rust/karplus.ir
all: ir/rust/karplus32.ir
all: ir/rust/lfboost.ir
all: ir/rust/logical.ir
all: ir/rust/lowboost.ir
all: ir/rust/lowcut.ir
all: ir/rust/lowShelf.ir
all: ir/rust/math.ir
all: ir/rust/math_simp.ir
all: ir/rust/matrix.ir
all: ir/rust/midi_tester.ir
all: ir/rust/mixer.ir
all: ir/rust/modulations.ir
all: ir/rust/multibandfilter.ir
all: ir/rust/noise.ir
all: ir/rust/noiseabs.ir
all: ir/rust/noisemetadata.ir
all: ir/rust/notch.ir
all: ir/rust/osc_enable.ir
all: ir/rust/osc.ir
all: ir/rust/osci.ir
all: ir/rust/panpot.ir
all: ir/rust/parametric_eq.ir
all: ir/rust/peakingEQ.ir
all: ir/rust/peakNotch.ir
all: ir/rust/phaser_flanger.ir
all: ir/rust/pitch_shifter.ir
all: ir/rust/pow.ir
all: ir/rust/precision.ir
#all: ir/rust/prefix.ir
all: ir/rust/priority.ir
all: ir/rust/priority1.ir
all: ir/rust/quadecho.ir
all: ir/rust/reverb_designer.ir
all: ir/rust/reverb_tester.ir
all: ir/rust/smoothdelay.ir
#all: ir/rust/sound.ir
all: ir/rust/spat.ir
all: ir/rust/spectral_level.ir
all: ir/rust/spectral_tilt.ir
all: ir/rust/stereoecho.ir
all: ir/rust/switcher.ir
all: ir/rust/table.ir
all: ir/rust/table1.ir
all: ir/rust/table2.ir
all: ir/rust/tapiir.ir
all: ir/rust/tester.ir
all: ir/rust/tester2.ir
all: ir/rust/tf_exp.ir
all: ir/rust/thru_zero_flanger.ir
all: ir/rust/UITester.ir
all: ir/rust/vcf_wah_pedals.ir
all: ir/rust/virtual_analog_oscillators.ir
all: ir/rust/volume.ir
all: ir/rust/vumeter.ir
all: ir/rust/waveform1.ir
all: ir/rust/waveform2.ir
all: ir/rust/waveform3.ir
all: ir/rust/waveform4.ir
all: ir/rust/waveform5.ir
all: ir/rust/waveform6.ir
all: ir/rust/zita_rev1.ir

filesCompare:
dspfiles := $(wildcard dsp/*.dsp)
listfiles = $(dspfiles:dsp/%.dsp=ir/$1/%.ir)

#########################################################################
all: filesCompare ir/$(outdir) $(call listfiles,$(outdir))

#########################################################################
# output directories
ir/$(outdir):
mkdir -p ir/$(outdir)


#########################################################################
# tools
filesCompare:
$(MAKE) filesCompare

#########################################################################
# rules
ir/$(outdir)/%.ir: reference/%.ir
mkdir -p ir/$(outdir)
$(FAUST) -lang rust $(FAUSTOPTIONS) -i -A ../../architecture -a archs/rust/architecture.rs dsp/$*.dsp -o archs/rust/src/bin/$*.rs
#cd archs/rust/ && cargo run --bin $* ../../$@

ir/$(outdir)/sound.ir: dsp/sound.dsp
$(FAUST) -lang rust $(FAUSTOPTIONS) dsp/sound.dsp -o archs/rust/src/bin/sound.rs > $@ 2>&1 || (echo "expected failure")
grep "ERROR : 'soundfile' primitive not yet supported for Rust" $@

ir/rust/ec/bs.ir: dsp/bs.dsp
$(FAUST) -lang rust $(FAUSTOPTIONS) dsp/bs.dsp -o archs/rust/src/bin/bs.rs > $@ 2>&1 || (echo "expected failure")
grep "ERROR : accessing foreign variable 'count' is not allowed in this compilation mode" $@

ir/rust/vec4/osc_enable.ir: dsp/osc_enable.dsp
$(FAUST) -lang rust $(FAUSTOPTIONS) dsp/osc_enable.dsp -o archs/rust/src/bin/osc_enable.rs > $@ 2>&1 || (echo "expected failure")
grep "ERROR : 'control/enable' can only be used in scalar mode" $@

ir/rust/vec32/osc_enable.ir: dsp/osc_enable.dsp
$(FAUST) -lang rust $(FAUSTOPTIONS) dsp/osc_enable.dsp -o archs/rust/src/bin/osc_enable.rs > $@ 2>&1 || (echo "expected failure")
grep "ERROR : 'control/enable' can only be used in scalar mode" $@

ir/rust/vec4/prefix.ir:
echo "todo fix bug #1071 to test dsp/prefix.dsp"

ir/rust/vec32/prefix.ir:
echo "todo fix bug #1071 to test dsp/prefix.dsp"

ir/$(outdir)/%.ir: dsp/%.dsp reference/%.ir
$(FAUST) -lang rust $(FAUSTOPTIONS) dsp/$*.dsp -o archs/rust/src/bin/$*.rs
cd archs/rust/ && cargo run --release --bin $* ../../$@
$(COMPARE) $@ reference/$(notdir $@) $(precision)
$(COMPARE) $@ reference/$(notdir $@) $(precision) || (rm -f $@; false)
13 changes: 6 additions & 7 deletions tests/impulse-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,12 @@ interp1:
#########################################################################
# Rust backend
rust:
$(MAKE) -f Make.rust FAUSTOPTIONS="-I dsp -double"
rm -rf ir/rust
$(MAKE) -f Make.rust FAUSTOPTIONS="-I dsp -double -fp"
rm -rf ir/rust
$(MAKE) -f Make.rust FAUSTOPTIONS="-I dsp -double -vec -vs 4"
rm -rf ir/rust
$(MAKE) -f Make.rust FAUSTOPTIONS="-I dsp -double -vec -vs 32"
$(MAKE) -f Make.rust outdir=rust/ec FAUSTOPTIONS="-I ../../libraries/ -double -ec -a archs/rust/architecture.rs"
$(MAKE) -f Make.rust outdir=rust/cm FAUSTOPTIONS="-I ../../libraries/ -double -cm -a archs/rust/architecture_cm.rs"
$(MAKE) -f Make.rust outdir=rust/no FAUSTOPTIONS="-I ../../libraries/ -double -a archs/rust/architecture_normal.rs"
$(MAKE) -f Make.rust outdir=rust/fp FAUSTOPTIONS="-I ../../libraries/ -double -fp -a archs/rust/architecture_normal.rs"
$(MAKE) -f Make.rust outdir=rust/vec4 FAUSTOPTIONS="-I ../../libraries/ -double -vec -vs 4 -a archs/rust/architecture_normal.rs"
$(MAKE) -f Make.rust outdir=rust/vec32 FAUSTOPTIONS="-I ../../libraries/ -double -vec -vs 32 -a archs/rust/architecture_normal.rs"

#########################################################################
# Cmajor backend
Expand Down
2 changes: 2 additions & 0 deletions tests/impulse-tests/archs/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ default-boxed = "0.2"
[features]
default = ["default-boxed"]
default-boxed = []

[workspace]
Loading
Loading