Skip to content

Commit

Permalink
qip
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Dec 5, 2024
1 parent e2d6403 commit 93a1bc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 16 additions & 0 deletions Src/LinearSolvers/AMReX_AlgVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ T Dot (AlgVector<T> const& x, AlgVector<T> const& y, bool local = false)
return r;
}

template <typename T>
void Axpy (AlgVector<T>& y, T a, AlgVector<T> const& x, bool async = false)
{
ForEach(y, x, [=] AMREX_GPU_DEVICE (T& yi, T const& xi) { yi += a*xi; });
if (!async) { Gpu::streamSynchronize(); }
}

template <typename T>
void LinComb (AlgVector<T>& y, T a, AlgVector<T> const& xa, T b, AlgVector<T> const& xb, bool async = false)
{
ForEach(y, xa, xb, [=] AMREX_GPU_DEVICE (T& yi, T const& xai, T const& xbi) {
yi = a*xai + b*xbi;
});
if (!async) { Gpu::streamSynchronize(); }
}

}

#endif
7 changes: 3 additions & 4 deletions Src/LinearSolvers/AMReX_GMRES_MV.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ void GMRES_MV<T>::scale (VEC& vec, T scale_factor)
template <typename T>
T GMRES_MV<T>::dotProduct (VEC const& vec1, VEC const& vec2)
{
amrex::Abort("xxxxx: GMRES_MV::dotProduct: todo");
return 0;
return amrex::Dot(vec1,vec2);
}

template <typename T>
Expand All @@ -129,13 +128,13 @@ void GMRES_MV<T>::assign (VEC& lhs, VEC const& rhs)
template <typename T>
void GMRES_MV<T>::increment (VEC& lhs, VEC const& rhs, T a)
{
amrex::Abort("xxxxx: GMRES_MV::increment: todo");
amrex::Axpy(lhs, a, rhs, true);
}

template <typename T>
void GMRES_MV<T>::linComb (VEC& lhs, T a, VEC const& rhs_a, T b, VEC const& rhs_b)
{
amrex::Abort("xxxxx: GMRES_MV::increment: todo");
amrex::LinComb(lhs, a, rhs_a, b, rhs_b, true);
}

template <typename T>
Expand Down

0 comments on commit 93a1bc0

Please sign in to comment.