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

32bit Float Support #18

Open
hpsjakob opened this issue Mar 30, 2023 · 5 comments
Open

32bit Float Support #18

hpsjakob opened this issue Mar 30, 2023 · 5 comments

Comments

@hpsjakob
Copy link

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

@ebarnard
Copy link
Collaborator

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.

@ebarnard ebarnard changed the title 32bit Support 32bit Float Support Mar 30, 2023
@hpsjakob
Copy link
Author

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

@ebarnard
Copy link
Collaborator

What Rust target are you using to compile?

@hpsjakob
Copy link
Author

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.

@ebarnard
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants