Skip to content

Commit

Permalink
Applying cmake-format and clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: Vedant <[email protected]>
  • Loading branch information
vrnimje committed Apr 19, 2024
1 parent 8997e2f commit 2e70beb
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,58 @@ int hpx_main(hpx::program_options::variables_map& vm)
// pull values from cmd
std::size_t repeat = vm["test_count"].as<std::size_t>();
std::size_t size = vm["vector_size"].as<std::size_t>();

hpx::util::perftests_init(vm);

// int

hpx::util::perftests_report("hpx::small_vector", "<int, 1>", repeat, [&] {
fill<hpx::detail::small_vector<int, 1>>(size);
});

hpx::util::perftests_report("hpx::small_vector", "<int, 2>", repeat, [&] {
fill<hpx::detail::small_vector<int, 2>>(size);
});

hpx::util::perftests_report("hpx::small_vector", "<int, 4>", repeat, [&] {
fill<hpx::detail::small_vector<int, 4>>(size);
});

hpx::util::perftests_report("hpx::small_vector", "<int, 8>", repeat, [&] {
fill<hpx::detail::small_vector<int, 8>>(size);
});
hpx::util::perftests_report("hpx::small_vector", "<int, 1>", repeat,
[&] { fill<hpx::detail::small_vector<int, 1>>(size); });

hpx::util::perftests_report("hpx::small_vector", "<int, 16>", repeat, [&] {
fill<hpx::detail::small_vector<int, 16>>(size);
});
hpx::util::perftests_report("hpx::small_vector", "<int, 2>", repeat,
[&] { fill<hpx::detail::small_vector<int, 2>>(size); });

// hpx::move_only_function<void()>

hpx::util::perftests_report("hpx::small_vector", "<fxn<void()>, 1>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 1>>(size);
});
hpx::util::perftests_report("hpx::small_vector", "<int, 4>", repeat,
[&] { fill<hpx::detail::small_vector<int, 4>>(size); });

hpx::util::perftests_report("hpx::small_vector", "<fxn<void()>, 2>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 2>>(size);
});
hpx::util::perftests_report("hpx::small_vector", "<int, 8>", repeat,
[&] { fill<hpx::detail::small_vector<int, 8>>(size); });

hpx::util::perftests_report("hpx::small_vector", "<fxn<void()>, 4>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 4>>(size);
});
hpx::util::perftests_report("hpx::small_vector", "<int, 16>", repeat,
[&] { fill<hpx::detail::small_vector<int, 16>>(size); });

hpx::util::perftests_report("hpx::small_vector", "<fxn<void()>, 8>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 8>>(size);
});
// hpx::move_only_function<void()>

hpx::util::perftests_report("hpx::small_vector", "<fxn<void()>, 16>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 16>>(size);
});
hpx::util::perftests_report(
"hpx::small_vector", "<fxn<void()>, 1>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 1>>(
size);
});

hpx::util::perftests_report(
"hpx::small_vector", "<fxn<void()>, 2>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 2>>(
size);
});

hpx::util::perftests_report(
"hpx::small_vector", "<fxn<void()>, 4>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 4>>(
size);
});

hpx::util::perftests_report(
"hpx::small_vector", "<fxn<void()>, 8>", repeat, [&] {
fill<hpx::detail::small_vector<hpx::move_only_function<void()>, 8>>(
size);
});

hpx::util::perftests_report(
"hpx::small_vector", "<fxn<void()>, 16>", repeat, [&] {
fill<
hpx::detail::small_vector<hpx::move_only_function<void()>, 16>>(
size);
});

hpx::util::perftests_print_times();

