Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pghysels committed Jun 20, 2024
1 parent 5352d83 commit 44cc00b
Show file tree
Hide file tree
Showing 56 changed files with 1,294 additions and 3,550 deletions.
3 changes: 0 additions & 3 deletions src/BLR/BLRBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#include "dense/KBLASWrapper.hpp"
#endif

// for gpu::round_up
#include "sparse/fronts/FrontalMatrixGPUKernels.hpp"

namespace strumpack {
namespace BLR {

Expand Down
8 changes: 4 additions & 4 deletions src/BLR/BLRExtendAdd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
namespace strumpack {

// forward declarations
template<typename scalar_t,typename integer_t> class FrontalMatrix;
template<typename scalar_t,typename integer_t> class FrontalMatrixMPI;
template<typename scalar_t,typename integer_t> class Front;
template<typename scalar_t,typename integer_t> class FrontMPI;
template<typename scalar_t,typename integer_t> class FrontBLRMPI;

namespace BLR {
Expand All @@ -46,8 +46,8 @@ namespace strumpack {
using DistM_t = DistributedMatrix<scalar_t>;
using BLR_t = BLRMatrix<scalar_t>;
using BLRMPI_t = BLRMatrixMPI<scalar_t>;
using F_t = FrontalMatrix<scalar_t,integer_t>;
using FMPI_t = FrontalMatrixMPI<scalar_t,integer_t>;
using F_t = Front<scalar_t,integer_t>;
using FMPI_t = FrontMPI<scalar_t,integer_t>;
using FBLRMPI_t = FrontBLRMPI<scalar_t,integer_t>;
using VI_t = std::vector<std::size_t>;
using VVS_t = std::vector<std::vector<scalar_t>>;
Expand Down
2 changes: 1 addition & 1 deletion src/BLR/BLRMatrix.GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "BLRBatch.hpp"

#include "dense/GPUWrapper.hpp"
#include "sparse/fronts/FrontalMatrixGPUKernels.hpp"
#include "sparse/fronts/FrontGPUKernels.hpp" // for replace_pivots

namespace strumpack {
namespace BLR {
Expand Down
5 changes: 1 addition & 4 deletions src/BLR/BLRMatrixMPI.GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
#include "BLRTileBLAS.hpp"
#include "BLRBatch.hpp"
#include "dense/GPUWrapper.hpp"

// TODO why include this?
#include "sparse/fronts/FrontalMatrixGPUKernels.hpp"

#include "sparse/fronts/FrontGPUKernels.hpp" // for replace_pivots

namespace strumpack {
namespace BLR {
Expand Down
20 changes: 20 additions & 0 deletions src/dense/GPUWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,31 @@

#include <memory>
#include "DenseMatrix.hpp"
#include "sparse/fronts/FrontGPUStructs.hpp"

namespace strumpack {
namespace gpu {
#if defined(STRUMPACK_USE_GPU)

// constexpr
inline int align_max_struct() {
auto m = sizeof(std::complex<double>);
m = std::max(m, sizeof(gpu::FrontData<std::complex<double>>));
m = std::max(m, sizeof(gpu::AssembleData<std::complex<double>>));
m = std::max(m, sizeof(Triplet<std::complex<double>>));
int k = 16;
while (k < int(m)) k *= 2;
return k;
}

inline std::size_t round_up(std::size_t n) {
int k = align_max_struct();
return std::size_t((n + k - 1) / k) * k;
}
template<typename T> T* aligned_ptr(void* p) {
return (T*)(round_up(uintptr_t(p)));
}

class Stream {
public:
Stream();
Expand Down
6 changes: 3 additions & 3 deletions src/sparse/EliminationTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "EliminationTree.hpp"
#include "fronts/FrontFactory.hpp"
#include "fronts/FrontalMatrix.hpp"
#include "fronts/Front.hpp"
#include "SeparatorTree.hpp"

namespace strumpack {
Expand All @@ -51,7 +51,7 @@ namespace strumpack {
EliminationTree<scalar_t,integer_t>::~EliminationTree() {}

template<typename scalar_t,typename integer_t>
FrontalMatrix<scalar_t,integer_t>*
Front<scalar_t,integer_t>*
EliminationTree<scalar_t,integer_t>::root() const {
return root_.get();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace strumpack {
}

template<typename scalar_t,typename integer_t>
std::unique_ptr<FrontalMatrix<scalar_t,integer_t>>
std::unique_ptr<Front<scalar_t,integer_t>>
EliminationTree<scalar_t,integer_t>::setup_tree
(const SPOptions<scalar_t>& opts, const SpMat_t& A,
SeparatorTree<integer_t>& sep_tree,
Expand Down
4 changes: 2 additions & 2 deletions src/sparse/EliminationTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@

namespace strumpack {

template<typename scalar_t,typename integer_t> class FrontalMatrix;
template<typename scalar_t,typename integer_t> class Front;
template<typename integer_t> class SeparatorTree;

// TODO rename this to SuperNodalTree?
template<typename scalar_t,typename integer_t>
class EliminationTree {
using SpMat_t = CompressedSparseMatrix<scalar_t,integer_t>;
using DenseM_t = DenseMatrix<scalar_t>;
using F_t = FrontalMatrix<scalar_t,integer_t>;
using F_t = Front<scalar_t,integer_t>;

public:
EliminationTree() {}
Expand Down
2 changes: 1 addition & 1 deletion src/sparse/EliminationTreeMPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "ordering/MatrixReorderingMPI.hpp"
#include "dense/DistributedMatrix.hpp"
#include "fronts/FrontFactory.hpp"
#include "fronts/FrontalMatrixMPI.hpp"
#include "fronts/FrontMPI.hpp"

namespace strumpack {

Expand Down
2 changes: 1 addition & 1 deletion src/sparse/EliminationTreeMPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace strumpack {
using DistM_t = DistributedMatrix<scalar_t>;
using DenseM_t = DenseMatrix<scalar_t>;
using DenseMW_t = DenseMatrixWrapper<scalar_t>;
using F_t = FrontalMatrix<scalar_t,integer_t>;
using F_t = Front<scalar_t,integer_t>;
using SepRange = std::pair<integer_t,integer_t>;

public:
Expand Down
8 changes: 4 additions & 4 deletions src/sparse/EliminationTreeMPIDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "PropMapSparseMatrix.hpp"
#include "ordering/MatrixReorderingMPI.hpp"
#include "fronts/FrontFactory.hpp"
#include "fronts/FrontalMatrix.hpp"
#include "fronts/FrontalMatrixMPI.hpp"
#include "fronts/Front.hpp"
#include "fronts/FrontMPI.hpp"

namespace strumpack {

Expand Down Expand Up @@ -628,7 +628,7 @@ namespace strumpack {


template<typename scalar_t,typename integer_t>
std::unique_ptr<FrontalMatrix<scalar_t,integer_t>>
std::unique_ptr<Front<scalar_t,integer_t>>
EliminationTreeMPIDist<scalar_t,integer_t>::prop_map
(const Opts_t& opts, std::vector<std::vector<integer_t>>& local_upd,
std::vector<float>& local_subtree_work,
Expand Down Expand Up @@ -699,7 +699,7 @@ namespace strumpack {
* [P0_sib,P0_sib+P_sib)
*/
template<typename scalar_t,typename integer_t>
std::unique_ptr<FrontalMatrix<scalar_t,integer_t>>
std::unique_ptr<Front<scalar_t,integer_t>>
EliminationTreeMPIDist<scalar_t,integer_t>::prop_map_sub_graphs
(const Opts_t& opts, const RedistSubTree<integer_t>& tree,
int P0, int P, int P0_sib, int P_sib, const MPIComm& fcomm, int level) {
Expand Down
6 changes: 3 additions & 3 deletions src/sparse/EliminationTreeMPIDist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace strumpack {

// forward declarations
template<typename scalar_t,typename integer_t> class MatrixReorderingMPI;
template<typename scalar_t,typename integer_t> class FrontalMatrixMPI;
template<typename scalar_t,typename integer_t> class FrontMPI;
template<typename scalar_t,typename integer_t> class CSRMatrixMPI;
template<typename integer_t> class RedistSubTree;

Expand All @@ -48,8 +48,8 @@ namespace strumpack {
public EliminationTreeMPI<scalar_t,integer_t> {
using DenseM_t = DenseMatrix<scalar_t>;
using DenseMW_t = DenseMatrixWrapper<scalar_t>;
using F_t = FrontalMatrix<scalar_t,integer_t>;
using FMPI_t = FrontalMatrixMPI<scalar_t,integer_t>;
using F_t = Front<scalar_t,integer_t>;
using FMPI_t = FrontMPI<scalar_t,integer_t>;
using DistM_t = DistributedMatrix<scalar_t>;
using Opts_t = SPOptions<scalar_t>;
using SepRange = std::pair<integer_t,integer_t>;
Expand Down
30 changes: 15 additions & 15 deletions src/sparse/fronts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
target_sources(strumpack
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixHIP.hip
${CMAKE_CURRENT_LIST_DIR}/FrontHIP.hip
${CMAKE_CURRENT_LIST_DIR}/FrontFactory.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrix.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixDense.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixDense.hpp
${CMAKE_CURRENT_LIST_DIR}/Front.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontDense.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontDense.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontHSS.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontHSS.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontBLR.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontBLR.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontFactory.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrix.hpp)
${CMAKE_CURRENT_LIST_DIR}/Front.hpp)

install(FILES
FrontFactory.hpp
Expand All @@ -19,10 +19,10 @@ install(FILES
if(STRUMPACK_USE_MPI)
target_sources(strumpack
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixMPI.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixMPI.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixDenseMPI.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixDenseMPI.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontMPI.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontMPI.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontDenseMPI.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontDenseMPI.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontHSSMPI.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontHSSMPI.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontBLRMPI.cpp
Expand All @@ -34,10 +34,10 @@ endif()
if(STRUMPACK_USE_CUDA OR STRUMPACK_USE_HIP OR STRUMPACK_USE_SYCL)
target_sources(strumpack
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixGPU.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixGPU.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixGPUKernels.hpp)

${CMAKE_CURRENT_LIST_DIR}/FrontGPU.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontGPU.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontGPUKernels.hpp
${CMAKE_CURRENT_LIST_DIR}/FrontGPUStructs.hpp)
endif()

if(STRUMPACK_USE_MAGMA)
Expand All @@ -48,15 +48,15 @@ endif()

if(STRUMPACK_USE_CUDA)
target_sources(strumpack PRIVATE
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixCUDA.cu
${CMAKE_CURRENT_LIST_DIR}/FrontCUDA.cu
${CMAKE_CURRENT_LIST_DIR}/FrontGPUSPD.cu
${CMAKE_CURRENT_LIST_DIR}/FrontGPUSPD.cpp
${CMAKE_CURRENT_LIST_DIR}/FrontGPUSPD.hpp)
endif()

if(STRUMPACK_USE_SYCL)
target_sources(strumpack PRIVATE
${CMAKE_CURRENT_LIST_DIR}/FrontalMatrixSYCL.cpp)
${CMAKE_CURRENT_LIST_DIR}/FrontSYCL.cpp)
endif()

if(STRUMPACK_USE_ZFP OR STRUMPACK_USE_SZ3)
Expand Down
4 changes: 2 additions & 2 deletions src/sparse/fronts/ExtendAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/

#include "ExtendAdd.hpp"
#include "FrontalMatrix.hpp"
#include "FrontalMatrixMPI.hpp"
#include "Front.hpp"
#include "FrontMPI.hpp"
#include "BLR/BLRMatrixMPI.hpp"

#include "sparse/CompressedSparseMatrix.hpp"
Expand Down
8 changes: 4 additions & 4 deletions src/sparse/fronts/ExtendAdd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
namespace strumpack {

// forward declarations
template<typename scalar_t,typename integer_t> class FrontalMatrix;
template<typename scalar_t,typename integer_t> class FrontalMatrixMPI;
template<typename scalar_t,typename integer_t> class Front;
template<typename scalar_t,typename integer_t> class FrontMPI;
namespace BLR {
template<typename scalar_t> class BLRMatrixMPI;
}
Expand All @@ -45,8 +45,8 @@ namespace strumpack {
using DenseM_t = DenseMatrix<scalar_t>;
using DistM_t = DistributedMatrix<scalar_t>;
using BLRMPI_t = BLR::BLRMatrixMPI<scalar_t>;
using F_t = FrontalMatrix<scalar_t,integer_t>;
using FMPI_t = FrontalMatrixMPI<scalar_t,integer_t>;
using F_t = Front<scalar_t,integer_t>;
using FMPI_t = FrontMPI<scalar_t,integer_t>;
using VI_t = std::vector<std::size_t>;
using VVS_t = std::vector<std::vector<scalar_t>>;

Expand Down
Loading

0 comments on commit 44cc00b

Please sign in to comment.