right now you can just export your code and run it inside this boilerplate Bela project provided by Cycling 74: https://github.com/Cycling74/genBela.
Unfortunately, from my experience you do not get a great performance improvement with gen
over libpd
, and it is way slower than Heavy. This is most likely because the code generated by gen works on single-samples buffers, therefore making it harder for the compiler to vectorize it. This was like 6 months ago, perhaps things have improved now.
Some of my notes on how to make it slightly faster:
numerical constants exported from gen do not have the "f" suffix and as such are treated as double, while they should be of the same type of sample_t. Maybe the most portable way would be to always prepend the constants with (sample_t) in the gen-generated code, but right now you have to either do it manually (
sed
is your friend), or usegcc
instead ofclang
and provide the-fsingle-precision-constant
flag (not supported byclang
).on Bela (and other platforms, such as the Owl) denormals are flushed to zero in hardware, so there is no point in checking for them.
Therefore we need a way to disable fixdenorm altogether. I can save 5% CPU by replacinginline t_sample fixdenorm(t_sample v) { return GENLIB_FIX_DENORM(v); }
with
#define fixdenorm(v) (v)
I also had some issues with gen
- generated code using stdlib math functions instead of the optimized ones that it tried to provide, so check the output of the pre-processor and see what it is actually calling.