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

Switch to a better memmove #2984

Merged
merged 8 commits into from
Jan 16, 2025
Merged

Switch to a better memmove #2984

merged 8 commits into from
Jan 16, 2025

Conversation

stellar-aria
Copy link
Collaborator

@stellar-aria stellar-aria commented Nov 27, 2024

This changes the (extremely naive) memmove implementation out for one that progressively copies in larger blocks until it reaches 8 quadwords.

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Test Results

106 tests  ±0   106 ✅ ±0   0s ⏱️ -1s
 16 suites ±0     0 💤 ±0 
 16 files   ±0     0 ❌ ±0 

Results for commit c6c5d13. ± Comparison against base commit e806053.

♻️ This comment has been updated with latest results.

@stellar-aria stellar-aria marked this pull request as draft November 27, 2024 20:06
@stellar-aria
Copy link
Collaborator Author

stellar-aria commented Nov 27, 2024

Had to check for correctness after realizing that building for Release disabled my test assertions in the benchmark/test. New implementation passed.

@stellar-aria stellar-aria marked this pull request as ready for review November 27, 2024 20:09
src/deluge/dsp/memmove.c Outdated Show resolved Hide resolved
src/deluge/dsp/memmove.c Outdated Show resolved Hide resolved
src/deluge/dsp/memmove.c Outdated Show resolved Hide resolved
src/mem_functions.h Outdated Show resolved Hide resolved
@stellar-aria
Copy link
Collaborator Author

Apparently the multi-load/multi-store intrinsics are new to GCC 14.2 :(

@nikodemus
Copy link
Collaborator

Idle thought: there's not a ton of memmove use-sites, I wonder if we could guarantee a healthy (like quadword) alignment for most?

@stellar-aria
Copy link
Collaborator Author

Idle thought: there's not a ton of memmove use-sites, I wonder if we could guarantee a healthy (like quadword) alignment for most?

We probably could, but better to just have an agnostic algorithm that's really fast anyways like this one and not accidentally get caught up when something in std:: uses it.

src/memmove.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@m-m-adams m-m-adams left a comment

Choose a reason for hiding this comment

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

lgtm but also we should remember to update these when gcc is updated, this generates worse assembly than the vld1q_u8_x4 intrinsic

@stellar-aria
Copy link
Collaborator Author

lgtm but also we should remember to update these when gcc is updated, this generates worse assembly than the vld1q_u8_x4 intrinsic

Considering we'll likely get 14.2 this week, I'll probably just rip 'em out before the merge even happens. They'll collide and error otherwise

@stellar-aria stellar-aria marked this pull request as draft December 16, 2024 23:20
@stellar-aria
Copy link
Collaborator Author

Currently blocked by xpack-dev-tools/arm-none-eabi-gcc-xpack#38

@stellar-aria stellar-aria marked this pull request as ready for review January 8, 2025 04:19
@m-m-adams
Copy link
Collaborator

This seems to be broken, I'm getting a lot of signs of memory corruption when I test it

@stellar-aria
Copy link
Collaborator Author

I'll retest it on some other platforms then, last I checked there wasn't any problems. It might be alignment stuff, which I thought about disabling the progressively larger copy sizes unless we hit half-word/word/doubleword/quadword alignment on both input and output

@stellar-aria stellar-aria added this pull request to the merge queue Jan 16, 2025
Merged via the queue into community with commit d6818f9 Jan 16, 2025
6 checks passed
@stellar-aria stellar-aria deleted the better-memmove branch January 16, 2025 03:35
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

Successfully merging this pull request may close these issues.

3 participants