Skip to content

Commit

Permalink
Remove duplicated helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Feb 6, 2023
1 parent 90b71cb commit 62b8421
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions core/perf_test/PerfTest_ViewCopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,20 @@
#include <benchmark/benchmark.h>
#endif

#include "Benchmark_Context.hpp"
#include <cmath>

namespace Test {

/**
* \brief Mark the label as a figure of merit.
*/
inline std::string benchmark_fom(const std::string& label) {
return "FOM: " + label;
}

inline void report_results(benchmark::State& state, std::size_t num_elems,
double time) {
state.SetIterationTime(time);

// data size in megabytes
const auto size = 1.0 * num_elems * sizeof(double) / 1000 / 1000;
// data processed in gigabytes
const auto data_processed = 2 * size / 1000;

state.counters["MB"] =
benchmark::Counter(size, benchmark::Counter::kDefaults);
state.counters[benchmark_fom("GB/s")] = benchmark::Counter(
data_processed, benchmark::Counter::kIsIterationInvariantRate);
}
static constexpr int DATA_RATIO = 2;

template <class ViewTypeA, class ViewTypeB>
void deepcopy_view(ViewTypeA& a, ViewTypeB& b, benchmark::State& state) {
for (auto _ : state) {
Kokkos::fence();
Kokkos::Timer timer;
Kokkos::deep_copy(a, b);
report_results(state, a.size(), timer.seconds());
KokkosBenchmark::report_results(state, a, DATA_RATIO, timer.seconds());
}
}

Expand Down Expand Up @@ -168,7 +149,7 @@ static void ViewDeepCopy_Raw(benchmark::State& state) {
Kokkos::parallel_for(
N8, KOKKOS_LAMBDA(const int& i) { a_ptr[i] = b_ptr[i]; });
Kokkos::fence();
report_results(state, a.size(), timer.seconds());
KokkosBenchmark::report_results(state, a, DATA_RATIO, timer.seconds());
}
}

Expand Down

0 comments on commit 62b8421

Please sign in to comment.