Adding a Scaling Configuration

Glossary terms: Benchmark, Experiment, Scaling Study

Start with the HPL experiment definition below in experiments/hpl/experiment.py. This definition includes the completed experiment from the previous tutorial page, but does not yet register its scaling configuration.

 1# Copyright 2023 Lawrence Livermore National Security, LLC and other
 2# Benchpark Project Developers. See the top-level COPYRIGHT file for details.
 3#
 4# SPDX-License-Identifier: Apache-2.0
 5
 6from benchpark.experiment import Experiment
 7from benchpark.programming_model import ProgrammingModel, ProgrammingModelType
 8from benchpark.caliper import Caliper
 9from benchpark.directives import variant, maintainers
10from benchpark.scaling import Scaling, ScalingMode
11
12
13class Hpl(
14    Experiment,
15    ProgrammingModel(ProgrammingModelType.Mpionly, ProgrammingModelType.Openmp),
16    Caliper,
17    Scaling(ScalingMode.Strong, ScalingMode.Weak),
18):
19    variant(
20        "workload",
21        default="standard",
22        description="Which ramble workload to execute.",
23    )
24
25    variant(
26        "version",
27        default="2.3-caliper",
28        values=("latest", "2.3-caliper", "2.3", "2.2"),
29        description="Which benchmark version to use.",
30    )
31
32    maintainers("daboehme")
33
34    def compute_applications_section(self):
35
36        if self.spec.satisfies("exec_mode=test"):
37            self.add_experiment_variable("n_ranks", 1, True)
38            self.add_experiment_variable("Ns", 1000, True)
39            self.add_experiment_variable("N-Grids", 1, False)
40            self.add_experiment_variable("Ps", "{n_ranks}", True)
41            self.add_experiment_variable("Qs", "1", False)
42            self.add_experiment_variable("N-Ns", 1, False)
43            self.add_experiment_variable("N-NBs", 1, False)
44            self.add_experiment_variable("NBs", 128, False)
45        # Must be exec_mode=perf if not test mode.
46        else:
47            self.add_experiment_variable("n_ranks", 32, True)
48            self.add_experiment_variable("Ns", 100000, True)
49            self.add_experiment_variable("N-Grids", 1, False)
50            self.add_experiment_variable("Ps", "({n_ranks} // 8)", True)
51            self.add_experiment_variable("Qs", "8", False)
52            self.add_experiment_variable("N-Ns", 1, False)
53            self.add_experiment_variable("N-NBs", 1, False)
54            self.add_experiment_variable("NBs", 128, False)
55
56        # Set the variables required by the experiment
57        self.set_required_variables(
58            n_resources="{n_ranks}",
59            process_problem_size="{Ns}/{n_ranks}",
60            total_problem_size="{Ns}",
61        )
62
63        # Step 1 adds the scaling configuration here.
64
65    def compute_package_section(self):
66        self.add_package_spec(self.name, [f"hpl{self.determine_version()}"])

1. Register the Scaling Configuration

Replace the Step 1 placeholder in compute_applications_section() with the following call. Strong scaling increases n_ranks while keeping Ns constant. Weak scaling increases both values.

self.register_scaling_config(
    {
        ScalingMode.Strong: {
            "n_ranks": lambda var, itr, dim, scaling_factor: (
                var.val(dim) * scaling_factor
            ),
            "Ns": lambda var, itr, dim, scaling_factor: var.val(dim),
        },
        ScalingMode.Weak: {
            "n_ranks": lambda var, itr, dim, scaling_factor: (
                var.val(dim) * scaling_factor
            ),
            "Ns": lambda var, itr, dim, scaling_factor: (
                var.val(dim) * scaling_factor
            ),
        },
    }
)

Initialize the strong-scaling experiment with the Fluxtainer system to validate the definition:

$ benchpark experiment init --dest=hpl fluxtainer hpl+strong

For the complete experiment authoring reference, see Adding an Experiment.

Next Step