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

[Core] RP2040: use built-in integer hardware divider and optimized i64 multiplication #18464

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented Sep 23, 2022

Description

The rp2040 cortex m0+ cores do not implement an integer divider itself, but instead the rp2040 provides two on-chip hardware dividers as an extra peripheral. To use those the GCC arm-v6 eabi integer division and modulo built-ins have to be replaced with implementations that utilize them. An optimized i64 multiplication implementation is provided as well.

these functions are implemented directly and do not need the pico vtable mechanism as the float/double functions

Benchmark

Reference metric is completed QMK keyboard tasks per second:

board baseline with hardware divider improvement
Onekey 20000 23000 15%
1up/pi40 5100 6000 17%

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

  • More processing power is always nice

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added the core label Sep 23, 2022
@KarlK90 KarlK90 requested a review from a team September 23, 2022 23:52
Copy link
Member

@daskygit daskygit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__attribute__((weak))

Doesn't appear to break anything in my 2 splits, offered quite the performance improvement while testing the new pimoroni trackball driver.

@KarlK90
Copy link
Member Author

KarlK90 commented Oct 4, 2022

Nice! I've been using this for several days now without any hick-ups or crashes therefore this should be save to merge?!

…plication

The rp2040 cortex m0+ cores do not implement an integer divider itself, but
instead the rp2040 provides two on-chip hardware dividers as an extra
peripheral. To use those the GCC arm-v6 eabi integer division and modulo
built-ins have to be replaced with implementations that utilize them. An
optimized i64 multiplication implementation is provided as well.
@KarlK90 KarlK90 force-pushed the feature/rp2040-use-hardware-divider branch from 0eec951 to d9dc3ee Compare October 4, 2022 21:39
@KarlK90 KarlK90 merged commit 7e844a4 into qmk:develop Oct 4, 2022
@KarlK90 KarlK90 deleted the feature/rp2040-use-hardware-divider branch October 4, 2022 21:43
ramonimbao pushed a commit to ramonimbao/qmk_firmware that referenced this pull request Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants