From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../libs/hana/benchmark/fold_left/bloat.erb.json | 38 ++++++++++++++ .../fold_left/compile.cexpr.recursive.erb.cpp | 53 +++++++++++++++++++ .../fold_left/compile.cexpr.unrolled.erb.cpp | 43 +++++++++++++++ .../libs/hana/benchmark/fold_left/compile.erb.json | 61 ++++++++++++++++++++++ .../fold_left/compile.fusion.list.erb.cpp | 31 +++++++++++ .../fold_left/compile.fusion.vector.erb.cpp | 31 +++++++++++ .../fold_left/compile.hana.basic_tuple.erb.cpp | 26 +++++++++ .../benchmark/fold_left/compile.hana.tuple.erb.cpp | 25 +++++++++ .../benchmark/fold_left/compile.meta.list.erb.cpp | 25 +++++++++ .../benchmark/fold_left/compile.mpl.vector.erb.cpp | 24 +++++++++ .../benchmark/fold_left/compile.mpl11.list.erb.cpp | 26 +++++++++ .../libs/hana/benchmark/fold_left/execute.erb.json | 32 ++++++++++++ .../fold_left/execute.fusion.list.erb.cpp | 32 ++++++++++++ .../fold_left/execute.fusion.vector.erb.cpp | 32 ++++++++++++ .../benchmark/fold_left/execute.hana.tuple.erb.cpp | 26 +++++++++ .../benchmark/fold_left/execute.std.array.erb.cpp | 22 ++++++++ .../benchmark/fold_left/execute.std.vector.erb.cpp | 22 ++++++++ 17 files changed, 549 insertions(+) create mode 100644 src/boost/libs/hana/benchmark/fold_left/bloat.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp (limited to 'src/boost/libs/hana/benchmark/fold_left') diff --git a/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json b/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json new file mode 100644 index 000000000..b3bd9892e --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json @@ -0,0 +1,38 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Executable size for fold_left" + }, + "yAxis": { + "title": { + "text": "Executable size (kb)" + }, + "floor": 0 + }, + "tooltip": { + "valueSuffix": "kb" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= measure(:bloat, 'execute.hana.tuple.erb.cpp', exec) %> + }, { + "name": "std::vector", + "data": <%= measure(:bloat, 'execute.std.vector.erb.cpp', exec) %> + }, { + "name": "std::array", + "data": <%= measure(:bloat, 'execute.std.array.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= measure(:bloat, 'execute.fusion.vector.erb.cpp', fusion) %> + } + <% end %> + ] +} \ No newline at end of file diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp new file mode 100644 index 000000000..30beb1698 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp @@ -0,0 +1,53 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +template +struct list { }; + +template +struct basic_type { using type = T; }; + +template +constexpr basic_type type{}; + + +template +constexpr auto head(list) +{ return type; } + +template +constexpr auto tail(list) +{ return list{}; } + +template +constexpr auto foldl(F f, State s, list xs) +{ return foldl(f, f(s, head(xs)), tail(xs)); } + +template +constexpr auto foldl(F, State s, list<>) +{ return s; } + +////////////////////////////////////////////////////////////////////////////// + + +struct f { + template + struct result { }; + + template + constexpr auto operator()(X, Y) const + { return result{}; } +}; + +template struct x { }; +struct state { }; + +int main() { + constexpr auto xs = list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> + >{}; + + constexpr auto result = foldl(f{}, state{}, xs); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp new file mode 100644 index 000000000..80fb46f05 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct list { }; + +template +struct basic_type { using type = T; }; + +template +constexpr basic_type type{}; + + +template +constexpr auto foldl(F f, State s, list xs) +{ return boost::hana::detail::variadic::foldl(f, s, type...); } + +////////////////////////////////////////////////////////////////////////////// + +struct f { + template + struct result { }; + + template + constexpr auto operator()(X, Y) const + { return result{}; } +}; + +template struct x { }; +struct state { }; + +int main() { + constexpr auto xs = list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> + >{}; + + constexpr auto result = foldl(f{}, state{}, xs); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.erb.json b/src/boost/libs/hana/benchmark/fold_left/compile.erb.json new file mode 100644 index 000000000..7240907a9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.erb.json @@ -0,0 +1,61 @@ +<% + hana = (0...50).step(5).to_a + (50..400).step(25).to_a + fusion = (0..50).step(5) + mpl = hana + mpl11 = (0...50).step(5).to_a + (50..500).step(25).to_a + meta = (0...50).step(5).to_a + (50..200).step(25).to_a + cexpr = (0...50).step(5).to_a + (50..200).step(25).to_a +%> + + +{ + "title": { + "text": "Compile-time behavior of fold_left" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_compilation('compile.hana.tuple.erb.cpp', hana) %> + }, { + "name": "hana::basic_tuple", + "data": <%= time_compilation('compile.hana.basic_tuple.erb.cpp', hana) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_compilation('compile.fusion.vector.erb.cpp', fusion) %> + },{ + "name": "fusion::list", + "data": <%= time_compilation('compile.fusion.list.erb.cpp', fusion) %> + }, { + "name": "mpl::vector", + "data": <%= time_compilation('compile.mpl.vector.erb.cpp', mpl) %> + } + <% end %> + + <% if cmake_bool("@MPL11_FOUND@") %> + , { + "name": "mpl11::list", + "data": <%= time_compilation('compile.mpl11.list.erb.cpp', mpl11) %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "meta::list", + "data": <%= time_compilation('compile.meta.list.erb.cpp', meta) %> + } + <% end %> + + <% if false %> + , { + "name": "cexpr::list (recursive)", + "data": <%= time_compilation('compile.cexpr.recursive.erb.cpp', cexpr) %> + }, { + "name": "cexpr::list (unrolled)", + "data": <%= time_compilation('compile.cexpr.unrolled.erb.cpp', cexpr) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp new file mode 100644 index 000000000..144744a23 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + auto xs = fusion::make_list( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::fold(xs, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp new file mode 100644 index 000000000..3a319b351 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + auto xs = fusion::make_vector( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::fold(xs, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp new file mode 100644 index 000000000..c076f3fc9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + constexpr auto tuple = hana::make_basic_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + constexpr auto result = hana::fold_left(tuple, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp new file mode 100644 index 000000000..a245e30c9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + constexpr auto result = boost::hana::fold_left(tuple, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp new file mode 100644 index 000000000..cd2ec0f8a --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + template + struct apply; +}; + +template struct x; + +struct state; + +using list = meta::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = meta::fold; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp new file mode 100644 index 000000000..4d5b5b4b6 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp @@ -0,0 +1,24 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +template +struct f { using type = X; }; + +struct state { }; + +template +struct t { }; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| "t<#{n}>" }) %>; + +using result = boost::mpl::fold>::type; + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp new file mode 100644 index 000000000..cf383ef00 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + using type = f; + template + struct apply { struct type; }; +}; + +template struct x { struct type; }; + +struct state { struct type; }; + +using list = boost::mpl11::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = boost::mpl11::foldl::type; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.erb.json b/src/boost/libs/hana/benchmark/fold_left/execute.erb.json new file mode 100644 index 000000000..2f7d94559 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.erb.json @@ -0,0 +1,32 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Runtime behavior of fold_left" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_execution('execute.hana.tuple.erb.cpp', exec) %> + }, { + "name": "std::vector", + "data": <%= time_execution('execute.std.vector.erb.cpp', exec) %> + }, { + "name": "std::array", + "data": <%= time_execution('execute.std.array.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_execution('execute.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_execution('execute.fusion.list.erb.cpp', fusion) %> + } + <% end %> + ] +} \ No newline at end of file diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp new file mode 100644 index 000000000..b71938980 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_list( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += fusion::fold(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp new file mode 100644 index 000000000..c733a3be0 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_vector( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += fusion::fold(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp new file mode 100644 index 000000000..622d74f88 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include "measure.hpp" +#include + + +int main () { + boost::hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = boost::hana::make_tuple( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += boost::hana::fold_left(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp new file mode 100644 index 000000000..3961151b6 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp @@ -0,0 +1,22 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::array> values = {{ + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }}; + + result += std::accumulate(values.begin(), values.end(), 0); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp new file mode 100644 index 000000000..703b6fbcc --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp @@ -0,0 +1,22 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::vector values = { + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }; + + result += std::accumulate(values.begin(), values.end(), 0); + } + }); +} -- cgit v1.2.3