Skip to content

Commit

Permalink
Merge Pull Request #7755 from trilinos/Trilinos/master_merge_20200731…
Browse files Browse the repository at this point in the history
…_000610

Automatically Merged using Trilinos Master Merge AutoTester
PR Title: Trilinos Master Merge PR Generator: Auto PR created to promote from master_merge_20200731_000610 branch to master
PR Author: trilinos-autotester
  • Loading branch information
trilinos-autotester authored Jul 31, 2020
2 parents 0af3d5f + 3107d22 commit f3e545b
Show file tree
Hide file tree
Showing 35 changed files with 5,166 additions and 860 deletions.
11 changes: 10 additions & 1 deletion packages/amesos2/test/solvers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ IF (${PACKAGE_NAME}_ENABLE_Cholmod)

TRIBITS_COPY_FILES_TO_BINARY_DIR(SolverTestCholmodFiles
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOURCE_FILES cholmod_test.xml
SOURCE_FILES cholmod_test.xml cholmod_int_test.xml
EXEDEPS Solver_Test
)

Expand All @@ -191,6 +191,15 @@ IF (${PACKAGE_NAME}_ENABLE_Cholmod)
COMM serial mpi
)

TRIBITS_ADD_TEST(
Solver_Test
NAME Cholmod_Int_Solver_Test
ARGS "--xml-params=cholmod_int_test.xml --filedir=${CMAKE_CURRENT_BINARY_DIR}/../matrices/ --multiple-solves --refactor"
STANDARD_PASS_OUTPUT
NUM_MPI_PROCS 1
COMM serial mpi
)

IF (KokkosKernels_ENABLE_SUPERNODAL_SPTRSV AND KokkosKernels_ENABLE_TPL_CHOLMOD)

TRIBITS_COPY_FILES_TO_BINARY_DIR(SolverTestCholmodTRSVFiles
Expand Down
64 changes: 64 additions & 0 deletions packages/amesos2/test/solvers/cholmod_int_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<ParameterList name="test_params">

<ParameterList name="tacho_test.mtx">

<!-- Optional parameter, used for debugging and for deciding whether to use epetra -->
<Parameter name="complex" type="bool" value="false"/>
<ParameterList name="Cholmod">

<!-- Test Epetra objects -->
<ParameterList name="epetra">
<!-- A non-list entry for epetra denotes a default run, name, type, and value are arbitrary -->
<Parameter name="defaultrun" type="bool" value="true"/>
</ParameterList>

<!-- Next test Tpetra objects -->
<ParameterList name="tpetra">
<!-- these `run*' sublist names are arbitrary -->
<!-- The `Node' parameter is not yet supported -->
<!-- Cholmod does not support float yet. -->

<ParameterList name="run_double_int">
<Parameter name="Scalar" type="string" value="double"/>
<Parameter name="LocalOrdinal" type="string" value="int"/>
<Parameter name="GlobalOrdinal" type="string" value="int"/>
</ParameterList>
<ParameterList name="run_double_long_long">
<Parameter name="Scalar" type="string" value="double"/>
<Parameter name="LocalOrdinal" type="string" value="int"/>
<Parameter name="GlobalOrdinal" type="string" value="long long int"/>
</ParameterList>
</ParameterList>

<!-- Next test Kokkos objects -->
<ParameterList name="kokkos">
<!-- these `run*' sublist names are arbitrary -->
<!-- Cholmod does not support float yet. -->
<ParameterList name="run_serial_double">
<Parameter name="Scalar" type="string" value="double"/>
<Parameter name="LocalOrdinal" type="string" value="int"/>
<Parameter name="Node" type="string" value="serial"/>
</ParameterList>
<ParameterList name="run_cuda_double">
<Parameter name="Scalar" type="string" value="double"/>
<Parameter name="LocalOrdinal" type="string" value="int"/>
<Parameter name="Node" type="string" value="cuda"/>
</ParameterList>
<ParameterList name="run_cudauvmoff_double">
<Parameter name="Scalar" type="string" value="double"/>
<Parameter name="LocalOrdinal" type="string" value="int"/>
<Parameter name="Node" type="string" value="cudauvmoff"/>
</ParameterList>
</ParameterList>

<ParameterList name="solver_params">
<Parameter name="CholmodInt" type="bool" value="true"/>
<!-- Cholmod cannot be GPU for int, though we can still run inputs with GPU as in the above tests,-->
<Parameter name="useGPU" type="int" value="0"/>
</ParameterList>
</ParameterList> <!-- end Cholmod -->
<ParameterList name="all_solver_params">
</ParameterList>
</ParameterList> <!-- end cholmod_test.mtx -->

</ParameterList>
4 changes: 2 additions & 2 deletions packages/shylu/shylu_node/tacho/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SET(LIB_REQUIRED_DEP_PACKAGES Kokkos)
SET(LIB_OPTIONAL_DEP_PACKAGES TrilinosSS)
SET(TEST_REQUIRED_DEP_PACKAGES Kokkos TrilinosSS Gtest)
SET(LIB_OPTIONAL_DEP_PACKAGES)
SET(TEST_REQUIRED_DEP_PACKAGES Kokkos KokkosAlgorithms Gtest)
SET(TEST_OPTIONAL_DEP_PACKAGES)
SET(LIB_REQUIRED_DEP_TPLS)
SET(LIB_OPTIONAL_DEP_TPLS METIS Scotch Cholmod HWLOC HYPRE MKL LAPACK BLAS Pthread QTHREAD VTune CUSOLVER CUSPARSE CUBLAS CUDA)
Expand Down
9 changes: 8 additions & 1 deletion packages/shylu/shylu_node/tacho/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ FILE(GLOB SOURCES *.cpp)

SET(LIBRARIES tacho)

TRIBITS_ADD_EXECUTABLE(
Tacho_ExampleCombineDataFileToMatrixMarketFile
NOEXEPREFIX
SOURCES Tacho_ExampleCombineDataFileToMatrixMarketFile.cpp
COMM serial mpi
)

IF (TACHO_HAVE_KOKKOS_TASK)
#
# Supernodes
Expand Down Expand Up @@ -199,7 +206,7 @@ IF (TACHO_HAVE_KOKKOS_TASK)
ENDIF()

TRIBITS_COPY_FILES_TO_BINARY_DIR(Tacho_SimpleSparseTest_File
SOURCE_FILES test.mtx
SOURCE_FILES test.mtx graph.dat weight.dat graph_test.mtx
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
DEST_DIR ${CMAKE_CURRENT_BINARY_DIR}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ int main (int argc, char *argv[]) {
#if defined(TACHO_HAVE_METIS)
typedef GraphTools_Metis graph_tools_type;
#else
/// not recommend to use CAMD
typedef GraphTools_CAMD graph_tools_type;
typedef GraphTools graph_tools_type;
#endif
Graph graph(h_A.NumRows(), h_A.NumNonZeros(), h_A.RowPtr(), h_A.Cols());
graph_tools_type G(graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int main (int argc, char *argv[]) {
#elif defined(TACHO_HAVE_SCOTCH)
Tacho::GraphTools_Scotch T(G);
#else
Tacho::GraphTools_CAMD T(G);
Tacho::GraphTools T(G);
#endif
T.reorder(verbose);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int main (int argc, char *argv[]) {
#elif defined(TACHO_HAVE_SCOTCH)
GraphTools_Scotch T(G);
#else
GraphTools_CAMD T(G);
GraphTools T(G);
#endif
T.reorder(verbose);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main (int argc, char *argv[]) {
#elif defined(TACHO_HAVE_SCOTCH)
Tacho::GraphTools_Scotch T(G);
#else
Tacho::GraphTools_CAMD T(G);
Tacho::GraphTools T(G);
#endif
T.reorder(verbose);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <Kokkos_Core.hpp>
#include <Kokkos_Random.hpp>
#include <impl/Kokkos_Timer.hpp>

#include "Tacho_Internal.hpp"
#include "Tacho_CommandLineParser.hpp"

using namespace Tacho;

int main (int argc, char *argv[]) {
CommandLineParser opts("This example program combines data file into a single matrix market file");

std::string graph_data_file = "graph.dat";
std::string value_data_file = "value.dat";
std::string matrix_market_file = "mm-out.mtx";

opts.set_option<std::string>("graph-file", "Input graph data file ", &graph_data_file);
opts.set_option<std::string>("value-file", "Input value data file ", &value_data_file);
opts.set_option<std::string>("matrix-market-file", "Output matrixmarket file", &matrix_market_file);

const bool r_parse = opts.parse(argc, argv);
if (r_parse) return 0; // print help return

Kokkos::initialize(argc, argv);

typedef Kokkos::DefaultHostExecutionSpace host_space;
{
typedef double value_type;
typedef CrsMatrixBase<value_type,host_space> CrsMatrixBaseTypeHost;

CrsMatrixBaseTypeHost A;
using ordinal_type_array = typename CrsMatrixBaseTypeHost::ordinal_type_array;
using size_type_array = typename CrsMatrixBaseTypeHost::size_type_array;
using value_type_array = typename CrsMatrixBaseTypeHost::value_type_array;

ordinal_type m(0), nnz(0);
size_type_array ap;
ordinal_type_array aj;
value_type_array ax;
{
std::ifstream in;
in.open(graph_data_file);
if (!in.good()) {
std::cout << "Failed in open the file: " << graph_data_file << std::endl;
return -1;
}

in >> m;
ap = size_type_array("ap", m+1);
for (ordinal_type i=0;i<(m+1);++i)
in >> ap(i);

nnz = ap(m);
aj = ordinal_type_array("aj", nnz);
for (ordinal_type k=0;k<nnz;++k)
in >> aj(k);
}
{
std::ifstream in;
in.open(value_data_file);
if (!in.good()) {
std::cout << "Failed in open the file: " << value_data_file << std::endl;
return -1;
}

ax = value_type_array("ax", nnz);
for (ordinal_type k=0;k<nnz;++k)
in >> ax(k);
}

A.setExternalMatrix(m, m, nnz, ap, aj, ax);
{
std::ofstream out(matrix_market_file);
MatrixMarket<value_type>::write(out, A);
}
}
Kokkos::finalize();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ namespace tacho {
/// with TACHO_ENABLE_INT_INT, size_type is "int"
int* rowBegin,
int* columns,
SX* values)
SX* values,
int numGraphRows = 0,
int* graphRowBegin = nullptr,
int* graphColumns = nullptr,
int* graphWeights = nullptr)
{
m_numRows = numRows;
if (m_numRows == 0) return 0;
Expand All @@ -83,6 +87,24 @@ namespace tacho {
size_type_array_host ap_host((size_type*) rowBegin, numRows+1);
ordinal_type_array_host aj_host((ordinal_type*)columns, numTerms);

size_type_array_host graph_ap_host;
ordinal_type_array_host graph_aj_host;
ordinal_type_array_host graph_aw_host;

if (numGraphRows > 0) {
if (graphRowBegin == nullptr ||
graphColumns == nullptr ||
graphWeights == nullptr) {
std::cout << "ExternalInterface::Error, with non-zero numGraphRows, graph pointers should not be nullptr\n";
std::logic_error("Error: one of graph pointers is nullptr");
} else {
const size_type nnz_graph = graph_ap_host(numGraphRows);
graph_ap_host = size_type_array_host((size_type*)graphRowBegin, numGraphRows+1);
graph_aj_host = ordinal_type_array_host((ordinal_type*)graphColumns, nnz_graph);
graph_aw_host = ordinal_type_array_host((ordinal_type*)graphWeights, nnz_graph);
}
}

#if defined (KOKKOS_ENABLE_CUDA)
/// transfer A into device
value_type_array ax(Kokkos::ViewAllocateWithoutInitializing("ax"),
Expand All @@ -97,7 +119,12 @@ namespace tacho {
Kokkos::Impl::Timer timer;
{
timer.reset();
m_Solver.analyze(numRows, ap_host, aj_host);
if (numGraphRows > 0) {
m_Solver.analyze(numRows, ap_host, aj_host,
numGraphRows, graph_ap_host, graph_aj_host, graph_aw_host);
} else {
m_Solver.analyze(numRows, ap_host, aj_host);
}
const double t = timer.seconds();
std::cout << "ExternalInterface:: analyze time " << t << std::endl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int main (int argc, char *argv[]) {
#elif defined(TACHO_HAVE_SCOTCH)
Tacho::GraphTools_Scotch G(graph);
#else
Tacho::GraphTools_CAMD G(graph);
Tacho::GraphTools G(graph);
#endif
G.reorder(verbose);

Expand Down
66 changes: 63 additions & 3 deletions packages/shylu/shylu_node/tacho/example/Tacho_ExampleSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ int driver (int argc, char *argv[]) {
bool verbose = true;
bool sanitize = false;
std::string file = "test.mtx";
std::string graph_file = "";
std::string weight_file = "";
int nrhs = 1;
int sym = 3;
int posdef = 1;
Expand All @@ -53,6 +55,8 @@ int driver (int argc, char *argv[]) {
opts.set_option<bool>("verbose", "Flag for verbose printing", &verbose);
opts.set_option<bool>("sanitize", "Flag to sanitize input matrix (remove zeros)", &sanitize);
opts.set_option<std::string>("file", "Input file (MatrixMarket SPD matrix)", &file);
opts.set_option<std::string>("graph", "Input condensed graph", &graph_file);
opts.set_option<std::string>("weight", "Input condensed graph weight", &weight_file);
opts.set_option<int>("nrhs", "Number of RHS vectors", &nrhs);
opts.set_option<int>("symmetric", "Symmetric type: 0 - unsym, 1 - structure sym, 2 - symmetric, 3 - hermitian", &sym);
opts.set_option<int>("posdef", "Positive definite: 0 - indef, 1 - positive definite", &posdef);
Expand Down Expand Up @@ -105,6 +109,53 @@ int driver (int argc, char *argv[]) {
}
Tacho::MatrixMarket<value_type>::read(file, A, sanitize, verbose);
}

/// read graph file if available
using size_type_array_host = typename CrsMatrixBaseTypeHost::size_type_array;
using ordinal_type_array_host = typename CrsMatrixBaseTypeHost::ordinal_type_array;

ordinal_type m_graph(0);
size_type_array_host ap_graph;
ordinal_type_array_host aw_graph, aj_graph;
{
if (graph_file.length() > 0 && weight_file.length() > 0) {
{
std::ifstream in;
in.open(graph_file);
if (!in.good()) {
std::cout << "Failed in open the file: " << graph_file << std::endl;
return -1;
}
in >> m_graph;

ap_graph = size_type_array_host("ap", m_graph+1);
for (ordinal_type i=0,iend=m_graph+1;i<iend;++i)
in >> ap_graph(i);

aj_graph = ordinal_type_array_host("aj", ap_graph(m_graph));
for (ordinal_type i=0;i<m_graph;++i) {
const ordinal_type jbeg = ap_graph(i), jend = ap_graph(i+1);
for (ordinal_type j=jbeg;j<jend;++j)
in >> aj_graph(j);
}
}

{
std::ifstream in;
in.open(weight_file);
if (!in.good()) {
std::cout << "Failed in open the file: " << weight_file << std::endl;
return -1;
}
ordinal_type m(0);
in >> m;
in >> m_graph;
aw_graph = ordinal_type_array_host("aw", m_graph);
for (ordinal_type i=0;i<m_graph;++i)
in >> aw_graph(i);
}
}
}

///
/// * to wrap triple pointers, declare following view types
Expand Down Expand Up @@ -149,9 +200,18 @@ int driver (int argc, char *argv[]) {
Kokkos::deep_copy(values_on_device, A.Values());

/// inputs are used for graph reordering and analysis
solver.analyze(A.NumRows(),
A.RowPtr(),
A.Cols());
if (m_graph > 0 && m_graph < A.NumRows())
solver.analyze(A.NumRows(),
A.RowPtr(),
A.Cols(),
m_graph,
ap_graph,
aj_graph,
aw_graph);
else
solver.analyze(A.NumRows(),
A.RowPtr(),
A.Cols());

/// create numeric tools and levelset tools
solver.initialize();
Expand Down
Loading

0 comments on commit f3e545b

Please sign in to comment.