C++ for P2?
David Betz
Posts: 14,516
in Propeller 2
Anyone remember who was working on C++ for P2? I downloaded the source code for the Mutable Instruments Eurorack modules and, unfortunately, the code is all in C++. I had hoped it might be possible to get it to run on P2.
Comments
I'm sure @"Dave Hein" had something that worked, right?
Hopefully, Parallax will pay Eric enough for his work to motive him to add a useful subset of C++ to FlexGUI.
The only C++ compiler for P2 I'm aware of is riscvp2: https://github.com/totalspectrum/riscvp2.
In most benchmarks I've run riscvp2 is the highest performing C compiler for the P2. The only case where I've seen it slower is in micropython, where it was a little slower than @rogloh's p2gcc version of micropython (but at least riscvp2 was considerably smaller ). So yes, I think it would work well for DSP like tasks.
For example, Heater's old fft-bench benchmark gave the following results when I tested it back in February:
Note that the actual "us" time is bogus, we're actually just reporting elapsed cycles divided by the fixed constant 80 (the original test was on P1 at 80 MHz, so that's how the time is computed). But the relative timings should be valid. I'm surprised at p2gcc's relatively poor result on this particular test. It's not representative, usually p2gcc and fastspin are around the same speed.
@ntosme2
Honestly riscvp2 should install just fine on MacOSX, or at least it'll be no harder than on Linux. Start with a riscvp2 cross compiler for Mac (like: https://github.com/ilg-archived/riscv-none-gcc/releases/download/v8.2.0-2.2-20190521/gnu-mcu-eclipse-riscv-none-gcc-8.2.0-2.2-20190521-0004-macos.tgz), install it someplace convenient (does Mac have /opt? I used /opt/riscv-none-gcc) and then edit the riscvp2 Makefile to reflect where the binaries are and what the prefix for them is. You'll also have to make the FASTSPIN= variable point to your fastspin. Then just do "make install" in the riscvp2 directory.
The riscvp2 Makefile only adds a few additional files to the existing risc-v toolchain. Basically it's all just linker scripts; from the risc-v compiler's point of view the P2 has a special crt0.o that's the first think linked and executed. But what "really" happens is that crt0.o has P2 code that the P2 executes to start the JIT compiler.
Maybe I'll try the binary installation.