Skip to content

Commit

Permalink
code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
flopez committed May 8, 2020
1 parent c3cdcb5 commit 7d7a8da
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 174 deletions.
76 changes: 76 additions & 0 deletions include/sylver/SymbolicTree.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#pragma once

#include <cstdio>
#include <vector>

#include "ssids/cpu/cpu_iface.hxx"
// #include "ssids/cpu/SymbolicNode.hxx"

#include "sylver/SymbolicFront.hxx"

// using namespace spral::ssids::cpu;

namespace sylver {

class SymbolicTree {
public:
SymbolicTree(
void* akeep, int n, int nnodes, int const* sptr, int const* sparent,
long const* rptr, int const* rlist, long const* nptr, long const* nlist,
int nsubtrees, int const* subtrees, int const* small, int const* contrib_dest,
int const* exec_loc); // FIXME exec_loc and small are redundent
// int nparts, int const* part, int const* contrib_idx, int const* exec_loc,
// int const* contrib_dest)

SymbolicFront& operator[](int idx) {
return fronts_[idx];
}

SymbolicFront const& operator[](int idx) const {
return fronts_[idx];
}

size_t get_factor_mem_est(double multiplier) const {
size_t mem = n*sizeof(int) + (2*n+nfactor_)*sizeof(double);
return std::max(mem, static_cast<size_t>(mem*multiplier));
}

template <typename T>
size_t get_pool_size() const {
return maxfront_*spral::ssids::cpu::align_lda<T>(maxfront_);
}

/// @brief Return the number of nodes in the assembly tree
inline int nnodes() const {
return nnodes_;
}

/// @brief Return the number of subtrees in the assembly tree
inline int nsubtrees() const {
return nsubtrees_;
}

/// @brief Return akeep structure
inline void* akeep() const {
return akeep_;
}

inline int const* subtrees() const {
return subtrees_;
}

public:
int const n; //< Maximum row index
private:
void* akeep_;
int nnodes_;
size_t nfactor_;
size_t maxfront_;
// int nparts_;
// int const* part_;
int nsubtrees_;
int const* subtrees_;
std::vector<SymbolicFront> fronts_;
};

} /* end of namespace sylver */
4 changes: 3 additions & 1 deletion src/NumericTree.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "sylver_ciface.hxx"
#include "kernels/ldlt_app.hxx"
#include "BuddyAllocator.hxx"
#include "SymbolicTree.hxx"
#include "NumericFront.hxx"
#include "factor.hxx"
#include "factor_indef.hxx"
Expand All @@ -19,9 +18,12 @@
#if defined(SPLDLT_USE_STARPU)
#include "StarPU/codelets.hxx"
#endif
#include "sylver/SymbolicTree.hxx"

// STD
#include <vector>
#include <chrono>

// SSIDS
// #include "ssids/cpu/cpu_iface.hxx"
#include "ssids/cpu/kernels/cholesky.hxx"
Expand Down
2 changes: 1 addition & 1 deletion src/NumericTreePosdef.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include "BuddyAllocator.hxx"
#include "factor.hxx"
#include "NumericFront.hxx"
#include "SymbolicTree.hxx"
#if defined(SPLDLT_USE_STARPU)
#include "StarPU/codelets_posdef.hxx"
#endif
#include "sylver_ciface.hxx"
#include "tasks/assemble_block.hxx"
#include "tasks/tasks.hxx"
#include "sylver/SymbolicTree.hxx"

#include <cstddef>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/NumericTreeUnsym.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// SyLVER
#include "BuddyAllocator.hxx"
#include "sylver_ciface.hxx"
#include "SymbolicTree.hxx"
#include "NumericFrontUnsym.hxx"
#include "tasks/unsym.hxx"
#include "sylver/SymbolicFront.hxx"
#include "sylver/SymbolicTree.hxx"

// STD
#include <stdexcept>
Expand Down
107 changes: 104 additions & 3 deletions src/SymbolicTree.cxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,109 @@
#include "SymbolicTree.hxx"
#include "sylver/SymbolicTree.hxx"

// #include "ssids/cpu/SymbolicSubtree.hxx"

