Skip to content

Commit

Permalink
SPMM: add Boost::graph as dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Apr 3, 2024
1 parent 1fd7cf3 commit cf17582
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmake/modules/FindOrFetchBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (TTG_PARSEC_USE_BOOST_SERIALIZATION)
list(APPEND optional_components
serialization
iostreams
graph
)
endif()

Expand Down
10 changes: 6 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ add_ttg_executable(t9-streaming t9/t9_streaming.cc)
# sparse matmul need Eigen ... it's always provided by TA
if (TARGET tiledarray)
# MADworld used for MADNESS serialization
add_ttg_executable(spmm spmm/spmm.cc LINK_LIBRARIES TiledArray_Eigen)
add_ttg_executable(spmm spmm/spmm.cc LINK_LIBRARIES TiledArray_Eigen $<TARGET_NAME_IF_EXISTS:Boost::graph>
COMPILE_DEFINITIONS $<$<TARGET_EXISTS:Boost::graph>,HAVE_BOOST_GRAPH=1>)
# block-sparse needs BTAS ... it's always provided by TA
# since only need to use matrices, limit BTAS_TARGET_MAX_INDEX_RANK to 2
add_ttg_executable(bspmm spmm/spmm.cc LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2)
add_ttg_executable(bspmm spmm/spmm.cc LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2)

add_ttg_executable(testing_dpotrf potrf/testing_dpotrf.cc LINK_LIBRARIES tiledarray lapackpp)
add_ttg_executable(testing_dtrtri potrf/testing_dtrtri.cc LINK_LIBRARIES tiledarray lapackpp)
Expand All @@ -37,12 +39,12 @@ if (TARGET tiledarray)
if (TARGET roc::hipsolver)
add_ttg_executable(testing_dpotrf_hip potrf/testing_dpotrf.cc
LINK_LIBRARIES lapackpp tiledarray roc::hipblas roc::hipsolver
COMPILE_DEFINITIONS TTG_ENABLE_HIP=1;DEBUG_TILES_VALUES=1
COMPILE_DEFINITIONS TTG_ENABLE_HIP=1 #;DEBUG_TILES_VALUES=1
RUNTIMES "parsec")
endif(TARGET roc::hipsolver)
elseif (TARGET MKL::MKL_DPCPP)
add_ttg_executable(bspmm-lz spmm/spmm_cuda.cc
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS MKL::MKL_DPCPP level_zero::ze_loader m
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS MKL::MKL_DPCPP level_zero::ze_loader m Boost::graph
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2
RUNTIMES "parsec")
endif()
Expand Down
6 changes: 5 additions & 1 deletion examples/spmm/spmm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#endif

#include <sys/time.h>
#include <boost/graph/rmat_graph_generator.hpp>
#if !defined(BLOCK_SPARSE_GEMM)
#include <boost/graph/rmat_graph_generator.hpp>
#include <boost/graph/directed_graph.hpp>
#include <boost/random/linear_congruential.hpp>
#include <unsupported/Eigen/SparseExtra>
Expand Down Expand Up @@ -1104,6 +1104,7 @@ static void initSpMatrixMarket(const std::function<int(const Key<2> &)> &keymap,
K = (int)A.cols();
}

#ifdef HAVE_BOOST_GRAPH
static void initSpRmat(const std::function<int(const Key<2> &)> &keymap, const char *opt, SpMatrix<> &A, SpMatrix<> &B,
SpMatrix<> &C, int &M, int &N, int &K, unsigned long seed) {
int E;
Expand Down Expand Up @@ -1160,6 +1161,7 @@ static void initSpRmat(const std::function<int(const Key<2> &)> &keymap, const c
std::cout << "#R-MAT: " << E << " nonzero elements, density: " << (double)nnz / (double)N / (double)N << std::endl;
}
}
#endif // HAVE_BOOST_GRAPH

static void initSpHardCoded(const std::function<int(const Key<2> &)> &keymap, SpMatrix<> &A, SpMatrix<> &B,
SpMatrix<> &C, int &m, int &n, int &k) {
Expand Down Expand Up @@ -1802,10 +1804,12 @@ int main(int argc, char **argv) {
char *filename = getCmdOption(argv, argv + argc, "-mm");
tiling_type = filename;
initSpMatrixMarket(ij_keymap, filename, A, B, C, M, N, K);
#ifdef HAVE_BOOST_GRAPH
} else if (cmdOptionExists(argv, argv + argc, "-rmat")) {
char *opt = getCmdOption(argv, argv + argc, "-rmat");
tiling_type = "RandomSparseMatrix";
initSpRmat(ij_keymap, opt, A, B, C, M, N, K, seed);
#endif // HAVE_BOOST_GRAPH
} else {
tiling_type = "HardCodedSparseMatrix";
initSpHardCoded(ij_keymap, A, B, C, M, N, K);
Expand Down

0 comments on commit cf17582

Please sign in to comment.