Skip to content

Commit

Permalink
Port ViewFill performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Feb 6, 2023
1 parent 2aa2576 commit 5235c89
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 189 deletions.
60 changes: 60 additions & 0 deletions core/perf_test/Benchmark_Context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott ([email protected])
//
// ************************************************************************
//@HEADER
*/

#include <Benchmark_Context.hpp>

namespace Test {

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

void add_benchmark_context(bool verbose) {
std::ostringstream msg;
Kokkos::print_configuration(msg, verbose);
benchmark::AddCustomContext("Kokkos configuration", msg.str());
}

} // namespace Test
2 changes: 2 additions & 0 deletions core/perf_test/Benchmark_Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

namespace KokkosBenchmark {

std::string benchmark_fom(const std::string& label);

/// \brief Remove unwanted spaces and colon signs from input string. In case of
/// invalid input it will return an empty string.
std::string remove_unwanted_characters(std::string str) {
Expand Down
6 changes: 6 additions & 0 deletions core/perf_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ SET(
PerfTest_ViewCopy_c8.cpp
PerfTest_ViewCopy_d8.cpp
PerfTest_ViewCopy_Raw.cpp
PerfTest_ViewFill.cpp
PerfTest_ViewFill_123.cpp
PerfTest_ViewFill_45.cpp
PerfTest_ViewFill_6.cpp
PerfTest_ViewFill_7.cpp
PerfTest_ViewFill_8.cpp
)

KOKKOS_ADD_BENCHMARK(
Expand Down
1 change: 0 additions & 1 deletion core/perf_test/PerfTest_ViewCopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ 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());
}
}
Expand Down
2 changes: 2 additions & 0 deletions core/perf_test/PerfTest_ViewCopy_Raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "PerfTest_ViewCopy.hpp"

#include <Benchmark_Context.hpp>

namespace Test {

#if defined(KOKKOS_ENABLE_CUDA_LAMBDA) || !defined(KOKKOS_ENABLE_CUDA)
Expand Down
63 changes: 63 additions & 0 deletions core/perf_test/PerfTest_ViewFill.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott ([email protected])
//
// ************************************************************************
//@HEADER
*/

#include <PerfTest_ViewFill.hpp>

#include <Benchmark_Context.hpp>

namespace Test {

void report_results_fill(benchmark::State& state, double time) {
state.SetIterationTime(time);
const auto N8 = std::pow(state.range(0), 8);
const auto size = N8 * 8 / 1024 / 1024;

state.counters["MB"] = benchmark::Counter(size, benchmark::Counter::kDefaults,
benchmark::Counter::OneK::kIs1024);
state.counters[benchmark_fom("GB/s")] =
benchmark::Counter(size / 1024 / time, benchmark::Counter::kDefaults,
benchmark::Counter::OneK::kIs1024);
}

} // namespace Test
Loading

0 comments on commit 5235c89

Please sign in to comment.