Skip to content

Commit

Permalink
OpenMP parallelism for a small loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed Mar 4, 2024
1 parent 5cb5a79 commit 1ec7cb0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions palace/fem/bilinearform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,20 @@ std::unique_ptr<ceed::Operator> DiscreteLinearOperator::PartialAssemble() const
Vector test_multiplicity(test_fespace.GetVSize());
test_multiplicity = 0.0;
auto *h_mult = test_multiplicity.HostReadWrite();
mfem::Array<int> dofs;
for (int i = 0; i < test_fespace.GetMesh().GetNE(); i++)
PalacePragmaOmp(parallel)
{
test_fespace.Get().GetElementVDofs(i, dofs);
for (int j = 0; j < dofs.Size(); j++)
mfem::Array<int> dofs;
mfem::DofTransformation dof_trans;
PalacePragmaOmp(for schedule(static))
for (int i = 0; i < test_fespace.GetMesh().GetNE(); i++)
{
const int k = dofs[j];
h_mult[(k >= 0) ? k : -1 - k] += 1.0;
test_fespace.Get().GetElementVDofs(i, dofs, dof_trans);
for (int j = 0; j < dofs.Size(); j++)
{
const int k = dofs[j];
PalacePragmaOmp(atomic update)
h_mult[(k >= 0) ? k : -1 - k] += 1.0;
}
}
}
test_multiplicity.UseDevice(true);
Expand Down

0 comments on commit 1ec7cb0

Please sign in to comment.