Skip to content

Commit

Permalink
Merge Pull Request trilinos#10323 from trilinos/Trilinos/master_merge…
Browse files Browse the repository at this point in the history
…_20220314_000724

Automatically Merged using Trilinos Master Merge AutoTester
PR Title: Trilinos Master Merge PR Generator: Auto PR created to promote from master_merge_20220314_000724 branch to master
PR Author: trilinos-autotester
  • Loading branch information
trilinos-autotester authored Mar 14, 2022
2 parents 8937230 + 35294d2 commit a3b63fd
Show file tree
Hide file tree
Showing 23 changed files with 246 additions and 159 deletions.
2 changes: 1 addition & 1 deletion cmake/ctest/drivers/lightsaber/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TRILINOS_DRIVER_ADD_DASHBOARD(

TRILINOS_DRIVER_ADD_DASHBOARD(
SERIAL_RELEASE_FLOAT
ctest_linux_experimental_mpi_release_glosy_lightsaber.cmake
ctest_linux_experimental_mpi_release_float_lightsaber.cmake
CTEST_INSTALLER_TYPE release
RUN_SERIAL
TIMEOUT_MINUTES 330
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ compute ()
"been called by this point, but isInitialized_ is false. "
"Please report this bug to the Ifpack2 developers.");

if (! isComputed_) {//Only compute if not computed before
if (Teuchos::nonnull (htsImpl_))
htsImpl_->compute (*A_crs_, out_);

Expand Down Expand Up @@ -590,6 +591,7 @@ compute ()

isComputed_ = true;
++numCompute_;
}
}

template<class MatrixType>
Expand Down
10 changes: 6 additions & 4 deletions packages/ifpack2/src/Ifpack2_RILUK_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,10 @@ void RILUK<MatrixType>::initialize ()
checkOrderingConsistency (*A_local_);
L_solver_->setMatrix (L_);
L_solver_->initialize ();
L_solver_->compute ();//NOTE: It makes sense to do compute here because only the nonzero pattern is involved in trisolve compute
U_solver_->setMatrix (U_);
U_solver_->initialize ();
U_solver_->compute ();//NOTE: It makes sense to do compute here because only the nonzero pattern is involved in trisolve compute

// Do not call initAllValues. compute() always calls initAllValues to
// fill L and U with possibly new numbers. initialize() is concerned
Expand Down Expand Up @@ -897,9 +899,9 @@ void RILUK<MatrixType>::compute ()

// If L_solver_ or U_solver store modified factors internally, we need to reset those
L_solver_->setMatrix (L_);
L_solver_->compute ();
L_solver_->compute ();//NOTE: Only do compute if the pointer changed. Otherwise, do nothing
U_solver_->setMatrix (U_);
U_solver_->compute ();
U_solver_->compute ();//NOTE: Only do compute if the pointer changed. Otherwise, do nothing
}
else {
{//Make sure values in A is picked up even in case of pattern reuse
Expand Down Expand Up @@ -962,9 +964,9 @@ void RILUK<MatrixType>::compute ()
U_->fillComplete (A_local_->getDomainMap (), U_->getRowMap ());

L_solver_->setMatrix (L_);
L_solver_->compute ();
L_solver_->compute ();//NOTE: Only do compute if the pointer changed. Otherwise, do nothing
U_solver_->setMatrix (U_);
U_solver_->compute ();
U_solver_->compute ();//NOTE: Only do compute if the pointer changed. Otherwise, do nothing
}

isComputed_ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Project x onto the bounds
template<class Real, class V>
template<class Real, class V, class CV>
struct Project {
typedef typename V::execution_space execution_space;
V X_; // Optimization variable
V L_; // Lower bounds
V U_; // Upper bounds
CV L_; // Lower bounds
CV U_; // Upper bounds

Project(V& X, const V& L, const V& U) : X_(X), L_(L), U_(U) {}
Project(V& X, const CV& L, const CV& U) : X_(X), L_(L), U_(U) {}

KOKKOS_INLINE_FUNCTION
void operator() (const int i) const {
Expand All @@ -158,15 +158,15 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the lower active set
template<class Real, class V>
template<class Real, class V, class CV>
struct PruneLowerActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V X_; // Optimization variable
V L_; // Lower bounds
CV X_; // Optimization variable
CV L_; // Lower bounds
Real eps_;

PruneLowerActive(V &Y, const V &X, const V &L, Real eps) :
PruneLowerActive(V &Y, const CV &X, const CV &L, Real eps) :
Y_(Y), X_(X), L_(L), eps_(eps) {}

KOKKOS_INLINE_FUNCTION
Expand All @@ -184,15 +184,15 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the upper active set
template<class Real, class V>
template<class Real, class V, class CV>
struct PruneUpperActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V X_; // Optimization variable
V U_; // Upper bounds
CV X_; // Optimization variable
CV U_; // Upper bounds
Real eps_;

PruneUpperActive(V &Y, const V &X, const V &U, Real eps) :
PruneUpperActive(V &Y, const CV &X, const CV &U, Real eps) :
Y_(Y), X_(X), U_(U), eps_(eps) {}

KOKKOS_INLINE_FUNCTION
Expand All @@ -210,16 +210,16 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the active set
template<class Real, class V>
template<class Real, class V, class CV>
struct PruneActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V X_; // Optimization variable
V L_; // Lower bounds
V U_; // Upper bounds
CV X_; // Optimization variable
CV L_; // Lower bounds
CV U_; // Upper bounds
Real eps_;

PruneActive(V &Y, const V &X, const V &L, const V &U, Real eps) :
PruneActive(V &Y, const CV &X, const CV &L, const CV &U, Real eps) :
Y_(Y), X_(X), L_(L), U_(U), eps_(eps) {}

KOKKOS_INLINE_FUNCTION
Expand All @@ -240,17 +240,17 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the lower active set and grad is positive
template<class Real, class V>
template<class Real, class V, class CV>
struct GradPruneLowerActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V G_; // Gradient
V X_; // Optimization variable
V L_; // Lower bounds
CV G_; // Gradient
CV X_; // Optimization variable
CV L_; // Lower bounds

Real xeps_, geps_;

GradPruneLowerActive(V &Y, const V &G, const V &X, const V &L,Real xeps, Real geps) :
GradPruneLowerActive(V &Y, const CV &G, const CV &X, const CV &L,Real xeps, Real geps) :
Y_(Y), G_(G), X_(X), L_(L), xeps_(xeps), geps_(geps) {}

KOKKOS_INLINE_FUNCTION
Expand All @@ -268,17 +268,17 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the upper active set and grad is negative
template<class Real, class V>
template<class Real, class V, class CV>
struct GradPruneUpperActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V G_; // Gradient
V X_; // Optimization variable
V U_; // Upper bounds
CV G_; // Gradient
CV X_; // Optimization variable
CV U_; // Upper bounds

Real xeps_, geps_;

GradPruneUpperActive(V &Y, const V &G, const V &X, const V &U, Real xeps, Real geps) :
GradPruneUpperActive(V &Y, const CV &G, const CV &X, const CV &U, Real xeps, Real geps) :
Y_(Y), G_(G), X_(X), U_(U), xeps_(xeps), geps_(geps) {}

KOKKOS_INLINE_FUNCTION
Expand All @@ -296,17 +296,17 @@ namespace ROL {
//----------------------------------------------------------------------
//
// Set variables to zero if they correspond to the active set
template<class Real, class V>
template<class Real, class V, class CV>
struct GradPruneActive {
typedef typename V::execution_space execution_space;
V Y_; // Variable to be pruned
V G_; // Gradient
V X_; // Optimization variable
V L_; // Lower bounds
V U_; // Upper bounds
CV G_; // Gradient
CV X_; // Optimization variable
CV L_; // Lower bounds
CV U_; // Upper bounds
Real xeps_, geps_;

GradPruneActive(V &Y, const V &G, const V &X, const V &L, const V &U, Real xeps, Real geps) :
GradPruneActive(V &Y, const CV &G, const CV &X, const CV &L, const CV &U, Real xeps, Real geps) :
Y_(Y), G_(G), X_(X), L_(L), U_(U), xeps_(xeps), geps_(geps) {}

KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -335,20 +335,18 @@ namespace ROL {


typedef Tpetra::MultiVector<Real,LO,GO,Node> MV;
typedef Tpetra::MultiVector<const Real,LO,GO,Node> CMV;
typedef ROL::Ptr<MV> MVP;
typedef ROL::Ptr<const MV> CMVP;
typedef TpetraMultiVector<Real,LO,GO,Node> TMV;
typedef ROL::Ptr<TMV> TMVP;
typedef typename MV::dual_view_type::t_dev ViewType;
typedef typename CMV::dual_view_type::t_dev ConstViewType;

private:
int gblDim_;
int lclDim_;
MVP lp_;
MVP up_;

ViewType l_; // Kokkos view of Lower bounds
ViewType u_; // Kokkos view of Upper bounds
ConstViewType l_; // Kokkos view of Lower bounds
ConstViewType u_; // Kokkos view of Upper bounds
Real min_diff_;
Real scale_;
ROL::Ptr<const Teuchos::Comm<int> > comm_;
Expand All @@ -366,14 +364,12 @@ namespace ROL {
TpetraBoundConstraint(MVP lp, MVP up, Real scale = 1.0) :
gblDim_(lp->getGlobalLength()),
lclDim_(lp->getLocalLength()),
lp_(lp),
up_(up),
l_(lp->getLocalViewDevice()),
u_(up->getLocalViewDevice()),
l_(lp->getLocalViewDevice(Tpetra::Access::ReadOnly)),
u_(up->getLocalViewDevice(Tpetra::Access::ReadOnly)),
scale_(scale),
comm_(lp->getMap()->getComm()) {

KokkosStructs::MinGap<Real,ViewType> findmin(l_,u_);
KokkosStructs::MinGap<Real,ConstViewType> findmin(l_,u_);
Real lclMinGap = 0;

// Reduce for this MPI process
Expand All @@ -393,9 +389,9 @@ namespace ROL {

int lclFeasible = 1;

ViewType x_lcl = xp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);

KokkosStructs::Feasible<Real,ViewType> check(x_lcl, l_, u_);
KokkosStructs::Feasible<Real,ConstViewType> check(x_lcl, l_, u_);

Kokkos::parallel_reduce(lclDim_,check,lclFeasible);

Expand All @@ -410,9 +406,9 @@ namespace ROL {

auto xp = getVector(x);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::Project<Real,ViewType> proj(x_lcl,l_,u_);
KokkosStructs::Project<Real,ViewType,ConstViewType> proj(x_lcl,l_,u_);

Kokkos::parallel_for(lclDim_,proj);
}
Expand All @@ -424,10 +420,10 @@ namespace ROL {

Real epsn = std::min(scale_*eps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::PruneLowerActive<Real,ViewType> prune(v_lcl,x_lcl,l_,epsn);
KokkosStructs::PruneLowerActive<Real,ViewType,ConstViewType> prune(v_lcl,x_lcl,l_,epsn);

Kokkos::parallel_for(lclDim_,prune);
}
Expand All @@ -438,10 +434,10 @@ namespace ROL {

Real epsn = std::min(scale_*eps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::PruneUpperActive<Real,ViewType> prune(v_lcl,x_lcl,u_,epsn);
KokkosStructs::PruneUpperActive<Real,ViewType,ConstViewType> prune(v_lcl,x_lcl,u_,epsn);

Kokkos::parallel_for(lclDim_,prune);
}
Expand All @@ -452,10 +448,10 @@ namespace ROL {

Real epsn = std::min(scale_*eps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::PruneActive<Real,ViewType> prune(v_lcl,x_lcl,l_,u_,epsn);
KokkosStructs::PruneActive<Real,ViewType,ConstViewType> prune(v_lcl,x_lcl,l_,u_,epsn);

Kokkos::parallel_for(lclDim_,prune);
}
Expand All @@ -466,11 +462,11 @@ namespace ROL {
auto vp = getVector(v);
Real epsn = std::min(scale_*xeps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType g_lcl = gp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ConstViewType g_lcl = gp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::GradPruneLowerActive<Real,ViewType> prune(v_lcl,g_lcl,x_lcl,l_,epsn,geps);
KokkosStructs::GradPruneLowerActive<Real,ViewType,ConstViewType> prune(v_lcl,g_lcl,x_lcl,l_,epsn,geps);

Kokkos::parallel_for(lclDim_,prune);
}
Expand All @@ -481,11 +477,11 @@ namespace ROL {
auto vp = getVector(v);
Real epsn = std::min(scale_*xeps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType g_lcl = gp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ConstViewType g_lcl = gp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::GradPruneUpperActive<Real,ViewType> prune(v_lcl,g_lcl,x_lcl,u_,epsn,geps);
KokkosStructs::GradPruneUpperActive<Real,ViewType,ConstViewType> prune(v_lcl,g_lcl,x_lcl,u_,epsn,geps);

Kokkos::parallel_for(lclDim_,prune);
}
Expand All @@ -496,11 +492,11 @@ namespace ROL {
auto vp = getVector(v);
Real epsn = std::min(scale_*xeps,this->min_diff_);

ViewType x_lcl = xp->getLocalViewDevice();
ViewType g_lcl = gp->getLocalViewDevice();
ViewType v_lcl = vp->getLocalViewDevice();
ConstViewType x_lcl = xp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ConstViewType g_lcl = gp->getLocalViewDevice(Tpetra::Access::ReadOnly);
ViewType v_lcl = vp->getLocalViewDevice(Tpetra::Access::ReadWrite);

KokkosStructs::GradPruneActive<Real,ViewType> prune(v_lcl,g_lcl,x_lcl,l_,u_,epsn,geps);
KokkosStructs::GradPruneActive<Real,ViewType,ConstViewType> prune(v_lcl,g_lcl,x_lcl,l_,u_,epsn,geps);

Kokkos::parallel_for(lclDim_,prune);
}
Expand Down
Loading

0 comments on commit a3b63fd

Please sign in to comment.