[libcxx-commits] [libcxx] [libc++] Vectorize mismatch (PR #73255)

Denis Yaroshevskiy via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 24 08:45:09 PST 2024


================
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SIMD_UTILS_H
+#define _LIBCPP___ALGORITHM_SIMD_UTILS_H
+
+#include <__bit/bit_cast.h>
+#include <__bit/countr.h>
+#include <__config>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_same.h>
+#include <__utility/integer_sequence.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 14 && __has_attribute(__ext_vector_type__) && __has_builtin(__builtin_reduce_and) &&            \
+    __has_builtin(__builtin_convertvector)
+#  define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
+#else
+#  define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
+#endif
+
+#if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS && !defined(__OPTIMIZE_SIZE__)
+#  define _LIBCPP_VECTORIZE_ALGORIHTMS 1
+#else
+#  define _LIBCPP_VECTORIZE_ALGORIHTMS 0
+#endif
+
+#if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if defined(__AVX512F__)
+template <class _Tp>
+inline constexpr size_t __native_vector_size = 64 / sizeof(_Tp);
----------------
DenisYaroshevskiy wrote:

oh - I mentioned that above - don't do it, 64 bytes will frequnce scale.
Also `__AVX512F__` is absolutely not enough for you.

Here is abit of an explanation, also not a full one: https://jfalcou.github.io/eve/freqscale.html

What you want is either:
* set it for 32 bytes
* read -mprefer-vector-width from user. 

https://reviews.llvm.org/D67259

I'm not 100% at the moment how to get that, but should be doable.

https://github.com/llvm/llvm-project/pull/73255


More information about the libcxx-commits mailing list