Skip to content

Commit

Permalink
Update main branch (#136)
Browse files Browse the repository at this point in the history
* Update CI versions and behavior

* Refactor timings, due to:
FEniCS/dolfinx#3487
FEniCS/dolfinx#3488

* API changes from:  FEniCS/dolfinx#3500

* Fix demo

* Install boost

* Set tag

* Only check docker on release branch

* Fixes for refernece value size

* More timing fixes

* Another round of timing changes

* Remove last old timing instance
  • Loading branch information
jorgensd authored Nov 17, 2024
1 parent 6a6ab73 commit 3a6936f
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 68 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
workflow_call:
pull_request:
branches:
- main
- release

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
container: ghcr.io/fenics/dolfinx/dev-env:current-mpich
env:
# Directory that will be published on github pages
Expand All @@ -18,9 +18,16 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: release

- name: Install libbost for backwards compatibility
run: |
apt-get update
apt-get install -y libboost-dev libboost-timer-dev
- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.3
uses: jorgensd/actions/install-dolfinx@v0.4
with:
dolfinx: v0.9.0
ufl: 2024.2.0
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
pull_request:
branches:
- release
- main

workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.3
uses: jorgensd/actions/install-dolfinx@v0.4
with:
petsc_arch: ${PETSC_ARCH}
dolfinx: main
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test_mpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: ghcr.io/fenics/dolfinx/dolfinx:stable
container: ghcr.io/fenics/dolfinx/dolfinx:nightly

strategy:
matrix:
Expand All @@ -37,10 +37,10 @@ jobs:
# - CC: clang
# CXX: c++
env:
DOLFINX_BRANCH: v0.9.0
BASIX_BRANCH: v0.9.0
UFL_BRANCH: 2024.2.0
FFCX_BRANCH: v0.9.0
DOLFINX_BRANCH: main
BASIX_BRANCH: main
UFL_BRANCH: main
FFCX_BRANCH: main

CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
python3 -m pip install --no-build-isolation --no-cache-dir --no-binary=h5py h5py
- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.3
uses: jorgensd/actions/install-dolfinx@v0.4
with:
dolfinx: ${{ env.DOLFINX_BRANCH }}
ufl: ${{ env.UFL_BRANCH }}
Expand Down
2 changes: 1 addition & 1 deletion cpp/PeriodicConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dolfinx_mpc::mpc_data<T> _create_periodic_condition(
parents_glob[i] = parents_glob[i] * bs + parent_rems[i];
return parents_glob;
};
if (const std::size_t value_size = V.value_size() / V.element()->block_size();
if (const std::size_t value_size = V.element()->reference_value_size();
value_size > 1)
throw std::runtime_error(
"Periodic conditions for vector valued spaces are not "
Expand Down
5 changes: 1 addition & 4 deletions cpp/mpc_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ create_extended_functionspace(const dolfinx::fem::FunctionSpace<U>& V,
old_dofmap.element_dof_layout(), new_index_map, old_dofmap.bs(),
std::move(flattened_dofmap), old_dofmap.bs());

return dolfinx::fem::FunctionSpace(
V.mesh(), element, new_dofmap,
dolfinx::fem::compute_value_shape(element, V.mesh()->topology()->dim(),
V.mesh()->geometry().dim()));
return dolfinx::fem::FunctionSpace(V.mesh(), element, new_dofmap);
}

} // namespace dolfinx_mpc
5 changes: 2 additions & 3 deletions cpp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,7 @@ evaluate_basis_functions(const dolfinx::fem::FunctionSpace<U>& V,
auto element = V.element();
assert(element);
const int bs_element = element->block_size();
const std::size_t reference_value_size
= element->reference_value_size() / bs_element;
const std::size_t reference_value_size = element->reference_value_size();

// If the space has sub elements, concatenate the evaluations on the
// sub elements
Expand All @@ -1026,7 +1025,7 @@ evaluate_basis_functions(const dolfinx::fem::FunctionSpace<U>& V,

assert(basis_shape[2]
== std::size_t(element->space_dimension() / bs_element));
assert(basis_shape[3] == std::size_t(V.value_size() / bs_element));
assert(basis_shape[3] == std::size_t(element->reference_value_size()));
std::array<std::size_t, 3> reference_shape
= {basis_shape[1], basis_shape[2], basis_shape[3]};
std::vector<U> output_basis(std::reduce(
Expand Down
8 changes: 4 additions & 4 deletions python/benchmarks/bench_contact_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np
from basix.ufl import element
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings, timing
from dolfinx.common import Timer, list_timings, timing
from dolfinx.cpp.mesh import entities_to_geometry
from dolfinx.fem import (
Constant,
Expand Down Expand Up @@ -297,7 +297,7 @@ def sigma(v):
apply_lifting(b, [bilinear_form], [bcs], mpc)
b.ghostUpdate(addv=PETSc.InsertMode.ADD_VALUES, mode=PETSc.ScatterMode.REVERSE) # type: ignore
set_bc(b, bcs)
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)

# Solve Linear problem
opts = PETSc.Options() # type: ignore
Expand Down Expand Up @@ -365,13 +365,13 @@ def sigma(v):
for op in operations:
op_timing = timing(f"{num_dofs}: {op}")
num_calls = op_timing[0]
wall_time = op_timing[1]
wall_time = op_timing[1].total_seconds()
avg_time = comm.allreduce(wall_time, op=MPI.SUM) / comm.size
min_time = comm.allreduce(wall_time, op=MPI.MIN)
max_time = comm.allreduce(wall_time, op=MPI.MAX)
if comm.rank == 0:
print(op, num_calls, avg_time, min_time, max_time, file=results_file)
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
b.destroy()
solver.destroy()

Expand Down
8 changes: 4 additions & 4 deletions python/benchmarks/bench_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import h5py
import numpy as np
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import (
Constant,
Function,
Expand Down Expand Up @@ -157,7 +157,7 @@ def l2b(li):
solver.solve(b, uh)
uh.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD) # type: ignore
mpc.backsubstitution(uh)
solver_time = timer.elapsed()
solver_time = timer.elapsed().total_seconds()

it = solver.getIterationNumber()
if kspview:
Expand All @@ -176,7 +176,7 @@ def l2b(li):
d_set = out_hdf5.get("num_dofs")
d_set[r_lvl] = num_dofs
d_set = out_hdf5.get("solve_time")
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time[0]
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time
if xdmf:
# Write solution to file
u_h = Function(mpc.function_space)
Expand Down Expand Up @@ -223,5 +223,5 @@ def l2b(li):
log_info(f"Run {i} in progress")
bench_elasticity_one(r_lvl=i, out_hdf5=h5f, xdmf=args.xdmf, boomeramg=args.boomeramg, kspview=args.kspview)
if args.timings and i == N - 1:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
h5f.close()
8 changes: 4 additions & 4 deletions python/benchmarks/bench_elasticity_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import h5py
import numpy as np
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import (
Constant,
Function,
Expand Down Expand Up @@ -190,7 +190,7 @@ def sigma(v):
solver.solve(b, uh.x.petsc_vec)
uh.x.scatter_forward()
mpc.backsubstitution(uh)
solver_time = timer.elapsed()
solver_time = timer.elapsed().total_seconds()
if kspview:
solver.view()

Expand All @@ -206,7 +206,7 @@ def sigma(v):
d_set = out_hdf5.get("num_slaves")
d_set[r_lvl, MPI.COMM_WORLD.rank] = mpc.num_local_slaves
d_set = out_hdf5.get("solve_time")
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time[0]
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time
if info:
log_info(f"Lvl: {r_lvl}, Its: {it}, max Mem: {mem}, dim(V): {num_dofs}")

Expand Down Expand Up @@ -278,5 +278,5 @@ def sigma(v):
)

if args.timings and i == N - 1:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
h5f.close()
8 changes: 4 additions & 4 deletions python/benchmarks/bench_periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import h5py
import numpy as np
from dolfinx import default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import Function, dirichletbc, form, functionspace, locate_dofs_geometrical
from dolfinx.fem.petsc import set_bc
from dolfinx.io import XDMFFile
Expand Down Expand Up @@ -148,7 +148,7 @@ def periodic_relation(x):
uh.x.scatter_forward()
mpc.backsubstitution(uh)

solver_time = timer.elapsed()
solver_time = timer.elapsed().total_seconds()
if kspview:
solver.view()

Expand All @@ -163,7 +163,7 @@ def periodic_relation(x):
d_set = out_hdf5.get("num_slaves")
d_set[r_lvl, MPI.COMM_WORLD.rank] = mpc.num_local_slaves
d_set = out_hdf5.get("solve_time")
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time[0]
d_set[r_lvl, MPI.COMM_WORLD.rank] = solver_time

if MPI.COMM_WORLD.rank == 0:
print(f"Rlvl {r_lvl}, Iterations {it}")
Expand Down Expand Up @@ -241,5 +241,5 @@ def periodic_relation(x):

# List_timings
if args.timings and i == N - 1:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
h5f.close()
4 changes: 2 additions & 2 deletions python/benchmarks/ref_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import h5py
import numpy as np
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import (
Constant,
Function,
Expand Down Expand Up @@ -257,5 +257,5 @@ def sigma(v):
degree=args.degree,
)
if args.timings and i == N - 1:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
h5f.close()
4 changes: 2 additions & 2 deletions python/benchmarks/ref_periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import h5py
import numpy as np
from dolfinx import default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import Function, dirichletbc, form, functionspace, locate_dofs_geometrical
from dolfinx.fem.petsc import apply_lifting, assemble_matrix, assemble_vector, set_bc
from dolfinx.io import XDMFFile
Expand Down Expand Up @@ -219,5 +219,5 @@ def dirichletboundary(x):
)

if args.timings and i == N - 1:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
h5f.close()
4 changes: 2 additions & 2 deletions python/demos/demo_contact_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np
import scipy.sparse.linalg
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.fem import Constant, dirichletbc, form, functionspace, locate_dofs_geometrical
from dolfinx.fem.petsc import apply_lifting, assemble_matrix, assemble_vector, set_bc
from dolfinx.io import XDMFFile
Expand Down Expand Up @@ -263,4 +263,4 @@ def left_corner(x):

outfile.close()
if args.timing:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
6 changes: 3 additions & 3 deletions python/demos/demo_contact_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np
import scipy.sparse.linalg
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.io import XDMFFile
from dolfinx.mesh import CellType
from ufl import Identity, TestFunction, TrialFunction, dx, grad, inner, sym, tr
Expand Down Expand Up @@ -232,7 +232,7 @@ def sigma(v):
uh_numpy = K @ d
assert np.allclose(uh_numpy, u_mpc)

list_timings(mesh.comm, [TimingType.wall])
list_timings(mesh.comm)
b.destroy()
L_org.destroy()
solver.destroy()
Expand Down Expand Up @@ -298,4 +298,4 @@ def sigma(v):

log_info("Simulation finished")
if args.timing:
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
4 changes: 2 additions & 2 deletions python/demos/demo_periodic3d_topological.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import numpy as np
import scipy.sparse.linalg
from dolfinx import default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.io import VTXWriter
from dolfinx.mesh import CellType, create_unit_cube, locate_entities_boundary, meshtags
from numpy.typing import NDArray
Expand Down Expand Up @@ -185,4 +185,4 @@ def periodic_relation(x):
if __name__ == "__main__":
for celltype in [CellType.hexahedron, CellType.tetrahedron]:
demo_periodic3D(celltype)
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
4 changes: 2 additions & 2 deletions python/demos/demo_periodic_geometrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import scipy.sparse.linalg
from dolfinx import default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.io import XDMFFile
from dolfinx.mesh import create_unit_square, locate_entities_boundary
from ufl import (
Expand Down Expand Up @@ -185,5 +185,5 @@ def periodic_relation(x):
# Back substitution to full solution vector
uh_numpy = K.astype(scipy_dtype) @ d.astype(scipy_dtype)
assert np.allclose(uh_numpy.astype(u_mpc.dtype), u_mpc, atol=float(tol))
list_timings(MPI.COMM_WORLD, [TimingType.wall])
list_timings(MPI.COMM_WORLD)
L_org.destroy()
2 changes: 1 addition & 1 deletion python/demos/demo_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,4 @@ def T(u: Expr, p: Expr, mu: Expr):
# ## Timings
# Finally, we list the execution time of various operations used in the demo

common.list_timings(MPI.COMM_WORLD, [common.TimingType.wall])
common.list_timings(MPI.COMM_WORLD)
2 changes: 1 addition & 1 deletion python/demos/demo_stokes_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,4 @@ def T(u: Expr, p: Expr, mu: Expr):
Uh.destroy()
ksp.destroy()
# -------------------- List timings --------------------------
dolfinx.common.list_timings(MPI.COMM_WORLD, [dolfinx.common.TimingType.wall])
dolfinx.common.list_timings(MPI.COMM_WORLD)
4 changes: 2 additions & 2 deletions python/tests/test_cube_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import scipy.sparse.linalg
import ufl
from dolfinx import default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.common import Timer, list_timings
from dolfinx.io import gmshio

import dolfinx_mpc
Expand Down Expand Up @@ -301,4 +301,4 @@ def sigma(v):
b.destroy()
solver.destroy()

list_timings(comm, [TimingType.wall])
list_timings(comm)
Loading

0 comments on commit 3a6936f

Please sign in to comment.