osqp / osqp.rs

Rust interface to OSQP: The Operator Splitting QP Solver

Home Page:https://osqp.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

32bit Float Support

hpsjakob opened this issue · comments

Hi,

we're using this lib in our rust project and it's great!

Unfortunately we now need to port our project to a 32-bit platform. There 64bit floating point operations are super slow. So we would like to switch to 32-bit floats.
In the osqp itself this seems to be possible using DFLOAT=ON. We’ve tried setting this flag in the build.rs but just that did not make it 😉

Could you give us a hint how much work it will be to port the crate to 32-bit float? Or do you even know of a fort that does it?
Would you be interested in a MR to add 32-bit float support?

Regards,
Jakob

It should be pretty straightforward to add 32-bit float support. Probably just needs a feature flag which switches the definition of osqp::float and osqp_sys::osqp_float as well as setting DFLOAT. Happy to accept a PR for this.

Hi,

thanks for you quick reply and sorry for my late one. I was on vacation...
With your help I managed to compile it as f32. But it did not give us the expected performance gain.
So we're now investigating further to find out why it’s slow on our hardware. I guess it’s something with the C compiler falgs.
As soon as I will find something I’ll open a Pull Request.

Regards,
Jakob

What Rust target are you using to compile?

We re building for RUST target: arm-unknown-linux-gnueabihf
I set the environement variables CC, CFLAGS and CRATE_CC_NO_DEFAULTS=1 for the C-compiler used by CMake.
As CLFAGS we use compiler flags specific for out hardware like -mfpu=vfpv3-d16. That now did a big perforamce gain.
We're still measureing but the switch between double and float does comparingly have a small impact.

I delieve the d16 of vfpv3-d16 relates to the fact that the architecture has 16 double-precision floating point registers, so I would expect very little performance improvements from switching to single precision floats.