Skip to content

Commit

Permalink
Merge pull request #136 from VectorCamp/feature/prefix-assume-aligned
Browse files Browse the repository at this point in the history
prefix assume_aligned to avoid clash with std::assume_aligned in c++20
  • Loading branch information
markos authored Nov 1, 2022
2 parents 00d1807 + e6cfd11 commit 0f967b9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/util/arch/common/simd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static really_inline m256 loadu2x128(const void *ptr) {
// aligned store
static really_inline void store256(void *ptr, m256 a) {
assert(ISALIGNED_N(ptr, alignof(m256)));
ptr = assume_aligned(ptr, 16);
ptr = vectorscan_assume_aligned(ptr, 16);
*(m256 *)ptr = a;
}

Expand Down Expand Up @@ -486,7 +486,7 @@ static really_inline m384 load384(const void *ptr) {
// aligned store
static really_inline void store384(void *ptr, m384 a) {
assert(ISALIGNED_16(ptr));
ptr = assume_aligned(ptr, 16);
ptr = vectorscan_assume_aligned(ptr, 16);
*(m384 *)ptr = a;
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/arch/x86/simd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ static really_inline m128 andnot128(m128 a, m128 b) {
// aligned load
static really_inline m128 load128(const void *ptr) {
assert(ISALIGNED_N(ptr, alignof(m128)));
ptr = assume_aligned(ptr, 16);
ptr = vectorscan_assume_aligned(ptr, 16);
return _mm_load_si128((const m128 *)ptr);
}

// aligned store
static really_inline void store128(void *ptr, m128 a) {
assert(ISALIGNED_N(ptr, alignof(m128)));
ptr = assume_aligned(ptr, 16);
ptr = vectorscan_assume_aligned(ptr, 16);
*(m128 *)ptr = a;
}

Expand Down
8 changes: 4 additions & 4 deletions src/util/simd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
// it's available. Note that we need to handle C or C++ compilation.
#ifdef __cplusplus
# ifdef HAVE_CXX_BUILTIN_ASSUME_ALIGNED
# define assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# endif
#else
# ifdef HAVE_CC_BUILTIN_ASSUME_ALIGNED
# define assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# endif
#endif

// Fallback to identity case.
#ifndef assume_aligned
#define assume_aligned(x, y) (x)
#ifndef vectorscan_assume_aligned
#define vectorscan_assume_aligned(x, y) (x)
#endif

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/util/supervector/arch/arm/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ template <>
really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
ptr = assume_aligned(ptr, SuperVector::size);
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
return {vld1q_s32((const int32_t *)ptr)};
}

Expand Down
6 changes: 3 additions & 3 deletions src/util/supervector/arch/x86/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ template <>
really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
ptr = assume_aligned(ptr, SuperVector::size);
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
return _mm_load_si128((const m128 *)ptr);
}

Expand Down Expand Up @@ -1119,7 +1119,7 @@ template <>
really_inline SuperVector<32> SuperVector<32>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
ptr = assume_aligned(ptr, SuperVector::size);
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
return {_mm256_load_si256((const m256 *)ptr)};
}

Expand Down Expand Up @@ -1769,7 +1769,7 @@ template <>
really_inline SuperVector<64> SuperVector<64>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
ptr = assume_aligned(ptr, SuperVector::size);
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
return {_mm512_load_si512((const m512 *)ptr)};
}

Expand Down
8 changes: 4 additions & 4 deletions src/util/supervector/supervector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ using Z_TYPE = u32;
// it's available. Note that we need to handle C or C++ compilation.
#ifdef __cplusplus
# ifdef HAVE_CXX_BUILTIN_ASSUME_ALIGNED
# define assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# endif
#else
# ifdef HAVE_CC_BUILTIN_ASSUME_ALIGNED
# define assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y))
# endif
#endif

// Fallback to identity case.
#ifndef assume_aligned
#define assume_aligned(x, y) (x)
#ifndef vectorscan_assume_aligned
#define vectorscan_assume_aligned(x, y) (x)
#endif

template <uint16_t SIZE>
Expand Down

0 comments on commit 0f967b9

Please sign in to comment.