Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds run_benchmarks CMake target and adapt existing test to be a benchmark #1222

Merged
merged 21 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8c4210a
add extra metadata tags
chapman39 Aug 22, 2024
83127e0
Merge remote-tracking branch 'origin/develop' into feature/chapman39/…
chapman39 Aug 22, 2024
094066f
Create script to run benchmarks and move caliper files to shared loca…
chapman39 Aug 23, 2024
01414d2
Merge remote-tracking branch 'origin/develop' into feature/chapman39/…
chapman39 Aug 27, 2024
94f2591
print spot dir, add -e option, skip building docs
chapman39 Aug 28, 2024
b016796
Merge remote-tracking branch 'origin/develop' into feature/chapman39/…
chapman39 Aug 30, 2024
8808849
Update nonlinear solve test to run specific solvers/ prec one after a…
chapman39 Sep 5, 2024
b5e4315
attempt to make a benchmark custom cmake target
chapman39 Sep 5, 2024
65c0789
use blt_add_benchmark, run across variable task counts
chapman39 Sep 5, 2024
b3f190c
Merge remote-tracking branch 'origin/develop' into feature/chapman39/…
chapman39 Sep 9, 2024
c5caac6
update shared file name
chapman39 Sep 9, 2024
ea1f981
bring back cmd line options, optionally enter them with string
chapman39 Sep 9, 2024
232fe88
update blt with benchmark fix
chapman39 Sep 9, 2024
36c82a2
run_benchmarks documentation
chapman39 Sep 9, 2024
7417e4b
working
chapman39 Sep 9, 2024
75aa408
style
chapman39 Sep 10, 2024
69024a7
Update src/docs/sphinx/dev_guide/profiling.rst
chapman39 Sep 11, 2024
19ce9e8
Update src/docs/sphinx/dev_guide/profiling.rst
chapman39 Sep 11, 2024
f434964
prefix benchmarks with physics, remove manual error prefix in slic calls
chapman39 Sep 11, 2024
f130b87
Merge branch 'feature/chapman39/spot' of github.com:LLNL/serac into f…
chapman39 Sep 11, 2024
18d1d8e
Tie benchmark command in with spot
chapman39 Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions scripts/llnl/build_devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from argparse import ArgumentParser

import os


def parse_args():
"Parses args from command line"
Expand Down
4 changes: 4 additions & 0 deletions scripts/llnl/common_build_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ def get_shared_libs_dir():
return pjoin(get_shared_base_dir(), "libs", get_project_name())


def get_shared_spot_dir():
return pjoin(get_shared_base_dir(), "califiles")
chapman39 marked this conversation as resolved.
Show resolved Hide resolved


def get_uberenv_path():
return pjoin(get_script_dir(), "../uberenv/uberenv.py")

Expand Down
2 changes: 2 additions & 0 deletions src/serac/infrastructure/tests/profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ TEST(Profiling, MeshRefinement)
pmesh->UniformRefinement();
}

// Add metadata
SERAC_SET_METADATA("test", "profiling");
SERAC_SET_METADATA("mesh_file", mesh_file.c_str());
SERAC_SET_METADATA("number_mesh_elements", pmesh->GetNE());

Expand Down
32 changes: 22 additions & 10 deletions src/serac/physics/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@

set(benchmark_depends serac_physics)
chapman39 marked this conversation as resolved.
Show resolved Hide resolved

blt_add_executable(NAME benchmark_thermal
SOURCES benchmark_thermal.cpp
DEPENDS_ON ${benchmark_depends}
OUTPUT_DIR ${PROJECT_BINARY_DIR}/benchmarks
FOLDER serac/benchmarks)
set(benchmark_targets
benchmark_functional
benchmark_solid_nonlinear_solve
benchmark_thermal
)

blt_add_executable(NAME benchmark_functional
SOURCES benchmark_functional.cpp
DEPENDS_ON ${benchmark_depends}
OUTPUT_DIR ${PROJECT_BINARY_DIR}/benchmarks
FOLDER serac/benchmarks)
# Create executable for each benchmark
foreach(benchmark ${benchmark_targets})
blt_add_executable(NAME ${benchmark}
SOURCES ${benchmark}.cpp
DEPENDS_ON ${benchmark_depends}
OUTPUT_DIR ${PROJECT_BINARY_DIR}/benchmarks
FOLDER serac/benchmarks
)

# Add benchmarks with various task counts
foreach(task_count 1 4 16)
blt_add_benchmark(NAME ${benchmark}_${task_count}_task_count
COMMAND ${benchmark}
NUM_MPI_TASKS ${task_count}
)
endforeach()
endforeach()
3 changes: 3 additions & 0 deletions src/serac/physics/benchmarks/benchmark_functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ int main(int argc, char* argv[])
// Initialize profiling
serac::profiling::initialize();

// Add metadata
SERAC_SET_METADATA("test", "functional");

SERAC_MARK_BEGIN("scalar H1");

SERAC_MARK_BEGIN("dimension 2, order 1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <algorithm>

#include "axom/slic/core/SimpleLogger.hpp"
#include <gtest/gtest.h>
#include "mfem.hpp"

#include "serac/physics/materials/liquid_crystal_elastomer.hpp"
Expand Down Expand Up @@ -48,10 +47,7 @@ enum NonlinSolve
TRUSTREGION
};

