0007-highway.patch 2.0 KB

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