Skip to content

Commit 2b45793

Browse files
committed
Merge branch 'master' into neuralpint
2 parents aaf4cdd + 51aa701 commit 2b45793

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3969
-224
lines changed

.github/workflows/ci_pipeline.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,58 @@ jobs:
169169
path: |
170170
data_libpressio
171171
coverage_libpressio.dat
172+
173+
user_firedrake_tests:
174+
runs-on: ubuntu-latest
175+
container:
176+
image: firedrakeproject/firedrake-vanilla:latest
177+
options: --user root
178+
volumes:
179+
- ${{ github.workspace }}:/repositories
180+
defaults:
181+
run:
182+
shell: bash -l {0}
183+
steps:
184+
- name: Checkout pySDC
185+
uses: actions/checkout@v4
186+
with:
187+
path: ./pySDC
188+
- name: Checkout gusto
189+
uses: actions/checkout@v4
190+
with:
191+
repository: firedrakeproject/gusto
192+
path: ./gusto_repo
193+
- name: Install pySDC
194+
run: |
195+
. /home/firedrake/firedrake/bin/activate
196+
python -m pip install --no-deps -e /repositories/pySDC
197+
python -m pip install qmat
198+
- name: Install gusto
199+
run: |
200+
. /home/firedrake/firedrake/bin/activate
201+
python -m pip install -e /repositories/gusto_repo
202+
- name: run pytest
203+
run: |
204+
. /home/firedrake/firedrake/bin/activate
205+
firedrake-clean
206+
cd ./pySDC
207+
coverage run -m pytest --continue-on-collection-errors -v --durations=0 /repositories/pySDC/pySDC/tests -m firedrake
208+
timeout-minutes: 45
209+
- name: Make coverage report
210+
run: |
211+
. /home/firedrake/firedrake/bin/activate
212+
213+
cd ./pySDC
214+
mv data ../data_firedrake
215+
coverage combine
216+
mv .coverage ../coverage_firedrake.dat
217+
- name: Upload artifacts
218+
uses: actions/upload-artifact@v4
219+
with:
220+
name: test-artifacts-firedrake
221+
path: |
222+
data_firedrake
223+
coverage_firedrake.dat
172224
173225
user_monodomain_tests_linux:
174226
runs-on: ubuntu-latest

.github/workflows/gitlab_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
echo "Merge the two parts of the Merge-Request to test the resulting version"
107107
git merge "${{ github.event.pull_request.head.sha }}"
108108
- name: Mirror and wait for Gitlab-CI
109-
uses: jakob-fritz/[email protected]
109+
uses: jakob-fritz/[email protected].1
110110
env:
111111
MODE: 'all' # Either 'mirror', 'get_status', 'get_artifact', or 'all'
112112
GITLAB_TOKEN: ${{ secrets.GITLAB_SECRET }}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ implemented.
1919

