From 0b839b9d7e3a2e3d8ac23c0ac5679edf89d670d2 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sat, 29 Jun 2024 22:20:50 -0700 Subject: [PATCH] Fixes for symbol multi-versioning with avx512f --- ConflictSet.cpp | 30 +++++++++++++++++++++++------- symbol-imports.txt | 2 ++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 5e9625f..d2bdd1f 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -38,6 +38,12 @@ limitations under the License. #include #endif +#if defined(__has_feature) +# if __has_feature(thread_sanitizer) +#define __SANITIZE_THREAD__ +# endif +#endif + #include using namespace weaselab; @@ -1767,11 +1773,17 @@ downLeftSpine: } #ifdef HAS_AVX -__attribute__((target("default"))) uint32_t compare16_32bit(const uint32_t *vs, - uint32_t rv) { +#ifndef __SANITIZE_THREAD__ +__attribute__((target("default"))) +#endif +uint32_t compare16_32bit(const InternalVersionT *vs, + InternalVersionT rv) { + uint32_t compared = 0; __m128i w[4]; memcpy(w, vs, sizeof(w)); - const auto rvVec = _mm_set1_epi32(rv); + uint32_t r; + memcpy(&r, &rv, sizeof(r)); + const auto rvVec = _mm_set1_epi32(r); const auto zero = _mm_setzero_si128(); for (int i = 0; i < 4; ++i) { compared |= @@ -1781,14 +1793,18 @@ __attribute__((target("default"))) uint32_t compare16_32bit(const uint32_t *vs, return compared; } -__attribute__((target("avx512f"))) uint32_t compare16_32bit(const uint32_t *vs, - uint32_t rv) { - __mm512i w; +#ifndef __SANITIZE_THREAD__ +__attribute__((target("avx512f"))) uint32_t compare16_32bit(const InternalVersionT *vs, + InternalVersionT rv) { + __m512i w; memcpy(&w, vs, sizeof(w)); - return _mm512_cmpgt_epi32_mask(_mm512_sub_epi32(w, _mm512_set1_epi32(rv)), + uint32_t r; + memcpy(&r, &rv, sizeof(r)); + return _mm512_cmpgt_epi32_mask(_mm512_sub_epi32(w, _mm512_set1_epi32(r)), _mm512_setzero()); } #endif +#endif // Returns true if v[i] <= readVersion for all i such that begin <= is[i] < end // Preconditions: begin <= end, end - begin < 256 diff --git a/symbol-imports.txt b/symbol-imports.txt index bbed523..0a97ef0 100644 --- a/symbol-imports.txt +++ b/symbol-imports.txt @@ -1,4 +1,6 @@ _GLOBAL_OFFSET_TABLE_ +__cpu_indicator_init +__cpu_model __stack_chk_fail@GLIBC_2.4 __tls_get_addr@GLIBC_2.3 abort@GLIBC_2.2.5