From bdc6d3d7fbe2e0be62e5ca2f16dcf6a5bc2ee1f4 Mon Sep 17 00:00:00 2001 From: Ian Halim Date: Wed, 24 Jul 2024 17:51:23 -0600 Subject: [PATCH] MueLu: std::complex Replaced With Kokkos::complex Signed-off-by: Ian Halim --- .../MueLu_CoalesceDropFactory_def.hpp | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_def.hpp b/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_def.hpp index da606ab20ff6..0090f3ccfc7d 100644 --- a/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_def.hpp +++ b/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_def.hpp @@ -582,10 +582,13 @@ void CoalesceDropFactory::Build(Level using ExecSpace = typename Node::execution_space; using TeamPol = Kokkos::TeamPolicy; using TeamMem = typename TeamPol::member_type; - + using ATS = Kokkos::ArithTraits; + using impl_scalar_type = typename ATS::val_type; + using implATS = Kokkos::ArithTraits; + //move from host to device - ArrayView ghostedDiagValsArrayView = ghostedDiagVals.view(ghostedDiagVals.lowerOffset(), ghostedDiagVals.size()); - Kokkos::View ghostedDiagValsView = Kokkos::Compat::getKokkosViewDeepCopy(ghostedDiagValsArrayView); + ArrayView ghostedDiagValsArrayView = ghostedDiagVals.view(ghostedDiagVals.lowerOffset(), ghostedDiagVals.size()); + Kokkos::View ghostedDiagValsView = Kokkos::Compat::getKokkosViewDeepCopy(ghostedDiagValsArrayView); auto boundaryNodesDevice = Kokkos::create_mirror_view(ExecSpace(), boundaryNodes); auto At = Utilities::Op2TpetraCrs(A); @@ -632,8 +635,8 @@ void CoalesceDropFactory::Build(Level return drop_view(x) < drop_view(y); } else { - typename STS::magnitudeType x_aij = static_cast(std::fabs(static_cast(rowView.value(x) * rowView.value(x)))); - typename STS::magnitudeType y_aij = static_cast(std::fabs(static_cast(rowView.value(y) * rowView.value(y)))); + typename implATS::magnitudeType x_aij = static_cast(implATS::magnitude(static_cast(rowView.value(x) * rowView.value(x)))); + typename implATS::magnitudeType y_aij = static_cast(implATS::magnitude(static_cast(rowView.value(y) * rowView.value(y)))); return x_aij > y_aij; } }); @@ -642,13 +645,13 @@ void CoalesceDropFactory::Build(Level Kokkos::parallel_reduce(Kokkos::TeamThreadRange(teamMember, 1, n), [=](size_t i, size_t& min) { auto const& x = index_view(i - 1); auto const& y = index_view(i); - typename STS::magnitudeType x_aij = 0; - typename STS::magnitudeType y_aij = 0; + typename implATS::magnitudeType x_aij = 0; + typename implATS::magnitudeType y_aij = 0; if(!drop_view(x)) { - x_aij = static_cast(std::fabs(static_cast(rowView.value(x) * rowView.value(x)))); + x_aij = static_cast(implATS::magnitude(static_cast(rowView.value(x) * rowView.value(x)))); } if(!drop_view(y)) { - y_aij = static_cast(std::fabs(static_cast(rowView.value(y) * rowView.value(y)))); + y_aij = static_cast(implATS::magnitude(static_cast(rowView.value(y) * rowView.value(y)))); } if(x_aij > realThreshold * y_aij) { @@ -664,10 +667,10 @@ void CoalesceDropFactory::Build(Level return drop_view(x) < drop_view(y); } else { - typename STS::magnitudeType x_aij = static_cast(std::fabs(static_cast(rowView.value(x) * rowView.value(x)))); - typename STS::magnitudeType y_aij = static_cast(std::fabs(static_cast(rowView.value(y) * rowView.value(y)))); - typename STS::magnitudeType x_aiiajj = static_cast(std::fabs(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(x)) * ghostedDiagValsView(row)))); - typename STS::magnitudeType y_aiiajj = static_cast(std::fabs(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(y)) * ghostedDiagValsView(row)))); + typename implATS::magnitudeType x_aij = static_cast(implATS::magnitude(static_cast(rowView.value(x) * rowView.value(x)))); + typename implATS::magnitudeType y_aij = static_cast(implATS::magnitude(static_cast(rowView.value(y) * rowView.value(y)))); + typename implATS::magnitudeType x_aiiajj = static_cast(implATS::magnitude(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(x)) * ghostedDiagValsView(row)))); + typename implATS::magnitudeType y_aiiajj = static_cast(implATS::magnitude(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(y)) * ghostedDiagValsView(row)))); return x_aij / x_aiiajj > y_aij / y_aiiajj; } }); @@ -676,16 +679,16 @@ void CoalesceDropFactory::Build(Level Kokkos::parallel_reduce(Kokkos::TeamThreadRange(teamMember, 1, n), [=](size_t i, size_t& min) { auto const& x = index_view(i - 1); auto const& y = index_view(i); - typename STS::magnitudeType x_val = 0; - typename STS::magnitudeType y_val = 0; + typename implATS::magnitudeType x_val = 0; + typename implATS::magnitudeType y_val = 0; if(!drop_view(x)) { - typename STS::magnitudeType x_aij = static_cast(std::fabs(static_cast(rowView.value(x) * rowView.value(x)))); - typename STS::magnitudeType x_aiiajj = static_cast(std::fabs(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(x)) * ghostedDiagValsView(row)))); + typename implATS::magnitudeType x_aij = static_cast(implATS::magnitude(static_cast(rowView.value(x) * rowView.value(x)))); + typename implATS::magnitudeType x_aiiajj = static_cast(implATS::magnitude(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(x)) * ghostedDiagValsView(row)))); x_val = x_aij / x_aiiajj; } if(!drop_view(y)) { - typename STS::magnitudeType y_aij = static_cast(std::fabs(static_cast(rowView.value(y) * rowView.value(y)))); - typename STS::magnitudeType y_aiiajj = static_cast(std::fabs(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(y)) * ghostedDiagValsView(row)))); + typename implATS::magnitudeType y_aij = static_cast(implATS::magnitude(static_cast(rowView.value(y) * rowView.value(y)))); + typename implATS::magnitudeType y_aiiajj = static_cast(implATS::magnitude(static_cast(threshold * threshold * ghostedDiagValsView(rowView.colidx(y)) * ghostedDiagValsView(row)))); y_val = y_aij / y_aiiajj; }