Skip to content
Snippets Groups Projects
Unverified Commit ab32edbe authored by Jayesh Badwaik's avatar Jayesh Badwaik
Browse files

[wip] : baseline benchmark

parent c51ab144
No related branches found
No related tags found
No related merge requests found
Pipeline #132143 failed
......@@ -16,5 +16,28 @@ add_subdirectory(common)
# Adding Benchmarks
# ------------------------------------------------------------------------------
# We only build the following tests when source the is also being built.
if(BUILD_SOURCE)
add_subdirectory(baseline)
add_subdirectory(micro)
endif()
# --------------------------------------------------------------------------------------------------
# Resolving Dependencies
# --------------------------------------------------------------------------------------------------
if(PROJECT_FEATURE_CUDA)
target_link_libraries(libbenchzell PUBLIC zell::cuda)
endif()
if(PROJECT_FEATURE_HIP)
target_link_libraries(libbenchzell PUBLIC zell::hip)
endif()
if(PROJECT_FEATURE_MPI)
target_link_libraries(libbenchzell PUBLIC zell::mpi)
endif()
target_link_libraries(libbenchzell PUBLIC zell::cxx)
target_link_libraries(libbenchzell PUBLIC zell::c)
target_link_libraries(libbenchzell PUBLIC Catch2::Catch2)
# --------------------------------------------------------------------------------------------------
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: (C) 2022 Jayesh Badwaik <j.badwaik@fz-juelich.de>
# --------------------------------------------------------------------------------------------------
add_subdirectory(cpp)
# --------------------------------------------------------------------------------------------------
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: (C) 2022 Jayesh Badwaik <j.badwaik@fz-juelich.de>
# --------------------------------------------------------------------------------------------------
add_executable(baseline.compute.b compute.b.cpp)
add_test(baseline.compute.b baseline.compute.b)
set_property(TEST baseline.compute.b PROPERTY LABELS "baseline_bench,production.bench")
target_link_libraries(baseline.compute.b PRIVATE libbenchzell)
// -------------------------------------------------------------------------------------------------
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: (C) 2022 Jayesh Badwaik <j.badwaik@fz-juelich.de>
// -------------------------------------------------------------------------------------------------
/*
* The objective of this program is to run a program of approximately 4 GFLOP
* and measure the performance of the underlying CPU.
*/
#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
auto main() -> int
{
// Gather Information about the Clock
using steady_clock_t = std::chrono::steady_clock;
using clock_period_t = steady_clock_t::duration::period;
constexpr long double duration
= static_cast<long double>(clock_period_t::num) / clock_period_t::den;
std::int64_t const max_iteration = 1'000'000'000;
double x_value[16];
double y_value[16];
double z_value[16];
double w_value[16];
for (std::int64_t k = 0; k < 16; ++k) {
x_value[k] = 0.7;
y_value[k] = 0.7;
z_value[k] = 0.7;
w_value[k] = 0.7;
}
auto const single_run_start = steady_clock_t::now();
for (std::int64_t i = 0; i < max_iteration; ++i) {
for (std::int64_t k = 0; k < 16; ++k) {
x_value[k] = 3.8 * x_value[k] * (1 - x_value[k]);
x_value[k] = 3.8 * x_value[k] * (1 - x_value[k]);
y_value[k] = 3.8 * y_value[k] * (1 - y_value[k]);
y_value[k] = 3.8 * y_value[k] * (1 - y_value[k]);
z_value[k] = 3.8 * z_value[k] * (1 - z_value[k]);
z_value[k] = 3.8 * z_value[k] * (1 - z_value[k]);
w_value[k] = 3.8 * w_value[k] * (1 - w_value[k]);
w_value[k] = 3.8 * w_value[k] * (1 - w_value[k]);
}
}
auto const single_run_end = steady_clock_t::now();
auto const single_run_delta = (single_run_end - single_run_start);
auto const double_run_start = steady_clock_t::now();
for (std::int64_t j = 0; j < 2; ++j) {
for (std::int64_t i = 0; i < max_iteration; ++i) {
for (std::int64_t k = 0; k < 16; ++k) {
x_value[k] = 3.8 * x_value[k] * (1 - x_value[k]);
x_value[k] = 3.8 * x_value[k] * (1 - x_value[k]);
y_value[k] = 3.8 * y_value[k] * (1 - y_value[k]);
y_value[k] = 3.8 * y_value[k] * (1 - y_value[k]);
z_value[k] = 3.8 * z_value[k] * (1 - z_value[k]);
z_value[k] = 3.8 * z_value[k] * (1 - z_value[k]);
w_value[k] = 3.8 * w_value[k] * (1 - w_value[k]);
w_value[k] = 3.8 * w_value[k] * (1 - w_value[k]);
}
}
}
auto const double_run_end = steady_clock_t::now();
auto const double_run_delta = (double_run_end - double_run_start);
auto const normalized_run_delta = double_run_delta - single_run_delta;
[[maybe_unused]] auto const speed
= static_cast<long double>(16 * 8 * 4.0) / (normalized_run_delta.count() * duration);
std::cout << "Processor Time = " << (normalized_run_delta.count() * duration) << " s\n";
std::cout << "Processor Speed = " << speed << " GFLOP/s\n";
constexpr auto epsilon = 10 * std::numeric_limits<double>::epsilon();
if (std::abs(x_value[0] - 0.8305942139168042) > epsilon) {
std::cout << std::setprecision(16) << "Value = " << x_value[0] << "\n";
return EXIT_FAILURE;
}
if (std::abs(y_value[0] - 0.8305942139168042) > epsilon) {
std::cout << std::setprecision(16) << "Value = " << y_value[0] << "\n";
return EXIT_FAILURE;
}
if (std::abs(z_value[0] - 0.8305942139168042) > epsilon) {
std::cout << std::setprecision(16) << "Value = " << z_value[0] << "\n";
return EXIT_FAILURE;
}
if (std::abs(w_value[0] - 0.8305942139168042) > epsilon) {
std::cout << std::setprecision(16) << "Value = " << w_value[0] << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
// -------------------------------------------------------------------------------------------------
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: (C) 2022 Jayesh Badwaik <j.badwaik@fz-juelich.de>
// -------------------------------------------------------------------------------------------------
#ifndef MOL_BENCH_HPP
#define MOL_BENCH_HPP
#define MOL_BENCH(name) MOL_DETAIL_BENCH_IMPL(name)
#endif // MOL_BENCH_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment