Skip to content

Commit

Permalink
Merge Pull Request #6488 from mhoemmen/Trilinos/TSQR-Dec2019
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: TpetraTSQR: Run on NVIDIA GPUs; ensure correct testing; refactor
PR Author: mhoemmen
  • Loading branch information
trilinos-autotester authored Dec 23, 2019
2 parents c8e4314 + 842320a commit 9c0d1c6
Show file tree
Hide file tree
Showing 89 changed files with 9,862 additions and 15,034 deletions.
2 changes: 2 additions & 0 deletions TPLsList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ TRIBITS_REPOSITORY_DEFINE_TPLS(
yaml-cpp "cmake/TPLs/" EX
Peano "cmake/TPLs/" EX
CUDA "${${PROJECT_NAME}_TRIBITS_DIR}/core/std_tpls/" PT
CUBLAS "cmake/TPLs/" PT
CUSOLVER "cmake/TPLs/" PT
CUSPARSE "cmake/TPLs/" PT
Thrust "cmake/TPLs/" ST
Cusp "cmake/TPLs/" ST
Expand Down
70 changes: 70 additions & 0 deletions cmake/TPLs/FindTPLCUBLAS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# @HEADER
# ************************************************************************
#
# Trilinos: An Object-Oriented Solver Framework
# Copyright (2001) Sandia Corporation
#
#
# Copyright (2001) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000, there is a non-exclusive license for use of this
# work by or on behalf of the U.S. Government. Export of this program
# may require a license from the United States Government.
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# NOTICE: The United States Government is granted for itself and others
# acting on its behalf a paid-up, nonexclusive, irrevocable worldwide
# license in this data to reproduce, prepare derivative works, and
# perform publicly and display publicly. Beginning five (5) years from
# July 25, 2001, the United States Government is granted for itself and
# others acting on its behalf a paid-up, nonexclusive, irrevocable
# worldwide license in this data to reproduce, prepare derivative works,
# distribute copies to the public, perform publicly and display
# publicly, and to permit others to do so.
#
# NEITHER THE UNITED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT
# OF ENERGY, NOR SANDIA CORPORATION, NOR ANY OF THEIR EMPLOYEES, MAKES
# ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR
# RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY
# INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS
# THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS.
#
# ************************************************************************
# @HEADER

IF (NOT TPL_ENABLE_CUDA)
MESSAGE(FATAL_ERROR "\nCUBLAS: This TPL requires CUDA")
ELSE()
find_library(CUDA_cublas_LIBRARY
cublas
HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib
)
IF(CUDA_cublas_LIBRARY STREQUAL "CUDA_cublas_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUBLAS: could not find cublas library.")
ENDIF()
GLOBAL_SET(TPL_CUBLAS_LIBRARY_DIRS)
GLOBAL_SET(TPL_CUBLAS_INCLUDE_DIRS ${TPL_CUDA_INCLUDE_DIRS})
GLOBAL_SET(TPL_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY})
ENDIF()

70 changes: 70 additions & 0 deletions cmake/TPLs/FindTPLCUSOLVER.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# @HEADER
# ************************************************************************
#
# Trilinos: An Object-Oriented Solver Framework
# Copyright (2001) Sandia Corporation
#
#
# Copyright (2001) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000, there is a non-exclusive license for use of this
# work by or on behalf of the U.S. Government. Export of this program
# may require a license from the United States Government.
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# NOTICE: The United States Government is granted for itself and others
# acting on its behalf a paid-up, nonexclusive, irrevocable worldwide
# license in this data to reproduce, prepare derivative works, and
# perform publicly and display publicly. Beginning five (5) years from
# July 25, 2001, the United States Government is granted for itself and
# others acting on its behalf a paid-up, nonexclusive, irrevocable
# worldwide license in this data to reproduce, prepare derivative works,
# distribute copies to the public, perform publicly and display
# publicly, and to permit others to do so.
#
# NEITHER THE UNITED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT
# OF ENERGY, NOR SANDIA CORPORATION, NOR ANY OF THEIR EMPLOYEES, MAKES
# ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR
# RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY
# INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS
# THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS.
#
# ************************************************************************
# @HEADER

IF (NOT TPL_ENABLE_CUDA)
MESSAGE(FATAL_ERROR "\nCUSOLVER: This TPL requires CUDA")
ELSE()
find_library(CUDA_cusolver_LIBRARY
cusolver
HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib
)
IF(CUDA_cusolver_LIBRARY STREQUAL "CUDA_cusolver_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUSOLVER: could not find cusolver library.")
ENDIF()
GLOBAL_SET(TPL_CUSOLVER_LIBRARY_DIRS)
GLOBAL_SET(TPL_CUSOLVER_INCLUDE_DIRS ${TPL_CUDA_INCLUDE_DIRS})
GLOBAL_SET(TPL_CUSOLVER_LIBRARIES ${CUDA_cusolver_LIBRARY})
ENDIF()

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ************************************************************************
// @HEADER

Expand All @@ -48,18 +46,18 @@

#include "Stokhos_Sacado_Kokkos_UQ_PCE.hpp"

# include <Tsqr_NodeTsqrFactory.hpp> // create intranode TSQR object
# include <Tsqr.hpp> // full (internode + intranode) TSQR
# include <Tsqr_DistTsqr.hpp> // internode TSQR
# include "Tsqr_NodeTsqrFactory.hpp" // create intranode TSQR object
# include "Tsqr.hpp" // full (internode + intranode) TSQR
# include "Tsqr_DistTsqr.hpp" // internode TSQR
// Subclass of TSQR::MessengerBase, implemented using Teuchos
// communicator template helper functions
# include <Tsqr_TeuchosMessenger.hpp>
# include <Tpetra_MultiVector.hpp>
# include <Teuchos_ParameterListAcceptorDefaultBase.hpp>
# include "Tsqr_TeuchosMessenger.hpp"
# include "Tpetra_MultiVector.hpp"
# include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
# include <stdexcept>

// Base TsqrAdator template we will specialize
# include <Tpetra_TsqrAdaptor.hpp>
# include "Tpetra_TsqrAdaptor.hpp"

namespace Tpetra {

Expand All @@ -81,16 +79,16 @@ namespace Tpetra {
typedef typename mp_scalar_type::scalar_type scalar_type;
typedef typename mp_scalar_type::ordinal_type mp_ordinal_type;
typedef typename MV::local_ordinal_type ordinal_type;
typedef typename MV::node_type node_type;
typedef Teuchos::SerialDenseMatrix<ordinal_type, scalar_type> dense_matrix_type;
typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;

private:
//typedef TSQR::MatView<ordinal_type, scalar_type> matview_type;
typedef TSQR::NodeTsqrFactory<node_type, scalar_type, ordinal_type> node_tsqr_factory_type;
typedef typename node_tsqr_factory_type::node_tsqr_type node_tsqr_type;
typedef TSQR::DistTsqr<ordinal_type, scalar_type> dist_tsqr_type;
typedef TSQR::Tsqr<ordinal_type, scalar_type, node_tsqr_type> tsqr_type;
using node_tsqr_factory_type =
TSQR::NodeTsqrFactory<scalar_type, ordinal_type,
typename MV::device_type>;
using node_tsqr_type = TSQR::NodeTsqr<ordinal_type, scalar_type>;
using dist_tsqr_type = TSQR::DistTsqr<ordinal_type, scalar_type>;
using tsqr_type = TSQR::Tsqr<ordinal_type, scalar_type>;

public:
/// \brief Constructor (that accepts a parameter list).
Expand All @@ -100,7 +98,7 @@ namespace Tpetra {
/// implementation. For details, call \c getValidParameters()
/// and examine the documentation embedded therein.
TsqrAdaptor (const Teuchos::RCP<Teuchos::ParameterList>& plist) :
nodeTsqr_ (new node_tsqr_type),
nodeTsqr_ (node_tsqr_factory_type::getNodeTsqr ()),
distTsqr_ (new dist_tsqr_type),
tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
ready_ (false)
Expand All @@ -110,7 +108,7 @@ namespace Tpetra {

//! Constructor (that uses default parameters).
TsqrAdaptor () :
nodeTsqr_ (new node_tsqr_type),
nodeTsqr_ (new node_tsqr_factory_type::getNodeTsqr ()),
distTsqr_ (new dist_tsqr_type),
tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
ready_ (false)
Expand Down Expand Up @@ -289,20 +287,10 @@ namespace Tpetra {
{
if (! ready_) {
prepareDistTsqr (mv);
prepareNodeTsqr (mv);
ready_ = true;
}
}

/// \brief Finish intraprocess TSQR initialization.
///
/// \note It's OK to call this method more than once; it is idempotent.
void
prepareNodeTsqr (const MV& mv)
{
node_tsqr_factory_type::prepareNodeTsqr (nodeTsqr_);
}

/// \brief Finish interprocess TSQR initialization.
///
/// \param mv [in] A valid Tpetra::MultiVector instance whose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ************************************************************************
// @HEADER

Expand All @@ -48,18 +46,18 @@

#include "Stokhos_Sacado_Kokkos_MP_Vector.hpp"

# include <Tsqr_NodeTsqrFactory.hpp> // create intranode TSQR object
# include <Tsqr.hpp> // full (internode + intranode) TSQR
# include <Tsqr_DistTsqr.hpp> // internode TSQR
# include "Tsqr_NodeTsqrFactory.hpp" // create intranode TSQR object
# include "Tsqr.hpp" // full (internode + intranode) TSQR
# include "Tsqr_DistTsqr.hpp" // internode TSQR
// Subclass of TSQR::MessengerBase, implemented using Teuchos
// communicator template helper functions
# include <Tsqr_TeuchosMessenger.hpp>
# include <Tpetra_MultiVector.hpp>
# include <Teuchos_ParameterListAcceptorDefaultBase.hpp>
# include "Tsqr_TeuchosMessenger.hpp"
# include "Tpetra_MultiVector.hpp"
# include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
# include <stdexcept>

// Base TsqrAdator template we will specialize
# include <Tpetra_TsqrAdaptor.hpp>
# include "Tpetra_TsqrAdaptor.hpp"

namespace Tpetra {

Expand All @@ -81,16 +79,16 @@ namespace Tpetra {
typedef typename mp_scalar_type::scalar_type scalar_type;
typedef typename mp_scalar_type::ordinal_type mp_ordinal_type;
typedef typename MV::local_ordinal_type ordinal_type;
typedef typename MV::node_type node_type;
typedef Teuchos::SerialDenseMatrix<ordinal_type, scalar_type> dense_matrix_type;
typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;

private:
//typedef TSQR::MatView<ordinal_type, scalar_type> matview_type;
typedef TSQR::NodeTsqrFactory<node_type, scalar_type, ordinal_type> node_tsqr_factory_type;
typedef typename node_tsqr_factory_type::node_tsqr_type node_tsqr_type;
typedef TSQR::DistTsqr<ordinal_type, scalar_type> dist_tsqr_type;
typedef TSQR::Tsqr<ordinal_type, scalar_type, node_tsqr_type> tsqr_type;
using node_tsqr_factory_type =
TSQR::NodeTsqrFactory<scalar_type, ordinal_type,
typename MV::device_type>;
using node_tsqr_type = TSQR::NodeTsqr<ordinal_type, scalar_type>;
using dist_tsqr_type = TSQR::DistTsqr<ordinal_type, scalar_type>;
using tsqr_type = TSQR::Tsqr<ordinal_type, scalar_type>;

public:
/// \brief Constructor (that accepts a parameter list).
Expand All @@ -100,7 +98,7 @@ namespace Tpetra {
/// implementation. For details, call \c getValidParameters()
/// and examine the documentation embedded therein.
TsqrAdaptor (const Teuchos::RCP<Teuchos::ParameterList>& plist) :
nodeTsqr_ (new node_tsqr_type),
nodeTsqr_ (node_tsqr_factory_type::getNodeTsqr ()),
distTsqr_ (new dist_tsqr_type),
tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
ready_ (false)
Expand All @@ -110,7 +108,7 @@ namespace Tpetra {

//! Constructor (that uses default parameters).
TsqrAdaptor () :
nodeTsqr_ (new node_tsqr_type),
nodeTsqr_ (node_tsqr_factory_type::getNodeTsqr ()),
distTsqr_ (new dist_tsqr_type),
tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
ready_ (false)
Expand Down Expand Up @@ -289,20 +287,10 @@ namespace Tpetra {
{
if (! ready_) {
prepareDistTsqr (mv);
prepareNodeTsqr (mv);
ready_ = true;
}
}

/// \brief Finish intraprocess TSQR initialization.
///
/// \note It's OK to call this method more than once; it is idempotent.
void
prepareNodeTsqr (const MV& mv)
{
node_tsqr_factory_type::prepareNodeTsqr (nodeTsqr_);
}

/// \brief Finish interprocess TSQR initialization.
///
/// \param mv [in] A valid Tpetra::MultiVector instance whose
Expand Down
11 changes: 1 addition & 10 deletions packages/stratimikos/adapters/belos/src/Thyra_TsqrAdaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ namespace Thyra {
#endif // HAVE_MPI
}

/// \brief Finish intraprocess TSQR initialization.
///
/// \note It's OK to call this method more than once; it is idempotent.
void
prepareNodeTsqr (const MV& /* X */) {}

/// \brief Finish interprocess TSQR initialization.
///
/// Input X is a valid Thyra::MultiVectorBase instance whose
Expand Down Expand Up @@ -306,10 +300,7 @@ namespace Thyra {
/// All multivector objects used with this adapter must have the
/// same communicator and Kokkos Node instance (if applicable).
void
prepareTsqr (const MV& /* X */)
{
throw std::logic_error ("Thyra adaptor for TSQR not implemented");
}
prepareTsqr (const MV& /* X */) {}
};

} // namespace Tpetra
Expand Down
Loading

0 comments on commit 9c0d1c6

Please sign in to comment.