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

Faster integers? #164

Open
welshcoder opened this issue Dec 30, 2021 · 0 comments
Open

Faster integers? #164

welshcoder opened this issue Dec 30, 2021 · 0 comments

Comments

@welshcoder
Copy link
Contributor

Hi,

I thought I'd bring to your attention a potential speed-up of the library that you might be interested in. The branch with the changes I've been testing is available here: https://github.com/welshcoder/SmartMatrix/tree/speed_improvement_check.

The nature of the change is to change certain variables from uintX_t to uint_fastX_t and intX_t to int_fastX_t. I've also changed some ints to be int_fastX_t too. The fast variants ensure that the integers are at least the given size, but the compiler will use the native integer size for the CPU, giving a potential for faster computation. For the Teensy 4, I believe this to be 32-bit integer, so all the fast variants of integers will be 32-bit. I've not done a wholesale change since it is evident that some variables need to be of a fixed size.

I've not done a PR for this because I don't consider it complete (I've only updated the Teensy 4 Hub75 related files, as that coincides with the hardware I have). According to my benchmarks, the speed increase is about 10%, and most of that comes from changing the Layer* classes. If others find that to be the case, then the modification might be more straightforward for a PR as the hardware dependant classes can be left untouched.

I would be interested to know if others get a similar speed increase using the branch cited above and whether it's worth updating the library to include the fast variants of integers. If there's a positive response to this, I'll arrange a PR with the required changes.

Cheers,
welshcoder

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