From 3bb92964fee090e7ffeb033e4cefdaf92dc32294 Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Thu, 20 Jun 2024 13:49:41 -0400 Subject: [PATCH] Add flags to support OpenBSD This commit includes OpenBSD in the platform checks used to check for size_t, uint64_t, unsigned long and unsigned long long all being 64 bits in length. Addtionally, the checks for some `avx513*` flags are removed, as `avx512fp16` yield an error: "invalid cpu feature string for builtin" when compiling with clang. This commit aims to address #156 --- lib/x86simdsort.cpp | 3 ++- src/avx2-64bit-qsort.hpp | 6 +++--- src/avx512-64bit-common.h | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/x86simdsort.cpp b/lib/x86simdsort.cpp index a5bbc578..ecc80bf0 100644 --- a/lib/x86simdsort.cpp +++ b/lib/x86simdsort.cpp @@ -10,7 +10,8 @@ static int check_cpu_feature_support(std::string_view cpufeature) const char *disable_avx512 = std::getenv("XSS_DISABLE_AVX512"); if ((cpufeature == "avx512_spr") && (!disable_avx512)) -#if defined(__FLT16_MAX__) && !defined(__INTEL_LLVM_COMPILER) +#if defined(__FLT16_MAX__) && !defined(__INTEL_LLVM_COMPILER) \ + && __clang_major__ >= 18 return __builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512fp16") && __builtin_cpu_supports("avx512vbmi2"); diff --git a/src/avx2-64bit-qsort.hpp b/src/avx2-64bit-qsort.hpp index 32e5e385..d8b094df 100644 --- a/src/avx2-64bit-qsort.hpp +++ b/src/avx2-64bit-qsort.hpp @@ -406,10 +406,10 @@ struct avx2_vector { }; /* - * workaround on 64-bit macOS which defines size_t as unsigned long and defines - * uint64_t as unsigned long long, both of which are 8 bytes + * workaround on 64-bit macOS and OpenBSD which both define size_t as unsigned + * long and define uint64_t as unsigned long long, both of which are 8 bytes */ -#if defined(__APPLE__) && defined(__x86_64__) +#if (defined(__APPLE__) || defined(__OpenBSD__)) && defined(__x86_64__) static_assert(sizeof(size_t) == sizeof(uint64_t), "Size of size_t and uint64_t are not the same"); template <> diff --git a/src/avx512-64bit-common.h b/src/avx512-64bit-common.h index 6e2b6eff..689c317f 100644 --- a/src/avx512-64bit-common.h +++ b/src/avx512-64bit-common.h @@ -960,10 +960,10 @@ struct zmm_vector { }; /* - * workaround on 64-bit macOS which defines size_t as unsigned long and defines - * uint64_t as unsigned long long, both of which are 8 bytes + * workaround on 64-bit macOS and OpenBSD which both define size_t as unsigned + * long and define uint64_t as unsigned long long, both of which are 8 bytes */ -#if defined(__APPLE__) && defined(__x86_64__) +#if (defined(__APPLE__) || defined(__OpenBSD__)) && defined(__x86_64__) static_assert(sizeof(size_t) == sizeof(uint64_t), "Size of size_t and uint64_t are not the same"); template <>