HybridADRSolver
Loading...
Searching...
No Matches
scaling_study.cpp File Reference

Comprehensive strong and weak scaling benchmark for the Hybrid ADR Solver. More...

#include "core/problem_definition.h"
#include "core/types.h"
#include "matrix_based/matrix_based_solver.h"
#include "matrix_free/matrix_free_solver.h"
#include "utils.h"
#include <deal.II/base/mpi.h>
#include <deal.II/base/multithread_info.h>
#include <algorithm>
#include <getopt.h>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
Include dependency graph for scaling_study.cpp:

Classes

struct  ScalingResult
 Extended benchmark result with scaling metrics. More...
struct  Statistics
 Statistics helper. More...

Functions

template<int dim>
unsigned int estimate_dofs (int n_refinements, int degree)
 Calculate expected DoFs for given refinement level.
template<int dim>
int calculate_min_refinements (int n_processes, int degree, unsigned int min_dofs_per_proc=MIN_DOFS_PER_PROCESS)
 Calculate minimum refinement level for given process count.
template<int dim>
TimingResults run_matrix_based_single (const ProblemInterface< dim > &problem, int n_refinements, int degree, MPI_Comm comm)
 Run matrix-based solver and collect timing.
template<int dim, int fe_degree>
TimingResults run_matrix_free_single (const ProblemInterface< dim > &problem, int n_refinements, MPI_Comm comm)
 Run matrix-free solver and collect timing.
template<int dim>
ScalingResult run_benchmark_with_trials (const ProblemInterface< dim > &problem, const std::string &solver_type, const std::string &test_type, int n_refinements, int degree, int n_warmup, int n_trials, MPI_Comm comm)
 Run multiple trials and compute statistics.
template<int dim>
std::pair< double, double > run_strong_scaling_test (std::vector< ScalingResult > &results, int n_refinements, int degree, int n_warmup, int n_trials, double baseline_solve_mb, double baseline_solve_mf, double baseline_total_mb, double baseline_total_mf, MPI_Comm comm)
 Strong scaling test with proper problem sizing.
template<int dim>
void run_weak_scaling_test (std::vector< ScalingResult > &results, int base_refinements, int degree, int n_warmup, int n_trials, double baseline_solve_mb, double baseline_solve_mf, MPI_Comm comm)
 Weak scaling test with proper problem scaling.
void write_results_csv (const std::vector< ScalingResult > &results, const std::string &filename, MPI_Comm comm)
 Write results to CSV file.
void print_summary (const std::vector< ScalingResult > &results, MPI_Comm comm)
 Print summary table.
void print_usage (const char *program_name)
int main (int argc, char *argv[])

Variables

constexpr unsigned int MIN_DOFS_PER_PROCESS = 50000

Detailed Description

Comprehensive strong and weak scaling benchmark for the Hybrid ADR Solver.

This benchmark measures:

  1. Strong Scaling: Fixed problem size, varying core count
    • Speedup: S(p) = T(1) / T(p)
    • Efficiency: E(p) = S(p) / p = T(1) / (p * T(p))
  2. Weak Scaling: Problem size scales with core count (constant work per core)
    • Efficiency: E(p) = T(1) / T(p) (ideal = 1.0)

Usage: mpirun -np <N> ./scaling_benchmark [options]

Options: –strong Run strong scaling test only –weak Run weak scaling test only –min-ref <n> Minimum refinements (default: 3) –max-ref <n> Maximum refinements (default: 7) –degree <n> Polynomial degree (default: 2) –output <file> Output CSV file prefix (default: scaling_results) –threads <n> Threads per MPI process (default: auto) –trials <n> Number of trials for averaging (default: 3) –warmup <n> Number of warmup runs (default: 1) –dim <n> Dimension 2 or 3 (default: 2)

Function Documentation

◆ calculate_min_refinements()

template<int dim>
int calculate_min_refinements ( int n_processes,
int degree,
unsigned int min_dofs_per_proc = MIN_DOFS_PER_PROCESS )

Calculate minimum refinement level for given process count.

◆ estimate_dofs()

template<int dim>
unsigned int estimate_dofs ( int n_refinements,
int degree )

Calculate expected DoFs for given refinement level.

◆ main()

int main ( int argc,
char * argv[] )

◆ print_summary()

void print_summary ( const std::vector< ScalingResult > & results,
MPI_Comm comm )

Print summary table.

◆ print_usage()

void print_usage ( const char * program_name)

◆ run_benchmark_with_trials()

template<int dim>
ScalingResult run_benchmark_with_trials ( const ProblemInterface< dim > & problem,
const std::string & solver_type,
const std::string & test_type,
int n_refinements,
int degree,
int n_warmup,
int n_trials,
MPI_Comm comm )

Run multiple trials and compute statistics.

◆ run_matrix_based_single()

template<int dim>
TimingResults run_matrix_based_single ( const ProblemInterface< dim > & problem,
int n_refinements,
int degree,
MPI_Comm comm )

Run matrix-based solver and collect timing.

◆ run_matrix_free_single()

template<int dim, int fe_degree>
TimingResults run_matrix_free_single ( const ProblemInterface< dim > & problem,
int n_refinements,
MPI_Comm comm )

Run matrix-free solver and collect timing.

◆ run_strong_scaling_test()

template<int dim>
std::pair< double, double > run_strong_scaling_test ( std::vector< ScalingResult > & results,
int n_refinements,
int degree,
int n_warmup,
int n_trials,
double baseline_solve_mb,
double baseline_solve_mf,
double baseline_total_mb,
double baseline_total_mf,
MPI_Comm comm )

Strong scaling test with proper problem sizing.

◆ run_weak_scaling_test()

template<int dim>
void run_weak_scaling_test ( std::vector< ScalingResult > & results,
int base_refinements,
int degree,
int n_warmup,
int n_trials,
double baseline_solve_mb,
double baseline_solve_mf,
MPI_Comm comm )

Weak scaling test with proper problem scaling.

◆ write_results_csv()

void write_results_csv ( const std::vector< ScalingResult > & results,
const std::string & filename,
MPI_Comm comm )

Write results to CSV file.

Variable Documentation

◆ MIN_DOFS_PER_PROCESS

unsigned int MIN_DOFS_PER_PROCESS = 50000
constexpr