[Csnd] Efficiency of faustgen vs faust2csound

I did an experiment to compare the runtime speed of the same DSP algorithm (a physical model of a guitar) implemented using Csound’s “faustgen” opcodes, versus a plugin opcode implemented using Faust’s “faust2csound” tool.

The faustgen version runs about 15% than the compiled C++ version. Of course using the faustgen version assumes that one’s computer has both LLVM and an installation of Faust with the LLVM back end.

Details here: https://github.com/gogins/csound-extended/issues/187.

Regards,
Mike

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

!5% slower or faster?

Faster by the looks of it (87% of the time of the compiled C++ code)

It’s an interesting result, I’d have thought the opposite would be the case, it just shows how much LLVM has
come along.

If we had the resources to do it, a LLVM compiler for UDOs would have been great to have.

I also had the thought of LLVM for Csound orchestra code, and also didn’t feel that I had the resources to do it.

One great thing about that though would be cross-platform native speed. In fact I think that would be a really great thing.

Another approach would be – just write UDOs in C or C++ and embed them in the Csound orchestra and compile them with LLVM.

Regards,
Mike

For Csound-language UDOs we would need to write a compiler for it. We could
reuse the parser, so it’s possible but it would not be easy.

My thinking is that it may be possible to first do something that would support arithmetic in init,
control, and audio rates. I had a sketch for it in my head, based on something I discussed in Italy.
Once that is working, then start supporting some opcodes like oscillators.

But what you’re saying is something I never thought of before, a just-in-time C/C++ compiler.
It may be achievable.

another thing to consider it is that (I am supposing) your C++ is gcc and LLVM is a different compiler.
Maybe it’s a little better. A clang++ vs g++ comparison should demonstrate that too.

I would argue that such a small difference is probably due to compilation flags. llvm can compile to native whereas the faust2csound script is really very poorly configured and should not be used for anything serious.