summaryrefslogtreecommitdiff
path: root/libcxx/benchmarks
diff options
context:
space:
mode:
authorMarco Gelmi <marcogelmi@google.com>2022-04-08 08:58:48 +0200
committerNikolas Klauser <nikolasklauser@berlin.de>2022-04-08 09:00:30 +0200
commit194d1965d2c841fa81e107d19e27fae1467e7f11 (patch)
tree84b52b40641c470c12fe9084eaccc180ca180489 /libcxx/benchmarks
parentbf2dc4b37623e1b4f7d39570e1b5a6f3ef5db107 (diff)
downloadllvm-194d1965d2c841fa81e107d19e27fae1467e7f11.tar.gz
Introduce branchless sorting functions for sort3, sort4 and sort5.
We are introducing branchless variants for sort3, sort4 and sort5. These sorting functions have been generated using Reinforcement Learning and aim to replace __sort3, __sort4 and __sort5 variants for integral types. The libc++ benchmarks were run on isolated machines for Skylake, ARM and AMD architectures and achieve statistically significant improvement in sorting random integers on test cases from sort1 to sort262144 for uint32 and uint64. A full performance overview for Intel Skylake, AMD and Arm can be found here: https://bit.ly/3AtesYf Reviewed By: ldionne, #libc, philnik Spies: daniel.mankowitz, mgrang, Quuxplusone, andreamichi, philnik, libcxx-commits, nilayvaish, kristof.beyls Differential Revision: https://reviews.llvm.org/D118029
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r--libcxx/benchmarks/algorithms.bench.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/libcxx/benchmarks/algorithms.bench.cpp b/libcxx/benchmarks/algorithms.bench.cpp
index b3724ecf23ad..5a97df1acc60 100644
--- a/libcxx/benchmarks/algorithms.bench.cpp
+++ b/libcxx/benchmarks/algorithms.bench.cpp
@@ -14,23 +14,17 @@
namespace {
-enum class ValueType { Uint32, Uint64, Pair, Tuple, String };
-struct AllValueTypes : EnumValuesAsTuple<AllValueTypes, ValueType, 5> {
- static constexpr const char* Names[] = {
- "uint32", "uint64", "pair<uint32, uint32>",
- "tuple<uint32, uint64, uint32>", "string"};
+enum class ValueType { Uint32, Uint64, Pair, Tuple, String, Float };
+struct AllValueTypes : EnumValuesAsTuple<AllValueTypes, ValueType, 6> {
+ static constexpr const char* Names[] = {"uint32", "uint64", "pair<uint32, uint32>", "tuple<uint32, uint64, uint32>",
+ "string", "float"};
};
+using Types = std::tuple< uint32_t, uint64_t, std::pair<uint32_t, uint32_t>, std::tuple<uint32_t, uint64_t, uint32_t>,
+ std::string, float >;
+
template <class V>
-using Value = std::conditional_t<
- V() == ValueType::Uint32, uint32_t,
- std::conditional_t<
- V() == ValueType::Uint64, uint64_t,
- std::conditional_t<
- V() == ValueType::Pair, std::pair<uint32_t, uint32_t>,
- std::conditional_t<V() == ValueType::Tuple,
- std::tuple<uint32_t, uint64_t, uint32_t>,
- std::string> > > >;
+using Value = std::tuple_element_t<(int)V::value, Types>;
enum class Order {
Random,