Skip to content

Commit

Permalink
Update timings in demos (#39)
Browse files Browse the repository at this point in the history
* Update timings in demos

* Fix strategy
  • Loading branch information
jorgensd authored Nov 3, 2024
1 parent b97e470 commit 0aabaf1
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 361 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

build:
needs: get_image
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
container: ghcr.io/fenics/dolfinx/dolfinx:${{ needs.get_image.outputs.image }}

steps:
Expand Down
15 changes: 9 additions & 6 deletions demo/assembly_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def assembly(mesh, P: int, repeats: int, jit_options: Optional[dict] = None):

t_matvec = np.zeros((repeats, mesh.comm.size), dtype=np.float64)
t_action = np.zeros((repeats, mesh.comm.size), dtype=np.float64)
N = mesh.topology.index_map(mesh.topology.dim).size_global
for i in range(repeats):
# Zero out time-dependent matrix
A.zeroEntries()
Expand All @@ -126,7 +127,7 @@ def assembly(mesh, P: int, repeats: int, jit_options: Optional[dict] = None):
A.assemble()

# Do mat-vec operations
with dolfinx.common.Timer(f"~{P} {i} Matvec strategy") as _:
with dolfinx.common.Timer(f"~{P} {i} {N} Matvec strategy") as _:
A.scale(-0.5)
A.axpy(1.0 / dt, M)
A.axpy(-0.5 * nu, K)
Expand All @@ -135,18 +136,20 @@ def assembly(mesh, P: int, repeats: int, jit_options: Optional[dict] = None):

# Compute the vector without using pre-generated matrices
b_d = dolfinx.fem.Function(V)
with dolfinx.common.Timer(f"~{P} {i} Action strategy") as _:
with dolfinx.common.Timer(f"~{P} {i} {N} Action strategy"):
dolfinx.fem.petsc.assemble_vector(b_d.x.petsc_vec, lhs)
b_d.x.scatter_reverse(dolfinx.la.InsertMode.add)
b_d.x.scatter_forward()
# Compare results
assert np.allclose(b.x.array, b_d.x.array)

# Get timings
matvec = dolfinx.common.timing(f"~{P} {i} Matvec strategy")
action = dolfinx.common.timing(f"~{P} {i} Action strategy")
t_matvec[i, :] = mesh.comm.allgather(matvec[1])
t_action[i, :] = mesh.comm.allgather(action[1])
matvec = dolfinx.common.timing(f"~{P} {i} {N} Matvec strategy")
assert matvec[0] == 1
action = dolfinx.common.timing(f"~{P} {i} {N} Action strategy")
assert action[0] == 1
t_matvec[i, :] = mesh.comm.allgather(matvec[1].total_seconds())
t_action[i, :] = mesh.comm.allgather(action[1].total_seconds())

return V.dofmap.index_map_bs * V.dofmap.index_map.size_global, t_matvec, t_action

Expand Down
707 changes: 355 additions & 352 deletions docs/assembly_strategies.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ requires = ["setuptools>=64.4.0", "wheel"]
[project]
name = "OasisX"
authors = [{ name = "Jørgen S. Dokken", email = "[email protected]" }]
version = "1.2.0"
version = "1.2.0.dev0"
description = "A modern implementation of Oasis"
readme = "README.md"
requires-python = ">=3.9"
license = { file = "LICENSE" }
dependencies = ['numpy', 'fenics-dolfinx>=0.8.0']
dependencies = ['numpy', 'fenics-dolfinx>0.9.0']

[project.scripts]
oasisx = "oasisx.__main__:main"
Expand Down

0 comments on commit 0aabaf1

Please sign in to comment.