Skip to content

Commit

Permalink
Phalanx: fix warnings for c++20 code deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Roger Pawlowski <[email protected]>
  • Loading branch information
rppawlo committed Dec 4, 2024
1 parent 784c3fe commit 40152b0
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 32 deletions.
8 changes: 4 additions & 4 deletions packages/phalanx/example/FiniteElementAssembly/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ KOKKOS_INLINE_FUNCTION
void Mesh::operator() (const ComputeJac_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [&] (const int& qp) {
for (int basis=0; basis < static_cast<int>(basis_.extent(1)); ++basis) {
for (int i=0; i < 3; ++i) {
for (int j=0; j < 3; ++j) {
Expand All @@ -220,7 +220,7 @@ KOKKOS_INLINE_FUNCTION
void Mesh::operator() (const ComputeInvJac_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [&] (const int& qp) {
inv_jac_(cell,qp,0,0) = jac_(cell,qp,1,1) * jac_(cell,qp,2,2) - jac_(cell,qp,1,2) * jac_(cell,qp,2,1);
inv_jac_(cell,qp,1,1) = jac_(cell,qp,2,2) * jac_(cell,qp,0,0) - jac_(cell,qp,2,0) * jac_(cell,qp,0,2);
inv_jac_(cell,qp,2,2) = jac_(cell,qp,0,0) * jac_(cell,qp,1,1) - jac_(cell,qp,0,1) * jac_(cell,qp,1,0);
Expand All @@ -246,7 +246,7 @@ KOKKOS_INLINE_FUNCTION
void Mesh::operator() (const ComputeCoords_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,qp_.extent(0)), [&] (const int& qp) {
for (int basis=0; basis < static_cast<int>(basis_.extent(1)); ++basis) {
qp_coords_(cell,qp,0) += basis_(qp,basis) * coords_(cell,basis,0);
qp_coords_(cell,qp,1) += basis_(qp,basis) * coords_(cell,basis,1);
Expand All @@ -260,7 +260,7 @@ KOKKOS_INLINE_FUNCTION
void Mesh::operator() (const ComputeGradBasisReal_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,grad_basis_real_.extent(1)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,grad_basis_real_.extent(1)), [&] (const int& qp) {
const int num_basis = static_cast<int>(grad_basis_real_.extent(2));
for (int basis=0; basis < num_basis; ++basis)
for (int dim1=0; dim1 < 3; ++dim1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct WorksetBuilder {
void operator() (const CopyWorksetDetJac_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,mesh_det_jac.extent(1)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,mesh_det_jac.extent(1)), [&] (const int& qp) {
workset_det_jac(cell,qp) = mesh_det_jac(cell+first_cell_global_index,qp);
//printf("det_jac=%f\n",workset.det_jac_(cell,qp));
});
Expand All @@ -41,7 +41,7 @@ struct WorksetBuilder {
void operator() (const CopyWorksetGradBasisReal_Tag& , const team_t& team) const
{
const int cell = team.league_rank();
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,mesh_det_jac.extent(1)), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,mesh_det_jac.extent(1)), [&] (const int& qp) {
for (int basis=0; basis < static_cast<int>(mesh_grad_basis_real.extent(2)); ++basis)
for (int dim=0; dim < static_cast<int>(mesh_grad_basis_real.extent(3)); ++dim)
workset_grad_basis_real(cell,qp,basis,dim) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [&] (const int& node) {
field(cell,node) = x( gids(cell_global_offset_index+cell,node) * num_equations + field_index);
});
}
Expand Down Expand Up @@ -94,8 +94,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
{
const int cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [&] (const int& node) {
field(cell,node).val() = x(gids(cell_global_offset_index+cell,node) * num_equations + field_index);
field(cell,node).fastAccessDx(num_equations * node + field_index) = 1.0;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int local_cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,residual_contribution.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,residual_contribution.extent(1)), [&] (const int& node) {
const int residual_index = gids(cell_global_offset_index+local_cell,node) * num_equations + equation_index;
global_residual_atomic(residual_index) += residual_contribution(local_cell,node);
});
Expand Down Expand Up @@ -106,24 +106,21 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int num_nodes = residual_contribution.extent(1);

if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_nodes), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_nodes), [&] (const int& node) {
const int global_row_index = gids(cell_global_offset_index+cell,node) * num_equations + equation_index;
global_residual_atomic(global_row_index) += residual_contribution(cell,node).val();
});
}

// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_nodes), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_nodes), [&] (const int& node) {

const int global_row_index = gids(cell_global_offset_index+cell,node) * num_equations + equation_index;

// loop over nodes
for (int col_node=0; col_node < num_nodes; ++col_node) {

// loop over equations
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_equations),[=] (const int& col_eq) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_equations),[&] (const int& col_eq) {
const int global_col_index = gids(cell_global_offset_index+cell,col_node) * num_equations + col_eq;
const int derivative_index = col_node * num_equations + col_eq;
global_jacobian.sumIntoValues(global_row_index,&global_col_index,1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [&] (const int& node) {
field(cell,node) = x( gids(cell_global_offset_index+cell,node) * num_equations + field_index);
});
}
Expand Down Expand Up @@ -95,7 +95,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,field.extent(1)), [&] (const int& node) {
field(cell,node).val() = x(gids(cell_global_offset_index+cell,node) * num_equations + field_index);
field(cell,node).fastAccessDx(num_equations * node + field_index) = 1.0;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
{
const int local_cell = team.league_rank();
if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,residual_contribution.extent(1)), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,residual_contribution.extent(1)), [&] (const int& node) {
const int residual_index = gids(cell_global_offset_index+local_cell,node) * num_equations + equation_index;
global_residual_atomic(residual_index) += residual_contribution(local_cell,node);
});
Expand Down Expand Up @@ -106,24 +105,21 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int num_nodes = residual_contribution.extent(1);

if (team.team_rank() == 0) {
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_nodes), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_nodes), [&] (const int& node) {
const int global_row_index = gids(cell_global_offset_index+cell,node) * num_equations + equation_index;
global_residual_atomic(global_row_index) += residual_contribution(cell,node).val();
});
}

// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_nodes), [=] (const int& node) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_nodes), [&] (const int& node) {

const int global_row_index = gids(cell_global_offset_index+cell,node) * num_equations + equation_index;

// loop over nodes
for (int col_node=0; col_node < num_nodes; ++col_node) {

// loop over equations
// Fix gcc 5/6 lambda bug by changing to capture by value (potentially less efficient)
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_equations),[=] (const int& col_eq) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_equations),[&] (const int& col_eq) {
const int global_col_index = gids(cell_global_offset_index+cell,col_node) * num_equations + col_eq;
const int derivative_index = col_node * num_equations + col_eq;
global_jacobian.sumIntoValues(global_row_index,&global_col_index,1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
{
const int i = team.league_rank();

Kokkos::single(Kokkos::PerTeam(team), [=] () {
Kokkos::single(Kokkos::PerTeam(team), [&] () {
x1(i) = f1(i) * f1(i);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int cell = team.league_rank();
const int num_qp = static_cast<int>(a.extent(1));

Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_qp), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_qp), [&] (const int& qp) {
const int num_dim = static_cast<int>(c.extent(2));
a(cell,qp) = 0.0;
for (int i = 0; i < num_dim; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ operator()(const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
const int cell = team.league_rank();
const int num_qp = static_cast<int>(a.extent(1));

Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_qp), [=] (const int& qp) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_qp), [&] (const int& qp) {
const int num_dim = static_cast<int>(c.extent(2));
a(cell,qp) = 0.0;
for (int i = 0; i < num_dim; ++i)
Expand Down
4 changes: 2 additions & 2 deletions packages/phalanx/test/Kokkos/tKokkosNestedLambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class MyFunctor {
{
const int cell = team.league_rank();
const int num_pts = a_.extent(1);
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_pts), [=] (const int& pt) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_pts), [&] (const int& pt) {
const int num_eq = a_.extent(2);
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_eq), [=] (const int& eq) {
Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,num_eq), [&] (const int& eq) {
c_(cell,pt,eq) = a_(cell,pt,eq) + b_(cell,pt,eq);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/phalanx/test/Kokkos/tKokkosPerf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace phalanx_test {
{
const int i = thread.league_rank();
const int num_qp = rho_.extent(1);
Kokkos::parallel_for(Kokkos::TeamThreadRange(thread,0,num_qp), [=] (const int& ip) {
Kokkos::parallel_for(Kokkos::TeamThreadRange(thread,0,num_qp), [&] (const int& ip) {
rho_(i,ip) = k_(0) * P_(i,ip) / T_(i,ip);
});
}
Expand Down

0 comments on commit 40152b0

Please sign in to comment.