using namespace sylver;
namespace sylver {

SymbolicTree::SymbolicTree(
void* akeep, int n, int nnodes, int const* sptr, int const* sparent,
long const* rptr, int const* rlist, long const* nptr, long const* nlist,
int nsubtrees, int const* subtrees, int const* small, int const* contrib_dest,
int const* exec_loc) // FIXME exec_loc and small are redundent
// int nparts, int const* part, int const* contrib_idx, int const* exec_loc,
// int const* contrib_dest)
: akeep_(akeep), n(n), nnodes_(nnodes), fronts_(nnodes_+1),
nsubtrees_(nsubtrees), subtrees_(subtrees)
// nparts_(nparts), part_(part)
{
// printf("[SymbolicTree] nsubtrees = %d\n", nsubtrees);
// printf("[SymbolicTree] root parent = %d\n", sparent[nnodes_]-1);
for(int ni=0; ni<nnodes_; ++ni)
fronts_[ni].least_desc = ni;

maxfront_ = 0;
for(int ni=0; ni<nnodes_; ++ni) {
// SymbolicNode info
fronts_[ni].idx = ni; // Node index
fronts_[ni].nrow = static_cast<int>(rptr[ni+1] - rptr[ni]); // Number of rows
fronts_[ni].ncol = sptr[ni+1] - sptr[ni];
fronts_[ni].first_child = nullptr;
fronts_[ni].next_child = nullptr;
fronts_[ni].rlist = &rlist[rptr[ni]-1]; // rptr is Fortran indexed
fronts_[ni].num_a = nptr[ni+1] - nptr[ni];
fronts_[ni].amap = &nlist[2*(nptr[ni]-1)]; // nptr is Fortran indexed
fronts_[ni].parent = sparent[ni]-1; // sparent is Fortran indexed

maxfront_ = std::max(maxfront_, (size_t) fronts_[ni].nrow); // Number of columns

// // Setup useful info in supernodal mode
// // SymbolicSNode info
// nodes_[ni].sa = sptr[ni];
// nodes_[ni].en = sptr[ni+1]-1;

// Setup least_desc for easily traverse subtrees
fronts_[fronts_[ni].parent].least_desc = std::min(
fronts_[fronts_[ni].parent].least_desc,
fronts_[ni].least_desc);

}

/* Build child linked lists */
for(int ni=0; ni<nnodes_; ++ni) {
SymbolicFront *parent = &fronts_[ std::min(fronts_[ni].parent, nnodes_) ];
fronts_[ni].next_child = parent->first_child;
parent->first_child = &fronts_[ni];
}

/* Record contribution block inputs */
// for(int ci = 0; ci < nparts; ++ci) {
for(int ci = 0; ci < nsubtrees; ++ci) {
int idx = contrib_dest[ci]-1; // contrib_dest is Fortran indexed
// printf("[SymbolicTree] %d -> %d, exec_loc = %d\n", ci+1, idx+1, exec_loc[ci]);
if (idx > 0) // idx equal to 0 means that ci is a root subtree
fronts_[idx].contrib.push_back(ci);
}

// count size of factors
nfactor_ = 0;
for(int ni=0; ni<nnodes_; ++ni)
nfactor_ += static_cast<size_t>(fronts_[ni].nrow)*fronts_[ni].ncol;

// printf("[SymbolicTree] num factors: %zu\n", nfactor_);

// Setup node partition and execution location information
// for(int p = 0; p < nparts; ++p) {
// printf("[SybolicSubtree] part = %d, contrib_idx = %d\n", p, contrib_idx[p]);
// for (int ni = part[p]-1; ni < part[p+1]-1; ++ni) {
// fronts_[ni].part = p;
// fronts_[ni].exec_loc = exec_loc[p];
// fronts_[ni].contrib_idx = contrib_idx[p]-1; // contrib_idx is Fortran indexed
// }
// }

// Setup node partition and execution location information
for(int ni=0; ni<nnodes_; ++ni) {
fronts_[ni].part = -1;
(small[ni] == 0) ?
fronts_[ni].exec_loc = -1 : fronts_[ni].exec_loc = 1;
}
for(int p = 0; p < nsubtrees; ++p) {
int idx = subtrees[p]-1; // subtrees is Fortran indexed
fronts_[idx].part = p;
fronts_[idx].contrib_idx = p;
// #if defined(SPLDLT_USE_STARPU) && defined(SPLDLT_USE_OMP)
#if defined(SPLDLT_USE_STARPU)
fronts_[idx].exec_loc = exec_loc[p];
#endif
}

// Init symbolic root
fronts_[nnodes_].idx = nnodes_;
fronts_[nnodes_].exec_loc = -1;
}

}

// using namespace sylver;
// using namespace spral::ssids::cpu;

extern "C"
Expand All @@ -29,7 +130,7 @@ void *spldlt_create_symbolic_tree(
// NULL, *options
// );

return (void *) new SymbolicTree(
return (void *) new sylver::SymbolicTree(
akeep, n, nnodes, sptr, sparent, rptr, rlist, nptr, nlist,
nsubtrees, subtrees, small, contrib_dest, exec_loc);

Expand Down

0 comments on commit 7d7a8da

Please sign in to comment.