-
Notifications
You must be signed in to change notification settings - Fork 248
compiler: Add Devito+PETSc MPI test #2635
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
Changes from all commits
27dd201
30ed5ba
6972cbc
8037cf9
8c16f2e
dcbf929
7a5b10f
467c19b
343ba75
d2e3eb5
6165373
0b43ea6
62d0045
bd96379
ce5cf82
b7c4082
e485c9c
df4e638
72e8222
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
|
|
||
|
|
||
| @skipif('petsc') | ||
| @pytest.fixture(scope='session', autouse=True) | ||
| def test_petsc_initialization(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a fixture or a test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A fixture, see comment above
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you merge this without updating the name? Tests start with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realise you were requesting a change, I will edit it on the |
||
| # TODO: Temporary workaround until PETSc is automatically | ||
| # initialized | ||
|
|
@@ -28,6 +29,14 @@ def test_petsc_initialization(): | |
| PetscInitialize() | ||
|
|
||
|
|
||
| @skipif('petsc') | ||
| @pytest.mark.parallel(mode=[1, 2, 4, 6]) | ||
| def test_petsc_initialization_parallel(mode): | ||
| configuration['compiler'] = 'custom' | ||
| os.environ['CC'] = 'mpicc' | ||
| PetscInitialize() | ||
|
|
||
|
|
||
| @skipif('petsc') | ||
| def test_petsc_local_object(): | ||
| """ | ||
|
|
@@ -1311,3 +1320,60 @@ def define(self, dimensions): | |
| + 'MATOP_MULT,(void (*)(void))J00_MatMult0)' in str(create) | ||
|
|
||
| # TODO: Test mixed, time dependent solvers | ||
|
|
||
|
|
||
| class TestMPI: | ||
ZoeLeibowitz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # TODO: Add test for DMDACreate() in parallel | ||
|
|
||
| @pytest.mark.parametrize('nx, unorm', [ | ||
| (17, 7.441506654790017), | ||
| (33, 10.317652759863675), | ||
| (65, 14.445123374862874), | ||
| (129, 20.32492895656658), | ||
| (257, 28.67050632840985) | ||
| ]) | ||
| @skipif('petsc') | ||
| @pytest.mark.parallel(mode=[2, 4, 8]) | ||
| def test_laplacian_1d(self, nx, unorm, mode): | ||
| """ | ||
| """ | ||
| configuration['compiler'] = 'custom' | ||
| os.environ['CC'] = 'mpicc' | ||
| PetscInitialize() | ||
|
|
||
| class SubSide(SubDomain): | ||
| def __init__(self, side='left', grid=None): | ||
| self.side = side | ||
| self.name = f'sub{side}' | ||
| super().__init__(grid=grid) | ||
|
|
||
| def define(self, dimensions): | ||
| x, = dimensions | ||
| return {x: (self.side, 1)} | ||
|
|
||
| grid = Grid(shape=(nx,), dtype=np.float64) | ||
| sub1, sub2 = [SubSide(side=s, grid=grid) for s in ('left', 'right')] | ||
|
|
||
| u = Function(name='u', grid=grid, space_order=2) | ||
| f = Function(name='f', grid=grid, space_order=2) | ||
|
|
||
| u0 = Constant(name='u0', value=-1.0, dtype=np.float64) | ||
| u1 = Constant(name='u1', value=-np.exp(1.0), dtype=np.float64) | ||
|
|
||
| eqn = Eq(-u.laplace, f, subdomain=grid.interior) | ||
|
|
||
| X = np.linspace(0, 1.0, nx).astype(np.float64) | ||
| f.data[:] = np.float64(np.exp(X)) | ||
|
|
||
| # Create boundary condition expressions using subdomains | ||
| bcs = [EssentialBC(u, u0, subdomain=sub1)] | ||
| bcs += [EssentialBC(u, u1, subdomain=sub2)] | ||
|
|
||
| petsc = PETScSolve([eqn] + bcs, target=u, solver_parameters={'ksp_rtol': 1e-10}) | ||
|
|
||
| op = Operator(petsc, language='petsc') | ||
| op.apply() | ||
|
|
||
| # Expected norm computed "manually" from sequential run | ||
| # What rtol and atol should be used? | ||
| assert np.isclose(norm(u), unorm, rtol=1e-13, atol=1e-13) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rtol and atol can probably be increased to ~1e-8 for CI reliability |
||
Uh oh!
There was an error while loading. Please reload this page.