Skip to content

Remove dynamic memory allocations inside lowest level assembly functions #3746

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

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
adf5491
Start removing dynamic memory allocation from lowest-level assembly f…
garth-wells May 30, 2025
4775760
Update demo
garth-wells May 31, 2025
c60fc40
More buffer use
garth-wells May 31, 2025
a540065
Doc fix
garth-wells May 31, 2025
a471e26
Small fix
garth-wells Jun 1, 2025
93bae6c
Update year
garth-wells Jun 1, 2025
a35bf4a
Work on vector assembly
garth-wells Jun 3, 2025
38d4ff4
Demo update
garth-wells Jun 3, 2025
b5194b2
Clean up
garth-wells Jun 4, 2025
af575d2
Merge branch 'garth/assembly-static' of github.com:FEniCS/dolfinx int…
garth-wells Jun 4, 2025
b5175f5
Work on docs
garth-wells Jun 4, 2025
1b62721
Doc fix
garth-wells Jun 4, 2025
d44de70
Doc fix
garth-wells Jun 4, 2025
8bbc142
Build fix
garth-wells Jun 4, 2025
8453942
Add checks
garth-wells Jun 4, 2025
f38cb08
Merge remote-tracking branch 'origin/main' into garth/assembly-static
garth-wells Jun 11, 2025
6fa65a7
Simplify
garth-wells Jun 11, 2025
8312f85
Update cpp/dolfinx/fem/assemble_matrix_impl.h
garth-wells Jun 11, 2025
89734b0
Integer size fix
garth-wells Jun 11, 2025
da4d74c
Merge branch 'garth/assembly-static' of github.com:FEniCS/dolfinx int…
garth-wells Jun 11, 2025
9d4a6b3
Ineger size fix
garth-wells Jun 11, 2025
8840f4c
Update cpp/dolfinx/fem/assemble_matrix_impl.h
garth-wells Jun 12, 2025
5fd321c
Merge branch 'main' into garth/assembly-static
garth-wells Jun 12, 2025
aebd3b2
Type fixes
garth-wells Jun 12, 2025
a91ca23
Merge branch 'garth/assembly-static' of github.com:FEniCS/dolfinx int…
garth-wells Jun 12, 2025
d30ff17
Fix
garth-wells Jun 12, 2025
42e13b9
Fix
garth-wells Jun 12, 2025
c6ecabc
Disable test
garth-wells Jun 12, 2025
581087d
Merge branch 'main' into garth/assembly-static
garth-wells Jun 15, 2025
76900d2
Merge branch 'main' into garth/assembly-static
garth-wells Jun 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions cpp/demo/custom_kernel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ double assemble_matrix1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
common::Timer timer("Assembler1 lambda (matrix)");
md::mdspan<const T, md::extents<std::size_t, md::dynamic_extent, 3>> x(
g.x().data(), g.x().size() / 3, 3);
fem::impl::assemble_cells<T>(
A.mat_add_values(), g.dofmap(), x, cells, {dofmap.map(), 1, cells}, ident,
{dofmap.map(), 1, cells}, ident, {}, {}, kernel, {}, {}, {}, {});

std::vector<T> Ae_b(dofmap.map().extent(1) * dofmap.map().extent(1));
std::vector<scalar_value_t<T>> cdofs_b(3 * g.dofmap().extent(1));
fem::impl::assemble_cells<T>(A.mat_add_values(), g.dofmap(), x, cells,
{dofmap.map(), 1, cells}, ident,
{dofmap.map(), 1, cells}, ident, {}, {}, kernel,
{}, {}, {}, {}, Ae_b, cdofs_b);
A.scatter_rev();
return A.squared_norm();
}
Expand All @@ -166,10 +170,13 @@ double assemble_vector1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
la::Vector<T> b(dofmap.index_map, 1);
md::mdspan<const T, md::extents<std::size_t, md::dynamic_extent, 3>> x(
g.x().data(), g.x().size() / 3, 3);

std::vector<T> be_b(dofmap.map().extent(1));
std::vector<scalar_value_t<T>> cdofs_b(3 * g.dofmap().extent(1));
common::Timer timer("Assembler1 lambda (vector)");
fem::impl::assemble_cells<T, 1>([](auto, auto, auto, auto) {},
b.mutable_array(), g.dofmap(), x, cells,
{dofmap.map(), 1, cells}, kernel, {}, {}, {});
fem::impl::assemble_cells<T, 1>(
[](auto, auto, auto, auto) {}, b.mutable_array(), g.dofmap(), x, cells,
{dofmap.map(), 1, cells}, kernel, {}, {}, {}, be_b, cdofs_b);
b.scatter_rev(std::plus<T>());
return la::squared_norm(b);
}
Expand Down
Loading
Loading