Skip to content

Commit

Permalink
Merge pull request #605 from PlasmaControl/dp/fix-benchmarks
Browse files Browse the repository at this point in the history
Fix Benchmarks
  • Loading branch information
dpanici authored Aug 2, 2023
2 parents 587d15f + 0c3ac7f commit f68f157
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
14 changes: 8 additions & 6 deletions tests/benchmarks/benchmark_cpu_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,12 @@ def test_perturb_1(SOLOVEV, benchmark):

def setup():
eq = EquilibriaFamily.load(load_from=str(SOLOVEV["desc_h5_path"]))[-1]
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)

constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}
args = (
Expand Down Expand Up @@ -283,11 +284,12 @@ def test_perturb_2(SOLOVEV, benchmark):

def setup():
eq = EquilibriaFamily.load(load_from=str(SOLOVEV["desc_h5_path"]))[-1]
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)

constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}
args = (
Expand Down
35 changes: 16 additions & 19 deletions tests/benchmarks/benchmark_cpu_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_objective_compile_heliotron(benchmark):

def setup():
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
Expand All @@ -141,7 +141,7 @@ def test_objective_compile_dshape_current(benchmark):

def setup():
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
Expand All @@ -164,12 +164,9 @@ def test_objective_compile_atf(benchmark):

def setup():
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
eq,
)
args = (objective, eq)
kwargs = {}
return args, kwargs

Expand All @@ -185,7 +182,7 @@ def run(objective, eq):
def test_objective_compute_heliotron(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -202,7 +199,7 @@ def run(x):
def test_objective_compute_dshape_current(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -219,7 +216,7 @@ def run(x):
def test_objective_compute_atf(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -236,7 +233,7 @@ def run(x):
def test_objective_jac_heliotron(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -253,7 +250,7 @@ def run(x):
def test_objective_jac_dshape_current(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -270,7 +267,7 @@ def run(x):
def test_objective_jac_atf(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -289,11 +286,11 @@ def test_perturb_1(benchmark):

def setup():
eq = desc.examples.get("SOLOVEV")
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)
constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down Expand Up @@ -322,11 +319,11 @@ def test_perturb_2(benchmark):

def setup():
eq = desc.examples.get("SOLOVEV")
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)
constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down
14 changes: 8 additions & 6 deletions tests/benchmarks/benchmark_gpu_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,12 @@ def test_perturb_1(SOLOVEV, benchmark):

def setup():
eq = EquilibriaFamily.load(load_from=str(SOLOVEV["desc_h5_path"]))[-1]
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)

constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down Expand Up @@ -284,11 +285,12 @@ def test_perturb_2(SOLOVEV, benchmark):

def setup():
eq = EquilibriaFamily.load(load_from=str(SOLOVEV["desc_h5_path"]))[-1]
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)

constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down
30 changes: 15 additions & 15 deletions tests/benchmarks/benchmark_gpu_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_objective_compile_heliotron(benchmark):

def setup():
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
Expand All @@ -141,7 +141,7 @@ def test_objective_compile_dshape_current(benchmark):

def setup():
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
Expand All @@ -164,7 +164,7 @@ def test_objective_compile_atf(benchmark):

def setup():
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
args = (
objective,
Expand All @@ -185,7 +185,7 @@ def run(objective, eq):
def test_objective_compute_heliotron(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -202,7 +202,7 @@ def run(x):
def test_objective_compute_dshape_current(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -219,7 +219,7 @@ def run(x):
def test_objective_compute_atf(benchmark):
"""Benchmark computing objective."""
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -236,7 +236,7 @@ def run(x):
def test_objective_jac_heliotron(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("HELIOTRON")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -253,7 +253,7 @@ def run(x):
def test_objective_jac_dshape_current(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("DSHAPE_current")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -270,7 +270,7 @@ def run(x):
def test_objective_jac_atf(benchmark):
"""Benchmark computing jacobian."""
eq = desc.examples.get("ATF")
objective = get_equilibrium_objective()
objective = get_equilibrium_objective(eq)
objective.build(eq)
objective.compile()
x = objective.x(eq)
Expand All @@ -289,11 +289,11 @@ def test_perturb_1(benchmark):

def setup():
eq = desc.examples.get("SOLOVEV")
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)
constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down Expand Up @@ -322,11 +322,11 @@ def test_perturb_2(benchmark):

def setup():
eq = desc.examples.get("SOLOVEV")
objective = get_equilibrium_objective()
constraints = get_fixed_boundary_constraints()
objective = get_equilibrium_objective(eq)
objective.build(eq)
constraints = get_fixed_boundary_constraints(eq)
tr_ratio = [0.01, 0.25, 0.25]
dp = np.zeros_like(eq.p_l)
objective.build(eq)
dp[np.array([0, 2])] = 8e3 * np.array([1, -1])
deltas = {"p_l": dp}

Expand Down

0 comments on commit f68f157

Please sign in to comment.