-
Notifications
You must be signed in to change notification settings - Fork 33
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
TL: first revision for the parallel SDC theory paper #481
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a0d29c9
TL: dump version
tlunet 534a607
TL: added MPI script for pSDC theory paper
tlunet e3a3b87
TL: adapted script for parallel computation
tlunet c8a1f57
TL: minor detail for output
tlunet be52d33
TL: mini-fixes and black
tlunet 8a2d682
TL: update for plots
tlunet e0ff6f3
TL: upload reference data from jusuf runs
tlunet 11a7ca7
TL: minor modifications
tlunet c3b31c1
TL: prepared PR
tlunet 5997c02
TL: fix linting error
tlunet d31e71b
TL: added missing dependency for project tests
tlunet e95a3f8
TL: another detail
tlunet 38752ed
TL: eventually <=> finally apparently
tlunet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ dependencies: | |
- matplotlib>=3.0 | ||
- dill>=0.2.6 | ||
- scipy>=0.17.1 | ||
- mpich | ||
- mpi4py>=3.0.0 | ||
- pip | ||
- pip: | ||
- qmat>=0.1.8 |
105 changes: 105 additions & 0 deletions
105
pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu Jan 11 11:14:01 2024 | ||
|
||
Figures with experiments on the Allen-Cahn problem (MPI runs) | ||
""" | ||
import os | ||
import sys | ||
import json | ||
import numpy as np | ||
from mpi4py import MPI | ||
|
||
from pySDC.projects.parallelSDC_reloaded.utils import solutionExact, getParamsSDC, solutionSDC, getParamsRK | ||
from pySDC.implementations.sweeper_classes.generic_implicit_MPI import generic_implicit_MPI | ||
|
||
PATH = '/' + os.path.join(*__file__.split('/')[:-1]) | ||
SCRIPT = __file__.split('/')[-1].split('.')[0] | ||
|
||
COMM_WORLD = MPI.COMM_WORLD | ||
|
||
# SDC parameters | ||
nNodes = 4 | ||
quadType = 'RADAU-RIGHT' | ||
nodeType = 'LEGENDRE' | ||
parEfficiency = 0.8 # 1/nNodes | ||
nSweeps = 4 | ||
|
||
# Problem parameters | ||
pName = "ALLEN-CAHN" | ||
tEnd = 50 | ||
pParams = { | ||
"periodic": False, | ||
"nvars": 2**11 - 1, | ||
"epsilon": 0.04, | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
# %% Convergence and error VS cost plots | ||
# ----------------------------------------------------------------------------- | ||
nStepsList = np.array([5, 10, 20, 50, 100, 200, 500]) | ||
dtVals = tEnd / nStepsList | ||
|
||
|
||
def getError(uNum, uRef): | ||
if uNum is None: | ||
return np.inf | ||
return np.linalg.norm(uRef[-1, :] - uNum[-1, :], ord=2) | ||
|
||
|
||
def getCost(counters): | ||
_, _, tComp = counters | ||
return tComp | ||
|
||
|
||
try: | ||
qDelta = sys.argv[1] | ||
except IndexError: | ||
qDelta = "MIN-SR-FLEX" | ||
|
||
try: | ||
params = getParamsRK(qDelta) | ||
except KeyError: | ||
params = getParamsSDC(quadType=quadType, numNodes=nNodes, nodeType=nodeType, qDeltaI=qDelta, nSweeps=nSweeps) | ||
|
||
useMPI = False | ||
if COMM_WORLD.Get_size() == 4 and qDelta in ["MIN-SR-NS", "MIN-SR-S", "MIN-SR-FLEX", "VDHS"]: # pragma: no cover | ||
params['sweeper_class'] = generic_implicit_MPI | ||
useMPI = True | ||
|
||
errors = [] | ||
costs = [] | ||
|
||
root = COMM_WORLD.Get_rank() == 0 | ||
if root: | ||
print(f"Running simulation with {qDelta}") | ||
|
||
for nSteps in nStepsList: | ||
if root: | ||
uRef = solutionExact(tEnd, nSteps, pName, **pParams) | ||
|
||
uSDC, counters, parallel = solutionSDC(tEnd, nSteps, params, pName, verbose=root, noExcept=True, **pParams) | ||
|
||
if root: | ||
err = getError(uSDC, uRef) | ||
errors.append(err) | ||
|
||
cost = getCost(counters) | ||
costs.append(cost) | ||
|
||
if COMM_WORLD.Get_rank() == 0: | ||
errors = [float(e) for e in errors] | ||
|
||
print("errors : ", errors) | ||
print("tComps : ", costs) | ||
fileName = f"{PATH}/fig06_compTime.json" | ||
timings = {} | ||
if os.path.isfile(fileName): | ||
with open(fileName, "r") as f: | ||
timings = json.load(f) | ||
|
||
timings[qDelta + "_MPI" * useMPI] = {"errors": errors, "costs": costs} | ||
|
||
with open(fileName, 'w') as f: | ||
json.dump(timings, f, indent=4) |
89 changes: 89 additions & 0 deletions
89
pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu Jan 11 11:14:01 2024 | ||
|
||
Figures with experiments on the Allen-Cahn problem (MPI runs) | ||
""" | ||
import os | ||
import json | ||
import numpy as np | ||
|
||
from pySDC.projects.parallelSDC_reloaded.utils import plt | ||
|
||
PATH = '/' + os.path.join(*__file__.split('/')[:-1]) | ||
SCRIPT = __file__.split('/')[-1].split('.')[0] | ||
|
||
fileName = f"{PATH}/fig06_compTime.json" | ||
timings = {} | ||
with open(fileName, "r") as f: | ||
timings = json.load(f) | ||
|
||
minPrec = ["MIN-SR-NS", "MIN-SR-S", "MIN-SR-FLEX"] | ||
|
||
symList = ['^', '>', '<', 'o', 's', '*', 'p'] | ||
config = [ | ||
(*minPrec, "VDHS", "ESDIRK43", "LU"), | ||
] | ||
nStepsList = np.array([5, 10, 20, 50, 100, 200, 500]) | ||
tEnd = 50 | ||
dtVals = tEnd / nStepsList | ||
|
||
# ----------------------------------------------------------------------------- | ||
# %% Error VS cost plots | ||
# ----------------------------------------------------------------------------- | ||
for qDeltaList in config: | ||
figNameConv = f"{SCRIPT}_conv_1" | ||
figNameCost = f"{SCRIPT}_cost_1" | ||
|
||
for qDelta, sym in zip(qDeltaList, symList): | ||
if qDelta == "MIN-SR-NS": | ||
res = timings["MIN-SR-S_MPI"].copy() | ||
res["errors"] = [np.nan for _ in res["errors"]] | ||
elif qDelta in ["MIN-SR-S", "MIN-SR-FLEX", "VDHS"]: | ||
res = timings[f"{qDelta}_MPI"] | ||
else: | ||
res = timings[qDelta] | ||
|
||
errors = res["errors"] | ||
costs = res["costs"] | ||
|
||
ls = '-' if qDelta.startswith("MIN-SR-") else "--" | ||
|
||
plt.figure(figNameConv) | ||
plt.loglog(dtVals, errors, sym + ls, label=qDelta) | ||
|
||
plt.figure(figNameCost) | ||
plt.loglog(costs, errors, sym + ls, label=qDelta) | ||
|
||
for figName in [figNameConv, figNameCost]: | ||
plt.figure(figName) | ||
plt.gca().set( | ||
xlabel="Computation Time" if "cost" in figName else r"$\Delta {t}$", | ||
ylabel=r"$L_2$ error at $T$", | ||
) | ||
plt.legend() | ||
plt.grid(True) | ||
plt.tight_layout() | ||
plt.savefig(f"{PATH}/{figName}.pdf") | ||
|
||
# ----------------------------------------------------------------------------- | ||
# %% Speedup tables | ||
# ----------------------------------------------------------------------------- | ||
header = f"{'dt size':12} |" | ||
header += '|'.join(f" {dt:1.1e} " for dt in dtVals) | ||
print(header) | ||
print("-" * len(header)) | ||
meanEff = 0 | ||
for qDelta in ["MIN-SR-S", "MIN-SR-FLEX", "VDHS"]: | ||
seq = timings[f"{qDelta}"] | ||
par = timings[f"{qDelta}_MPI"] | ||
assert np.allclose( | ||
seq["errors"], par["errors"], atol=1e-6 | ||
), f"parallel and sequential errors are not close for {qDelta}" | ||
tComp = seq["costs"] | ||
tCompMPI = par["costs"] | ||
meanEff += np.mean([tS / tP for tP, tS in zip(tCompMPI, tComp)]) | ||
print(f"{qDelta:12} |" + '|'.join(f" {tS/tP:1.1f} ({tS/tP/4*100:1.0f}%) " for tP, tS in zip(tCompMPI, tComp))) | ||
meanEff /= 3 | ||
print("Mean parallel efficiency :", meanEff / 4) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
Eventually
? That sounds like it will come in the futureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it's just that most preconditioners keep the same coefficient for different
k
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! This is a false friend, I guess. https://www.oed.com/search/dictionary/?scope=Entries&q=eventually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this one was vicious ...