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

Backend: use fixed-point numerics instead of float32 for weights #363

Open
sstangl opened this issue May 27, 2024 · 0 comments
Open

Backend: use fixed-point numerics instead of float32 for weights #363

sstangl opened this issue May 27, 2024 · 0 comments

Comments

@sstangl
Copy link
Contributor

sstangl commented May 27, 2024

The backend currently represents weights using float32 values. Floating-point arithmetic and comparisons are significantly slower than integer operations and require the use of special floating-point registers.

OpenPowerlifting got a nice speed bump by using a fixed-point representation: a weight like 123.45 is stored as an i32 in the format 12345. Go appears to have an arbitrary-precision fixed-decimal representation through the decimal package, but a representation that hardcodes one decimal point (for i16) or two decimal points (for i32) is likely to be simpler and more performant.

sstangl added a commit to sstangl/openweightlifting that referenced this issue May 27, 2024
This patch ports the OpenPowerlifting weight representation to Go.

The new WeightKg type represents numbers like `123.45` by storing them
in a fixed-point integer representation, like `12345`. The advantage of
this representation is that integer comparisons and arithmetic are
significantly faster than the corresponding floating-point operations,
because integers do not require loads into XMM registers.
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

1 participant