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

spin_delay.hpp: fix for Darwin PPC #3129

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions include/seqan3/utility/parallel/detail/spin_delay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

#include <thread>

#include <seqan3/core/platform.hpp>

//!\cond
#ifndef SEQAN3_HAS_MM_PAUSE
# if defined(__SSE2__) && __has_include(<xmmintrin.h>)
# include <xmmintrin.h> // _mm_pause()
# define SEQAN3_HAS_MM_PAUSE 1
# else
# define SEQAN3_HAS_MM_PAUSE 0
# endif // defined(__SSE2__) && __has_include(<xmmintrin.h>)
#endif // SEQAN3_HAS_MM_PAUSE
//!\endcond

#include <seqan3/core/platform.hpp>

namespace seqan3::detail
{
/*!\brief A delay for threads waiting for a shared resource.
Expand Down Expand Up @@ -80,16 +82,19 @@ class spin_delay
{
#if SEQAN3_HAS_MM_PAUSE // AMD and Intel
_mm_pause();
#elif defined(__armel__) \
|| defined(__ARMEL__) // arm, but broken? ; repeat of default case as armel also defines __arm__
#elif defined(__armel__) || defined(__ARMEL__) // ARM, but broken? repeat of default case as ARMEL also defines __arm__
asm volatile("nop" ::: "memory"); // default operation - does nothing => Might lead to passive spinning.
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
#elif defined(__arm__) || defined(__aarch64__) // ARM big endian / ARM64
__asm__ __volatile__("yield" ::: "memory");
#elif defined(__ia64__) // IA64
#elif defined(__ia64__) // IA64
__asm__ __volatile__("hint @pause");
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) // PowerPC
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__ppc64__) // PowerPC
# if defined(__APPLE__)
__asm__ volatile("or r27,r27,r27" ::: "memory");
# else
__asm__ __volatile__("or 27,27,27" ::: "memory");
#else // everything else.
# endif
#else // everything else
asm volatile("nop" ::: "memory"); // default operation - does nothing => Might lead to passive spinning.
#endif
}
Expand Down