NonlinSolve nonlinSolve = NonlinSolve::TRUSTREGION;
Prec prec = Prec::JACOBI;

auto get_opts(int max_iters, double abs_tol = 1e-9)
auto get_opts(NonlinSolve nonlinSolve, Prec prec, int max_iters, double abs_tol = 1e-9)
{
serac::NonlinearSolverOptions nonlinear_options{
.nonlin_solver = NonlinearSolver::TrustRegion,
Expand Down Expand Up @@ -160,7 +156,7 @@ auto get_opts(int max_iters, double abs_tol = 1e-9)
#include <ostream>
#include <fstream>

void functional_solid_test_euler()
void functional_solid_test_euler(NonlinSolve nonlinSolve, Prec prec)
{
// initialize serac
axom::sidre::DataStore datastore;
Expand Down Expand Up @@ -192,7 +188,7 @@ void functional_solid_test_euler()
// solid mechanics
using seracSolidType = serac::SolidMechanics<ORDER, DIM, serac::Parameters<>>;

auto [nonlinear_options, linear_options] = get_opts(3 * Nx * Ny * Nz, 1e-9);
auto [nonlinear_options, linear_options] = get_opts(nonlinSolve, prec, 3 * Nx * Ny * Nz, 1e-9);

auto seracSolid = std::make_unique<seracSolidType>(
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options,
Expand Down Expand Up @@ -224,7 +220,7 @@ void functional_solid_test_euler()
}
}

void functional_solid_test_nonlinear_buckle(double loadMagnitude)
void functional_solid_test_nonlinear_buckle(NonlinSolve nonlinSolve, Prec prec, double loadMagnitude)
{
// initialize serac
axom::sidre::DataStore datastore;
Expand Down Expand Up @@ -258,7 +254,7 @@ void functional_solid_test_nonlinear_buckle(double loadMagnitude)
// solid mechanics
using seracSolidType = serac::SolidMechanics<ORDER, DIM, serac::Parameters<>>;

auto [nonlinear_options, linear_options] = get_opts(3 * Nx * Ny * Nz, 1e-11);
auto [nonlinear_options, linear_options] = get_opts(nonlinSolve, prec, 3 * Nx * Ny * Nz, 1e-11);

auto seracSolid = std::make_unique<seracSolidType>(
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options,
Expand All @@ -280,30 +276,33 @@ void functional_solid_test_nonlinear_buckle(double loadMagnitude)
seracSolid->outputStateToDisk("paraview_buckle_easy");
}

TEST(SolidMechanics, nonlinear_solve_buckle_easy) { functional_solid_test_nonlinear_buckle(5e-10); }
// TEST(SolidMechanics, nonlinear_solve_buckle_medium) { functional_solid_test_nonlinear_buckle(4e-4); }
// TEST(SolidMechanics, nonlinear_solve_buckle_hard) { functional_solid_test_nonlinear_buckle(3e-2); }
// TEST(SolidMechanics, nonlinear_solve_euler) { functional_solid_test_euler(); }

int main(int argc, char* argv[])
{
axom::CLI::App app{"Nonlinear problems"};
// app.add_option("-p", mesh_path, "Path to mesh files")->check(axom::CLI::ExistingDirectory);
app.add_option("--nonlinear-solver", nonlinSolve, "Nonlinear solver", true);
app.add_option("--preconditioner", prec, "Preconditioner", true);
app.set_help_flag("--help");
app.allow_extras()->parse(argc, argv);

::testing::InitGoogleTest(&argc, argv);

serac::initialize(argc, argv);

SERAC_SET_METADATA("test", "solid_nonlinear_solve");
SERAC_SET_METADATA("nonlinear solver", std::to_string(nonlinSolve));
SERAC_SET_METADATA("preconditioner", std::to_string(prec));

int result = RUN_ALL_TESTS();
serac::exitGracefully(result);
// TODO add commandline options. if there set, run with those options only. otherwise, run the options below:

SERAC_MARK_BEGIN("Jacobi Preconditioner");
functional_solid_test_nonlinear_buckle(NonlinSolve::NEWTON, Prec::JACOBI, 5e-10);
SERAC_MARK_END("Jacobi Preconditioner");

SERAC_MARK_BEGIN("Multigrid Preconditioner");
functional_solid_test_nonlinear_buckle(NonlinSolve::NEWTON, Prec::MULTIGRID, 5e-10);
SERAC_MARK_END("Multigrid Preconditioner");

SERAC_MARK_BEGIN("Petsc Multigrid Preconditioner");
functional_solid_test_nonlinear_buckle(NonlinSolve::NEWTON, Prec::PETSC_MULTIGRID, 5e-10);
SERAC_MARK_END("Petsc Multigrid Preconditioner");

// functional_solid_test_nonlinear_buckle(4e-4);
// functional_solid_test_nonlinear_buckle(3e-2);
// functional_solid_test_euler();

serac::profiling::finalize();

MPI_Finalize();

return result;
return 0;
}
1 change: 0 additions & 1 deletion src/serac/physics/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ set(physics_parallel_test_sources
dynamic_thermal_adjoint.cpp
solid_reaction_adjoint.cpp
thermal_nonlinear_solve.cpp
solid_nonlinear_solve.cpp
)
blt_list_append(TO physics_parallel_test_sources ELEMENTS contact_patch.cpp contact_beam.cpp IF TRIBOL_FOUND)

Expand Down