Expand Down
16 changes: 8 additions & 8 deletions libs/core/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ set(testing_compat_headers
# Default location is $HPX_ROOT/libs/testing/src
set(testing_sources testing.cpp performance.cpp)

set(module_deps
hpx_assertion
hpx_config
hpx_format
hpx_functional
hpx_preprocessor
hpx_util
hpx_command_line_handling_local
set(module_deps
hpx_assertion
hpx_config
hpx_format
hpx_functional
hpx_preprocessor
hpx_util
hpx_command_line_handling_local
)

if(HPX_WITH_NANOBENCH)
Expand Down
9 changes: 6 additions & 3 deletions libs/core/testing/include/hpx/testing/performance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

namespace hpx::util {
HPX_CORE_EXPORT inline bool detailed_;
HPX_CORE_EXPORT void perftests_cfg(hpx::program_options::options_description& cmdline);
HPX_CORE_EXPORT void perftests_init(const hpx::program_options::variables_map& vm);
HPX_CORE_EXPORT void perftests_cfg(
hpx::program_options::options_description& cmdline);
HPX_CORE_EXPORT void perftests_init(
const hpx::program_options::variables_map& vm);
#if defined(HPX_HAVE_NANOBENCH)
HPX_CORE_EXPORT void perftests_report(std::string const& name,
std::string const& exec, std::size_t const steps,
hpx::function<void()>&& test);
HPX_CORE_EXPORT void perftests_print_times(std::ostream& strm, char const* templ);
HPX_CORE_EXPORT void perftests_print_times(
std::ostream& strm, char const* templ);
HPX_CORE_EXPORT void perftests_print_times(std::ostream& strm);
HPX_CORE_EXPORT void perftests_print_times();
#else
Expand Down
51 changes: 29 additions & 22 deletions libs/core/testing/src/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@

namespace hpx::util {

void perftests_cfg(hpx::program_options::options_description& cmdline) {
cmdline.add_options()
("detailed_bench",
"Use if detailed benchmarks are required, showing the execution time taken for each epoch")
;
void perftests_cfg(hpx::program_options::options_description& cmdline)
{
cmdline.add_options()("detailed_bench",
"Use if detailed benchmarks are required, showing the execution "
"time taken for each epoch");
}

void perftests_init(const hpx::program_options::variables_map& vm) {
if (vm.count("detailed_bench")) {
void perftests_init(const hpx::program_options::variables_map& vm)
{
if (vm.count("detailed_bench"))
{
detailed_ = true;
}
}
Expand Down Expand Up @@ -111,8 +113,7 @@ average: {{average(elapsed)}}{{^-last}}

std::ostream& operator<<(std::ostream& strm, json_perf_times const& obj)
{

if (detailed_)
if (detailed_)
{
strm << "{\n";
strm << " \"outputs\" : [";
Expand All @@ -123,12 +124,14 @@ average: {{average(elapsed)}}{{^-last}}
strm << ",";
strm << "\n {\n";
strm << R"( "name" : ")" << std::get<0>(item.first)
<< "\",\n";
<< "\",\n";
strm << R"( "executor" : ")" << std::get<1>(item.first)
<< "\",\n";
strm << R"( "series" : [)" << "\n";
<< "\",\n";
strm << R"( "series" : [)"
<< "\n";
int series = 0;
strm.precision(std::numeric_limits<long double>::max_digits10 - 1);
strm.precision(
std::numeric_limits<long double>::max_digits10 - 1);
for (long double const val : item.second)
{
if (series)
Expand All @@ -138,9 +141,9 @@ average: {{average(elapsed)}}{{^-last}}
strm << R"( )" << std::scientific << val;
++series;
}

strm << "\n ]\n";

strm << " }";
++outputs;
}
Expand All @@ -149,10 +152,10 @@ average: {{average(elapsed)}}{{^-last}}
strm << "]\n";
strm << "}\n";
}
else
else
{
strm << "Results:\n\n";
for (auto&& item: obj.m_map)
for (auto&& item : obj.m_map)
{
long double average = 0.0;
int series = 0;
Expand All @@ -163,8 +166,10 @@ average: {{average(elapsed)}}{{^-last}}
++series;
average += val;
}
strm.precision(std::numeric_limits<long double>::max_digits10 - 1);
strm << std::scientific << "average: " << average / series << "\n\n";
strm.precision(
std::numeric_limits<long double>::max_digits10 - 1);
strm << std::scientific << "average: " << average / series
<< "\n\n";
}
}
return strm;
Expand All @@ -186,7 +191,8 @@ average: {{average(elapsed)}}{{^-last}}
if (steps == 0)
return;

std::size_t const steps_per_epoch = steps / detail::nanobench_epochs + 1;
std::size_t const steps_per_epoch =
steps / detail::nanobench_epochs + 1;

detail::bench()
.name(name)
Expand Down Expand Up @@ -214,8 +220,9 @@ average: {{average(elapsed)}}{{^-last}}
{
if (detailed_)
perftests_print_times(detail::nanobench_hpx_template(), std::cout);
else
perftests_print_times(detail::nanobench_hpx_simple_template(), std::cout);
else
perftests_print_times(
detail::nanobench_hpx_simple_template(), std::cout);
}
#else
void perftests_report(std::string const& name, std::string const& exec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

set(benchmarks minmax_element_performance)

# if (HPX_WITH_NANOBENCH_BENCHMARKS)
# set(benchmarks ${benchmarks} minmax_nanobench)
# endif()

foreach(benchmark ${benchmarks})
set(sources ${benchmark}.cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <hpx/include/parallel_minmax.hpp>
#include <hpx/include/partitioned_vector.hpp>
#include <hpx/iostream.hpp>
#include <hpx/modules/timing.hpp>
#include <hpx/modules/program_options.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/modules/timing.hpp>

#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -72,15 +72,16 @@ int hpx_main(hpx::program_options::variables_map& vm)
hpx::util::perftests_init(vm);

// run benchmark
hpx::util::perftests_report("hpx::minmax", "par", test_count, [&]{
hpx::minmax_element(hpx::execution::par, v.begin(), v.end());});
hpx::util::perftests_report("hpx::minmax", "par", test_count, [&] {
hpx::minmax_element(hpx::execution::par, v.begin(), v.end());
});

hpx::util::perftests_report("hpx::min", "par", test_count,
[&] { hpx::min_element(hpx::execution::par, v.begin(), v.end()); });

hpx::util::perftests_report("hpx::min", "par", test_count, [&]{hpx::min_element(
hpx::execution::par, v.begin(), v.end());});
hpx::util::perftests_report("hpx::max", "par", test_count,
[&] { hpx::max_element(hpx::execution::par, v.begin(), v.end()); });

hpx::util::perftests_report("hpx::max", "par", test_count, [&]{hpx::max_element(
hpx::execution::par, v.begin(), v.end());});

hpx::util::perftests_print_times();

return hpx::finalize();
Expand Down

0 comments on commit 2e70beb

Please sign in to comment.