2020
- Variants of SDC: explicit, implicit, IMEX, multi-implicit, Verlet,
2121
multi-level, diagonal, multi-step
22-
- Variants of PFASST: virtual parallel or MPI-based parallel,
23-
classical of multigrid perspective
22+
- Variants of PFASST: virtually parallel or MPI-based parallel,
23+
classical or multigrid perspective
2424
- 8 tutorials: from setting up a first collocation problem to SDC,
2525
PFASST and advanced topics
2626
- Projects: many documented projects with defined and tested outcomes
@@ -43,12 +43,11 @@ The code is hosted on GitHub, see
4343
will give you a core version of `pySDC` to work with,
4444
working with the developer version is most often the better choice. We
4545
thus recommend to checkout the code from GitHub and install the
46-
dependencies e.g. by using a [conda](https://conda.io/en/latest/)
47-
environment. For this, `pySDC` ships with environment files
48-
which can be found in the folder `etc/`. Use these as e.g.
46+
dependencies e.g. by using [micromamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html). For this, `pySDC` ships with environment files
47+
which can be found in the folder `etc/` or within the projects. Use these as e.g.
4948

5049
``` bash
51-
conda env create -f etc/environment-base.yml
50+
micromamba create -f etc/environment-base.yml
5251
```
5352

5453
If you want to install the developer version using `pip` directly from the GitHub repository, use this:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Full code: `pySDC/tutorial/step_7/E_pySDC_with_Firedrake.py <https://github.com/Parallel-in-Time/pySDC/blob/master/pySDC/tutorial/step_7/E_pySDC_with_Firedrake.py>`_
2+
3+
.. literalinclude:: ../../../pySDC/tutorial/step_7/E_pySDC_with_Firedrake.py
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Full code: `pySDC/tutorial/step_7/F_pySDC_with_Gusto.py <https://github.com/Parallel-in-Time/pySDC/blob/master/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py>`_
2+
Find a suitable plotting script here: `pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py <https://github.com/Parallel-in-Time/pySDC/blob/master/pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py>`_
3+
4+
.. literalinclude:: ../../../pySDC/tutorial/step_7/F_pySDC_with_Gusto.py

etc/environment-petsc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- matplotlib>=3.0
1010
- dill>=0.2.6
1111
- mpich
12-
- petsc4py
12+
- petsc4py<3.22
1313
- mpi4py>=3.0.0
1414
- pip
1515
- pip:

pySDC/core/space_transfer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ class SpaceTransfer(object):
2727
coarse_prob (pySDC.Problem.ptype): reference to the coarse problem
2828
"""
2929

30-
def __init__(self, fine_prob, coarse_prob, space_transfer_params):
30+
def __init__(self, fine_prob, coarse_prob, params):
3131
"""
3232
Initialization routine
3333
3434
Args:
3535
fine_prob (pySDC.Problem.ptype): reference to the fine problem
3636
coarse_prob (pySDC.Problem.ptype): reference to the coarse problem
37-
space_transfer_params (dict): user-defined parameters
37+
params (dict): user-defined parameters
3838
"""
3939

40-
self.params = _Pars(space_transfer_params)
40+
self.params = _Pars(params)
4141

4242
# set up logger
4343
self.logger = logging.getLogger('space-transfer')

pySDC/helpers/fieldsIO.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import os
5050
import numpy as np
5151
from typing import Type, TypeVar
52+
import logging
5253

5354
T = TypeVar("T")
5455

@@ -69,11 +70,26 @@ class MPI:
6970
DTYPES = {
7071
0: np.float64, # double precision
7172
1: np.complex128,
72-
2: np.float128, # quadruple precision
73-
3: np.complex256,
74-
4: np.float32, # single precision
75-
5: np.complex64,
7673
}
74+
try:
75+
DTYPES.update(
76+
{
77+
2: np.float128, # quadruple precision
78+
3: np.complex256,
79+
}
80+
)
81+
except AttributeError:
82+
logging.getLogger('FieldsIO').debug('Warning: Quadruple precision not available on this machine')
83+
try:
84+
DTYPES.update(
85+
{
86+
4: np.float32, # single precision
87+
5: np.complex64,
88+
}
89+
)
90+
except AttributeError:
91+
logging.getLogger('FieldsIO').debug('Warning: Single precision not available on this machine')
92+
7793
DTYPES_AVAIL = {val: key for key, val in DTYPES.items()}
7894

7995
# Header dtype
@@ -106,7 +122,7 @@ def __init__(self, dtype, fileName):
106122
self.dtype = key
107123
avail = True
108124
break
109-
assert avail, f"{dtype=} not available"
125+
assert avail, f"{dtype=} not available. Supported on this machine: {list(DTYPES_AVAIL.keys())}"
110126
self.fileName = fileName
111127
self.initialized = False
112128

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from mpi4py import MPI
2+
import firedrake as fd
3+
import numpy as np
4+
5+
6+
class FiredrakeEnsembleCommunicator:
7+
"""
8+
Ensemble communicator for performing multiple similar distributed simulations with Firedrake, see https://www.firedrakeproject.org/firedrake/parallelism.html
9+
This is intended to do space-time parallelism in pySDC.
10+
This class wraps the time communicator. All requests that are not overloaded are passed to the time communicator. For instance, `ensemble.rank` will return the rank in the time communicator.
11+
Some operations are overloaded to use the interface of the MPI communicator but handles communication with the ensemble communicator instead.
12+
"""
13+
14+
def __init__(self, comm, space_size):
15+
"""
16+
Args:
17+
comm (MPI.Intracomm): MPI communicator, which will be split into time and space communicators
18+
space_size (int): Size of the spatial communicators
19+
20+
Attributes:
21+
ensemble (firedrake.Ensemble): Ensemble communicator
22+
"""
23+
self.ensemble = fd.Ensemble(comm, space_size)
24+
self.comm_wold = comm
25+
26+
def Split(self, *args, **kwargs):
27+
return FiredrakeEnsembleCommunicator(self.comm_wold.Split(*args, **kwargs), space_size=self.space_comm.size)
28+
29+
@property
30+
def space_comm(self):
31+
return self.ensemble.comm
32+
33+
@property
34+
def time_comm(self):
35+
return self.ensemble.ensemble_comm
36+
37+
def __getattr__(self, name):
38+
return getattr(self.time_comm, name)
39+
40+
def Reduce(self, sendbuf, recvbuf, op=MPI.SUM, root=0):
41+
if type(sendbuf) in [np.ndarray]:
42+
self.ensemble.ensemble_comm.Reduce(sendbuf, recvbuf, op, root)
43+
else:
44+
assert op == MPI.SUM
45+
self.ensemble.reduce(sendbuf, recvbuf, root=root)
46+
47+
def Allreduce(self, sendbuf, recvbuf, op=MPI.SUM):
48+
if type(sendbuf) in [np.ndarray]:
49+
self.ensemble.ensemble_comm.Allreduce(sendbuf, recvbuf, op)
50+
else:
51+
assert op == MPI.SUM
52+
self.ensemble.allreduce(sendbuf, recvbuf)
53+
54+
def Bcast(self, buf, root=0):
55+
if type(buf) in [np.ndarray]:
56+
self.ensemble.ensemble_comm.Bcast(buf, root)
57+
else:
58+
self.ensemble.bcast(buf, root=root)
59+
60+
def Irecv(self, buf, source, tag=MPI.ANY_TAG):
61+
if type(buf) in [np.ndarray, list]:
62+
return self.ensemble.ensemble_comm.Irecv(buf=buf, source=source, tag=tag)
63+
return self.ensemble.irecv(buf, source, tag=tag)[0]
64+
65+
def Isend(self, buf, dest, tag=MPI.ANY_TAG):
66+
if type(buf) in [np.ndarray, list]:
67+
return self.ensemble.ensemble_comm.Isend(buf=buf, dest=dest, tag=tag)
68+
return self.ensemble.isend(buf, dest, tag=tag)[0]
69+
70+
def Free(self):
71+
del self
72+
73+
74+
def get_ensemble(comm, space_size):
75+
return fd.Ensemble(comm, space_size)

0 commit comments

Comments
 (0)