diff --git a/fft/perf_test/Benchmark_Context.hpp b/fft/perf_test/Benchmark_Context.hpp index 1d222bb4..337b3f90 100644 --- a/fft/perf_test/Benchmark_Context.hpp +++ b/fft/perf_test/Benchmark_Context.hpp @@ -11,111 +11,114 @@ #include namespace KokkosFFTBenchmark { - /// \brief Remove unwanted spaces and colon signs from input string. In case of - /// invalid input it will return an empty string. - inline std::string remove_unwanted_characters(std::string str) { - auto from = str.find_first_not_of(" :"); - auto to = str.find_last_not_of(" :"); - - if (from == std::string::npos || to == std::string::npos) { - return ""; - } - - // return extracted part of string without unwanted spaces and colon signs - return str.substr(from, to + 1); +/// \brief Remove unwanted spaces and colon signs from input string. In case of +/// invalid input it will return an empty string. +inline std::string remove_unwanted_characters(std::string str) { + auto from = str.find_first_not_of(" :"); + auto to = str.find_last_not_of(" :"); + + if (from == std::string::npos || to == std::string::npos) { + return ""; } - /// \brief Extract all key:value pairs from kokkos configuration and add it to - /// the benchmark context - inline void add_kokkos_configuration(bool verbose) { - std::ostringstream msg; - Kokkos::print_configuration(msg, verbose); - KokkosFFT::print_configuration(msg); - - // Iterate over lines returned from kokkos and extract key:value pairs - std::stringstream ss{msg.str()}; - for (std::string line; std::getline(ss, line, '\n');) { - auto found = line.find_first_of(':'); - if (found != std::string::npos) { - auto val = remove_unwanted_characters(line.substr(found + 1)); - // Ignore line without value, for example a category name - if (!val.empty()) { - benchmark::AddCustomContext( - remove_unwanted_characters(line.substr(0, found)), val); - } + // return extracted part of string without unwanted spaces and colon signs + return str.substr(from, to + 1); +} + +/// \brief Extract all key:value pairs from kokkos configuration and add it to +/// the benchmark context +inline void add_kokkos_configuration(bool verbose) { + std::ostringstream msg; + Kokkos::print_configuration(msg, verbose); + KokkosFFT::print_configuration(msg); + + // Iterate over lines returned from kokkos and extract key:value pairs + std::stringstream ss{msg.str()}; + for (std::string line; std::getline(ss, line, '\n');) { + auto found = line.find_first_of(':'); + if (found != std::string::npos) { + auto val = remove_unwanted_characters(line.substr(found + 1)); + // Ignore line without value, for example a category name + if (!val.empty()) { + benchmark::AddCustomContext( + remove_unwanted_characters(line.substr(0, found)), val); } } } - - /// \brief Add Kokkos Kernels git info and google benchmark release to - /// benchmark context. - inline void add_version_info() { - using namespace KokkosFFT::Impl; - - if (!GIT_BRANCH.empty()) { - benchmark::AddCustomContext("GIT_BRANCH", std::string(GIT_BRANCH)); - benchmark::AddCustomContext("GIT_COMMIT_HASH", - std::string(GIT_COMMIT_HASH)); - benchmark::AddCustomContext("GIT_CLEAN_STATUS", - std::string(GIT_CLEAN_STATUS)); - benchmark::AddCustomContext("GIT_COMMIT_DESCRIPTION", - std::string(GIT_COMMIT_DESCRIPTION)); - benchmark::AddCustomContext("GIT_COMMIT_DATE", - std::string(GIT_COMMIT_DATE)); - } - if (!BENCHMARK_VERSION.empty()) { - benchmark::AddCustomContext("GOOGLE_BENCHMARK_VERSION", - std::string(BENCHMARK_VERSION)); - } +} + +/// \brief Add Kokkos Kernels git info and google benchmark release to +/// benchmark context. +inline void add_version_info() { + using namespace KokkosFFT::Impl; + + if (!GIT_BRANCH.empty()) { + benchmark::AddCustomContext("GIT_BRANCH", std::string(GIT_BRANCH)); + benchmark::AddCustomContext("GIT_COMMIT_HASH", + std::string(GIT_COMMIT_HASH)); + benchmark::AddCustomContext("GIT_CLEAN_STATUS", + std::string(GIT_CLEAN_STATUS)); + benchmark::AddCustomContext("GIT_COMMIT_DESCRIPTION", + std::string(GIT_COMMIT_DESCRIPTION)); + benchmark::AddCustomContext("GIT_COMMIT_DATE", + std::string(GIT_COMMIT_DATE)); } - - inline void add_env_info() { - auto num_threads = std::getenv("OMP_NUM_THREADS"); - if (num_threads) { - benchmark::AddCustomContext("OMP_NUM_THREADS", num_threads); - } - auto dynamic = std::getenv("OMP_DYNAMIC"); - if (dynamic) { - benchmark::AddCustomContext("OMP_DYNAMIC", dynamic); - } - auto proc_bind = std::getenv("OMP_PROC_BIND"); - if (proc_bind) { - benchmark::AddCustomContext("OMP_PROC_BIND", proc_bind); - } - auto places = std::getenv("OMP_PLACES"); - if (places) { - benchmark::AddCustomContext("OMP_PLACES", places); - } + if (!BENCHMARK_VERSION.empty()) { + benchmark::AddCustomContext("GOOGLE_BENCHMARK_VERSION", + std::string(BENCHMARK_VERSION)); } +} - /// \brief Gather all context information and add it to benchmark context - inline void add_benchmark_context(bool verbose = false) { - add_kokkos_configuration(verbose); - add_version_info(); - add_env_info(); +inline void add_env_info() { + auto num_threads = std::getenv("OMP_NUM_THREADS"); + if (num_threads) { + benchmark::AddCustomContext("OMP_NUM_THREADS", num_threads); } - - /** - * \brief Report throughput and amount of data processed for simple View - * operations - */ - template - void report_results(benchmark::State& state, InViewType in, OutViewType out, double time) { - // data processed in megabytes - const double in_data_processed = static_cast(in.size() * - sizeof(typename InViewType::value_type)) / - 1.0e6; - const double out_data_processed = static_cast(out.size() * - sizeof(typename OutViewType::value_type)) / - 1.0e6; - - state.SetIterationTime(time); - state.counters["MB (In)"] = benchmark::Counter(in_data_processed); - state.counters["MB (Out)"] = benchmark::Counter(out_data_processed); - state.counters["GB/s"] = benchmark::Counter( - (in_data_processed + out_data_processed) / 1.0e3, benchmark::Counter::kIsIterationInvariantRate); + auto dynamic = std::getenv("OMP_DYNAMIC"); + if (dynamic) { + benchmark::AddCustomContext("OMP_DYNAMIC", dynamic); } - -} // namespace KokkosFFTBenchmark + auto proc_bind = std::getenv("OMP_PROC_BIND"); + if (proc_bind) { + benchmark::AddCustomContext("OMP_PROC_BIND", proc_bind); + } + auto places = std::getenv("OMP_PLACES"); + if (places) { + benchmark::AddCustomContext("OMP_PLACES", places); + } +} + +/// \brief Gather all context information and add it to benchmark context +inline void add_benchmark_context(bool verbose = false) { + add_kokkos_configuration(verbose); + add_version_info(); + add_env_info(); +} + +/** + * \brief Report throughput and amount of data processed for simple View + * operations + */ +template +void report_results(benchmark::State& state, InViewType in, OutViewType out, + double time) { + // data processed in megabytes + const double in_data_processed = + static_cast(in.size() * sizeof(typename InViewType::value_type)) / + 1.0e6; + const double out_data_processed = + static_cast(out.size() * + sizeof(typename OutViewType::value_type)) / + 1.0e6; + + state.SetIterationTime(time); + state.counters["MB (In)"] = benchmark::Counter(in_data_processed); + state.counters["MB (Out)"] = benchmark::Counter(out_data_processed); + state.counters["GB/s"] = + benchmark::Counter((in_data_processed + out_data_processed) / 1.0e3, + benchmark::Counter::kIsIterationInvariantRate); +} + +} // namespace KokkosFFTBenchmark #endif \ No newline at end of file diff --git a/fft/perf_test/KokkosFFT_PrintConfiguration.hpp b/fft/perf_test/KokkosFFT_PrintConfiguration.hpp index bf590f00..022b3efc 100644 --- a/fft/perf_test/KokkosFFT_PrintConfiguration.hpp +++ b/fft/perf_test/KokkosFFT_PrintConfiguration.hpp @@ -61,17 +61,14 @@ inline void print_enabled_tpls(std::ostream& os) { #endif } - inline void print_version(std::ostream& os) { - // KOKKOSFFT_VERSION is used because MAJOR, MINOR and PATCH macros // are not available in FFT os << " " << "KokkosFFT Version: " << KOKKOSFFT_VERSION_MAJOR << "." - << KOKKOSFFT_VERSION_MINOR << "." << KOKKOSFFT_VERSION_PATCH - << '\n'; + << KOKKOSFFT_VERSION_MINOR << "." << KOKKOSFFT_VERSION_PATCH << '\n'; } -} // namespace Impl +} // namespace Impl inline void print_configuration(std::ostream& os) { Impl::print_version(os); @@ -80,6 +77,6 @@ inline void print_configuration(std::ostream& os) { Impl::print_enabled_tpls(os); } -} // namespace KokkosFFT +} // namespace KokkosFFT #endif \ No newline at end of file diff --git a/fft/perf_test/KokkosFFT_TplsVersion.hpp b/fft/perf_test/KokkosFFT_TplsVersion.hpp index 11e0354a..e5ec33da 100644 --- a/fft/perf_test/KokkosFFT_TplsVersion.hpp +++ b/fft/perf_test/KokkosFFT_TplsVersion.hpp @@ -36,5 +36,5 @@ inline std::string cufft_version_string() { } #endif -} // namespace KokkosFFT +} // namespace KokkosFFT #endif \ No newline at end of file diff --git a/fft/perf_test/PerfTest_FFT1.cpp b/fft/perf_test/PerfTest_FFT1.cpp index 846714cd..4148103a 100644 --- a/fft/perf_test/PerfTest_FFT1.cpp +++ b/fft/perf_test/PerfTest_FFT1.cpp @@ -120,4 +120,4 @@ BENCHMARK(IRFFT_1DView) ->UseManualTime() ->Unit(benchmark::kMicrosecond); -} // namespace KokkosFFTBenchmark \ No newline at end of file +} // namespace KokkosFFTBenchmark \ No newline at end of file diff --git a/fft/perf_test/PerfTest_FFT1.hpp b/fft/perf_test/PerfTest_FFT1.hpp index 074a78e0..6424b4e7 100644 --- a/fft/perf_test/PerfTest_FFT1.hpp +++ b/fft/perf_test/PerfTest_FFT1.hpp @@ -80,7 +80,7 @@ static void RFFT_1DView(benchmark::State& state) { const int n = state.range(0); RealView1DType x("x", n); - ComplexView1DType x_hat("x_hat", n/2+1); + ComplexView1DType x_hat("x_hat", n / 2 + 1); rfft(x, x_hat, state); } @@ -92,12 +92,12 @@ static void IRFFT_1DView(benchmark::State& state) { Kokkos::View*, LayoutType, execution_space>; const int n = state.range(0); - ComplexView1DType x("x", n/2+1); + ComplexView1DType x("x", n / 2 + 1); RealView1DType x_hat("x_hat", n); irfft(x, x_hat, state); } -} // namespace KokkosFFTBenchmark +} // namespace KokkosFFTBenchmark #endif \ No newline at end of file