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

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


================
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+#include <benchmark/benchmark.h>
+#include <random>
+
+template <class T>
+static void bm_mismatch(benchmark::State& state) {
----------------
DenisYaroshevskiy wrote:

I don't know how much you care for it but you can try to mess with data alignment.

ve1.data() and vec2.data() will be aligned to 16 bytes. Which can lead to loads being aligned.

the difference can be quite huge.

There are some things you can do about that, I don't know if they are worth it for 2 range algorithms.

At the very least maybe aligned your .data() pointers to 64 bytes:

* allocate both vectors with +64 bytes.
* align the pointers forward - get a span.

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


More information about the libcxx-commits mailing list