12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- From 6667b0cd38025d0a0457537e9badcbc6be6e2049 Mon Sep 17 00:00:00 2001
- From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
- Date: Wed, 22 Jun 2022 08:49:22 +0000
- Subject: [PATCH] add workaround for riscv64
- Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
- ---
- hwy/aligned_allocator.cc | 7 +++++++
- hwy/base.h | 4 ++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
- diff --git a/hwy/aligned_allocator.cc b/hwy/aligned_allocator.cc
- index bec7c3b..677fcf1 100644
- --- a/hwy/aligned_allocator.cc
- +++ b/hwy/aligned_allocator.cc
- @@ -27,7 +27,14 @@
- namespace hwy {
- namespace {
-
- +#if HWY_ARCH_RVV && defined(__riscv_vector)
- +// Not actually an upper bound on the size, but this value prevents crossing a
- +// 4K boundary (relevant on Andes).
- +constexpr size_t kAlignment = HWY_MAX(HWY_ALIGNMENT, 4096);
- +#else
- constexpr size_t kAlignment = HWY_MAX(HWY_ALIGNMENT, kMaxVectorSize);
- +#endif
- +
- // On x86, aliasing can only occur at multiples of 2K, but that's too wasteful
- // if this is used for single-vector allocations. 256 is more reasonable.
- constexpr size_t kAlias = kAlignment * 4;
- diff --git a/hwy/base.h b/hwy/base.h
- index d87eb34..db5df58 100644
- --- a/hwy/base.h
- +++ b/hwy/base.h
- @@ -319,7 +319,7 @@ static constexpr HWY_MAYBE_UNUSED size_t kMaxVectorSize = 64; // AVX-512
- #elif HWY_ARCH_RVV
- // Not actually an upper bound on the size, but this value prevents crossing a
- // 4K boundary (relevant on Andes).
- -static constexpr HWY_MAYBE_UNUSED size_t kMaxVectorSize = 4096;
- +static constexpr HWY_MAYBE_UNUSED size_t kMaxVectorSize = 64;
- #define HWY_ALIGN_MAX alignas(8) // only elements need be aligned
- #else
- static constexpr HWY_MAYBE_UNUSED size_t kMaxVectorSize = 16;
- @@ -333,7 +333,7 @@ static constexpr HWY_MAYBE_UNUSED size_t kMaxVectorSize = 16;
- // by concatenating base type and bits.
-
- // RVV already has a builtin type and the GCC intrinsics require it.
- -#if HWY_ARCH_RVV && HWY_COMPILER_GCC
- +#if HWY_ARCH_RVV && HWY_COMPILER_GCC && 0
- #define HWY_NATIVE_FLOAT16 1
- #else
- #define HWY_NATIVE_FLOAT16 0
- --
- 2.30.2
|