Skip to content

Commit

Permalink
Add flags to support OpenBSD
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ron-at-swgy committed Jun 21, 2024
1 parent 33a4a1d commit 3bb9296
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/x86simdsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions src/avx2-64bit-qsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ struct avx2_vector<uint64_t> {
};

/*
* 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 <>
Expand Down
6 changes: 3 additions & 3 deletions src/avx512-64bit-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,10 +960,10 @@ struct zmm_vector<uint64_t> {
};

/*
* 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 <>
Expand Down

0 comments on commit 3bb9296

Please sign in to comment.