Skip to content

Commit 251b5ed

Browse files
Many small things... (#523)
1 parent 4a098ad commit 251b5ed

File tree

10 files changed

+44
-13
lines changed

10 files changed

+44
-13
lines changed

pySDC/helpers/plot_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def figsize_by_journal(journal, scale, ratio): # pragma: no cover
4242
textwidths = {
4343
'JSC_beamer': 426.79135,
4444
'Springer_Numerical_Algorithms': 338.58778,
45+
'Springer_proceedings': 347.12354,
4546
'JSC_thesis': 434.26027,
4647
'TUHH_thesis': 426.79135,
4748
}
@@ -50,6 +51,7 @@ def figsize_by_journal(journal, scale, ratio): # pragma: no cover
5051
'JSC_beamer': 214.43411,
5152
'JSC_thesis': 635.5,
5253
'TUHH_thesis': 631.65118,
54+
'Springer_proceedings': 549.13828,
5355
}
5456
assert (
5557
journal in textwidths.keys()

pySDC/implementations/convergence_controller_classes/step_size_limiter.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,7 @@ def _round_step_size(dt, fac, digits):
192192

193193
def get_new_step_size(self, controller, S, **kwargs):
194194
"""
195-
Enforce an upper and lower limit to the step size here.
196-
Be aware that this is only tested when a new step size has been determined. That means if you set an initial
197-
value for the step size outside of the limits, and you don't do any further step size control, that value will
198-
go through.
199-
Also, the final step is adjusted such that we reach Tend as best as possible, which might give step sizes below
200-
the lower limit set here.
195+
Round step size here
201196
202197
Args:
203198
controller (pySDC.Controller): The controller

pySDC/implementations/hooks/log_solution.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self):
122122
)
123123

124124
if not os.path.isdir(self.path):
125-
os.mkdir(self.path)
125+
os.makedirs(self.path, exist_ok=True)
126126

127127
def log_to_file(self, step, level_number, condition, process_solution=None):
128128
if level_number > 0:
@@ -188,3 +188,15 @@ def post_step(self, step, level_number):
188188
if L.time + L.dt >= self.t_next_log and not step.status.restart:
189189
super().post_step(step, level_number)
190190
self.t_next_log = max([L.time + L.dt, self.t_next_log]) + self.time_increment
191+
192+
def pre_run(self, step, level_number):
193+
L = step.levels[level_number]
194+
L.uend = L.u[0]
195+
196+
def process_solution(L):
197+
return {
198+
**type(self).process_solution(L),
199+
't': L.time,
200+
}
201+
202+
self.log_to_file(step, level_number, type(self).logging_condition(L), process_solution=process_solution)

pySDC/projects/GPU/etc/generate_jobscript.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ def generate_directories():
99
'''
1010
import os
1111

12-
for name in ['jobscripts', 'slurm-out']:
12+
for name in ['jobscripts', 'slurm-out', 'nsys_profiles']:
1313
path = f'{PROJECT_PATH}/etc/{name}'
1414
os.makedirs(path, exist_ok=True)
1515

1616

17-
def get_jobscript_text(sbatch_options, srun_options, command, cluster):
17+
def get_jobscript_text(
18+
sbatch_options, srun_options, command, cluster, name='Coffeebreak', nsys_profiling=False, OMP_NUM_THREADS=1
19+
):
1820
"""
1921
Generate the text for a jobscript
2022
@@ -23,25 +25,33 @@ def get_jobscript_text(sbatch_options, srun_options, command, cluster):
2325
srun_options (list): Options for the srun command
2426
command (str): python (!) command. Will be prefaced by `python <path>/`
2527
cluster (str): Name of the cluster you want to run on
28+
name (str): Jobname
29+
nsys_profiling (bool): Whether to generate an NSIGHT Systems profile
2630
2731
Returns:
2832
str: Content of jobscript
2933
"""
3034
msg = '#!/usr/bin/bash\n\n'
35+
msg += f'#SBATCH -J {name}\n'
36+
3137
for op in DEFAULT_SBATCH_OPTIONS + sbatch_options:
3238
msg += f'#SBATCH {op}\n'
3339

40+
msg += f'\nexport OMP_NUM_THREADS={OMP_NUM_THREADS}\n'
3441
msg += f'\nsource {PROJECT_PATH}/etc/venv_{cluster.lower()}/activate.sh\n'
3542

3643
srun_cmd = 'srun'
3744
for op in DEFAULT_SRUN_OPTIONS + srun_options:
3845
srun_cmd += f' {op}'
3946

47+
if nsys_profiling:
48+
srun_cmd += f' nsys profile --trace=mpi,ucx,cuda,nvtx --output={PROJECT_PATH}/etc/nsys_profiles/{name}.%q{{SLURM_PROCID}}_%q{{SLURM_NTASKS}} --force-overwrite true'
49+
4050
msg += f'\n{srun_cmd} python {PROJECT_PATH}/{command}'
4151
return msg
4252

4353

44-
def write_jobscript(sbatch_options, srun_options, command, cluster, submit=True):
54+
def write_jobscript(sbatch_options, srun_options, command, cluster, submit=True, **kwargs):
4555
"""
4656
Generate a jobscript.
4757
@@ -54,11 +64,12 @@ def write_jobscript(sbatch_options, srun_options, command, cluster, submit=True)
5464
"""
5565
generate_directories()
5666

57-
text = get_jobscript_text(sbatch_options, srun_options, command, cluster)
67+
text = get_jobscript_text(sbatch_options, srun_options, command, cluster, **kwargs)
5868

5969
path = f'{PROJECT_PATH}/etc/jobscripts/{command.replace(" ", "").replace("/", "_")}-{cluster}.sh'
6070
with open(path, 'w') as file:
6171
file.write(text)
72+
print(f'Written jobscript {path!r}')
6273

6374
if submit:
6475
import os

pySDC/projects/GPU/etc/venv_booster/modules.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ module load FFTW
1111
module load mpi4py
1212
module load FFmpeg/.6.0
1313
module load SciPy-Stack
14+
module load texlive

pySDC/projects/GPU/etc/venv_jusuf/modules.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ module load Python
1010
module load FFTW
1111
module load mpi4py
1212
module load FFmpeg/.6.0
13-
module load SciPy-Stack
13+
# module load SciPy-Stack
14+
module load texlive

pySDC/projects/GPU/etc/venv_jusuf/setup.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ FFTW_LIBRARY_DIR="/p/software/jusuf/stages/2024/software/FFTW/3.3.10-GCC-12.3.0/
1616
python3 -m pip install -e /p/project1/ccstma/baumann7/qmat
1717
python3 -m pip install -r "${ABSOLUTE_PATH}"/requirements.txt
1818
python3 -m pip install -e /p/project1/ccstma/baumann7/pySDC/
19-

pySDC/projects/Resilience/sweepers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def predict(self):
2626
if self.params.initial_guess == 'spread':
2727
L.u[m] = P.dtype_u(L.u[0])
2828
L.f[m] = P.eval_f(L.u[m], L.time + L.dt * self.coll.nodes[m - 1])
29+
elif self.params.initial_guess == 'copy':
30+
L.f[0] = P.eval_f(L.u[0], L.time)
31+
L.u[m] = P.dtype_u(L.u[0])
32+
L.f[m] = P.dtype_f(L.f[0])
2933
# start with zero everywhere
3034
elif self.params.initial_guess == 'zero':
3135
L.u[m] = P.dtype_u(init=P.init, val=0.0)

pySDC/projects/Resilience/venv/modules.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ module load FFTW
66
module load Python/3.11.3
77
module load mpi4py
88
module load FFmpeg/.6.0
9+
module load texlive

pySDC/tests/test_convergence_controllers/test_step_size_limiter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def test_step_size_slope_limiter():
8080
limiter.get_new_step_size(controller, S)
8181
assert L.status.dt_new == 1
8282

83+
L.params.dt = 1
84+
L.status.dt_new = 1 - 1e-1
85+
limiter.get_new_step_size(controller, S)
86+
assert L.status.dt_new == 1
87+
8388

8489
@pytest.mark.base
8590
def test_step_size_limiter():

0 commit comments

Comments
 (0)