Make spin-waiting a little more power efficient on desktop#202
Open
cobaltgit wants to merge 7 commits into
Open
Make spin-waiting a little more power efficient on desktop#202cobaltgit wants to merge 7 commits into
cobaltgit wants to merge 7 commits into
Conversation
Un1q32
reviewed
Jun 7, 2026
| #include <intrin.h> | ||
| #define YIELD() __yield() | ||
| #elif defined(__aarch64__) || (defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) | ||
| #if defined(__GNUC__) && (__GNUC__ < 5) |
Contributor
There was a problem hiding this comment.
clang appears to have this too, clang does define __GNUC__ but it pretends to be GCC 4.2.1
Contributor
|
Intrinsics are not standard C, so you should put the whole YIELD block behind an |
Un1q32
reviewed
Jun 7, 2026
Un1q32
reviewed
Jun 8, 2026
| #include <immintrin.h> | ||
| #define YIELD() _mm_pause() | ||
| #endif | ||
| #elif defined(_M_ARM64) || defined(_M_ARM) |
Contributor
There was a problem hiding this comment.
Is this MSVC? If so make the #ifdef __GNUC__ into #if defined(__GNUC__) and add an #elif defined(_MSC_VER) that this can go into.
Contributor
There was a problem hiding this comment.
Also move out the x86 MSVC path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supports x86, ARMv7+, RISC-V GCC/Clang/MSVC, otherwise falls back to a no-op.
Uses the pause/yield instruction to stop busy-looping from using CPU while waiting for the next frame to begin