Skip to content

Commit

Permalink
fixed test drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
flopez committed May 9, 2020
1 parent 4d0c88a commit 50dcda1
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 378 deletions.
29 changes: 29 additions & 0 deletions include/sylver/NumericFrontBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,35 @@ namespace sylver {

starpu_data_unregister_submit(contrib_hdl_);
}

// TODO: test routine
void register_contrib_blocks() {

int m = this->nrow();
int n = this->ncol();
int ldcontrib = m-n;
int blksz = this->blksz();
// Number of block rows
int nr = this->nr();

// Allocate and init handles in contribution blocks
if (ldcontrib>0 && this->contrib_blocks.size()>0) {
// Index of first block in contrib
int rsa = n/blksz;
// Number of block in contrib
int ncontrib = nr-rsa;

for(int j = rsa; j < nr; j++) {
for(int i = j; i < nr; i++) {
// Register block in StarPU
// front.contrib_blocks[(i-rsa)+(j-rsa)*ncontrib].register_handle();
this->contrib_block(i, j).register_handle();
}
}
}

}

#endif

// Return associated symbolic node
Expand Down
116 changes: 116 additions & 0 deletions src/NumericFront.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public:
// (delays are set when they are imported from children)
this->perm = FAIntTraits::allocate(factor_alloc_int, this->ncol()); // ncol fully summed variables
// Set permuatation array
assert(this->symb().rlist);
for(int i=0; i< this->symb().ncol; i++) {
this->perm[i] = this->symb().rlist[i];
}
Expand Down Expand Up @@ -177,6 +178,121 @@ public:
err = this->alloc_blocks(); // FIXME specialize for posdef case
sylver::sylver_check_error(err, context, "Failed to allocate blocks");
}

#if defined(SPLDLT_USE_STARPU)
// TODO: test routine
void register_node() {

using ValueType = T;

auto& sfront = this->symb();
int blksz = this->blksz();
int m = this->nrow();
int n = this->ncol();
ValueType *a = this->lcol;
int lda = spral::ssids::cpu::align_lda<ValueType>(m);
int nr = this->nr(); // number of block rows
int nc = this->nc(); // number of block columns
auto& cdata = *this->cdata;

// Block diagonal matrix
ValueType *d = &a[n*lda];

// FIXME: DO we still need these handles?
sfront.handles.resize(nr*nc); // allocate handles

for(int j = 0; j < nc; ++j) {

int blkn = std::min(blksz, n - j*blksz);

// Register cdata for APP factorization.
// FIXME: Only if pivot_method is APP
cdata[j].register_handle(); // Symbolic handle on column j
cdata[j].register_d_hdl(d, 2*std::min((j+1)*blksz, n)); // Handle on diagonal D
// cdata[j].register_d_hdl(d, 2*n); // Handle on diagonal D

for(int i = j; i < nr; ++i) {
int blkm = std::min(blksz, m - i*blksz);

// TODO remove sfront.handles registration for indef case
starpu_matrix_data_register(
&(sfront.handles[i + j*nr]), // StarPU handle ptr
STARPU_MAIN_RAM, // memory
reinterpret_cast<uintptr_t>(&a[(j*blksz)*lda+(i*blksz)]),
lda, blkm, blkn,
sizeof(ValueType));

// Register StarPU handle for block (i,j)
this->blocks[j*nr+i].register_handle();
}
}

// Register blocks in contribution block
this->register_contrib_blocks();

}

// TODO: move to a new structure NumericFrontPosdef
// TODO: est routine
void register_node_posdef() {

using ValueType = T;

auto& sfront = this->symb();
int blksz = this->blksz();

int const m = this->nrow();
int const n = this->ncol();
ValueType *a = this->lcol;
int const lda = this->ldl();
int const nr = this->nr(); // number of block rows
int const nc = this->nc(); // number of block columns
// sfront.handles.reserve(nr*nc);
sfront.handles.resize(nr*nc); // Allocate handles

for(int j = 0; j < nc; ++j) {
int blkn = std::min(blksz, n - j*blksz);

for(int i = j; i < nr; ++i) {
int blkm = std::min(blksz, m - i*blksz);

// TODO: remove the following register and test
starpu_matrix_data_register(
&(sfront.handles[i + j*nr]), // StarPU handle ptr
STARPU_MAIN_RAM, // memory
reinterpret_cast<uintptr_t>(&a[(j*blksz)*lda+(i*blksz)]),
lda, blkm, blkn,
sizeof(ValueType));

// Register StarPU handle for block (i,j)
this->blocks[j*nr+i].register_handle();

}
}

// Register blocks in contribution block
this->register_contrib_blocks();

}
#endif

/// @brief Activate front: allocate meemory associated with factors and
/// contrib block. Register data handles in StarPU.
void activate(void** child_contrib) {
this->allocate(child_contrib);
#if defined(SPLDLT_USE_STARPU)
this->register_node();
#endif
}

/// @brief Activate front posdef: allocate meemory associated with
/// factors and contrib block. Register data handles in StarPU.
void activate_posdef() {
this->allocate_posdef();
#if defined(SPLDLT_USE_STARPU)
this->register_node_posdef();
#endif
}

/// \brief Allocate block structures and memory space for
/// contrib (below diagonal)
Expand Down
5 changes: 3 additions & 2 deletions src/NumericTreePosdef.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ namespace spldlt {
if (sfront.is_in_subtree()) continue;

// Activate frontal matrix
activate_front(true, front, child_contrib, factor_alloc_);

// activate_front(true, front, child_contrib, factor_alloc_);
front.activate_posdef();

// Initialize frontal matrix
// init_node(sfront, fronts_[ni], aval); // debug
init_node_task(front, aval, scaling, sylver::spldlt::INIT_PRIO);
Expand Down
15 changes: 12 additions & 3 deletions src/StarPU/kernels.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,12 @@ namespace starpu {
cl_arg, &posdef, &snode, &node, &child_contrib, &blksz,
&factor_alloc);

activate_front(posdef, *node, child_contrib, *factor_alloc);
if (posdef) {
node->activate_posdef();
}
else {
node->activate(child_contrib);
}

}

Expand Down Expand Up @@ -874,8 +879,12 @@ namespace starpu {
&factor_alloc, &pool_alloc, &aval, &scaling);

// Allocate data structures
activate_front(
posdef, *node, child_contrib, *factor_alloc);
if (posdef) {
node->activate_posdef();
}
else {
node->activate(child_contrib);
}

// Add coefficients from original matrix
init_node(*node, aval, scaling);
Expand Down

0 comments on commit 50dcda1

Please sign in to comment.