23 #include <starpu_data.h>
26 pastix_starpu_filter_interface(
void *father_interface,
27 void *child_interface,
28 struct starpu_data_filter *f,
34 size_t *sizetab = (
size_t *)f->filter_arg_ptr;
38 assert( father->
offset == -1 );
41 child->
id = father->
id;
43 child->
offset = sizetab[id];
44 child->
nbblok = sizetab[
id+1] - sizetab[id];
49 assert( child->
offset >= 0 );
51 if ( father->
dataptr == NULL ) {
67 for ( i=0; i<child->
nbblok; i++, blok++) {
77 #if defined(PASTIX_STARPU_INTERFACE_DEBUG)
79 "blok (%9s, size=%8ld, nbblok=%2ld )\n",
80 child->
cblk->
cblktype & CBLK_COMPRESSED ?
"Low-rank" :
"Full-rank",
98 starpu_data_handle_t *handler = ( (starpu_data_handle_t *)( cblk->
handler ) ) + side;
99 int64_t tag_cblk = 2 * cblk->
gcblknum + side;
101 if ( cblk->
ownerid == myrank ) {
108 #if defined( PASTIX_WITH_MPI )
109 starpu_mpi_data_register( *handler, spmtx->
mpitag + tag_cblk, cblk->
ownerid );
121 pastix_starpu_register_interface( spmtx, cblk, myrank,
PastixLCoef, flttype );
123 pastix_starpu_register_interface( spmtx, cblk, myrank,
PastixUCoef, flttype );
165 pastix_int_t cblknbr, cblkmin2d;
169 pastix_int_t n = 0, cblknum;
173 #if defined( PASTIX_WITH_MPI )
178 if ( spmtx != NULL ) {
185 tag_desc = ( solvmtx->gcblknbr + solvmtx->bloknbr ) * 2;
186 spmtx->
mpitag = pastix_starpu_tag_book( tag_desc );
187 tag_desc = spmtx->
mpitag + 2 * solvmtx->gcblknbr;
188 spmtx->
typesze = pastix_size_of( flttype );
194 cblknbr = solvmtx->cblknbr;
195 cblkmin2d = solvmtx->cblkmin2d;
199 cblk = spmtx->
solvmtx->cblktab;
200 for ( cblknum = 0; cblknum < cblkmin2d; cblknum++, n++, cblk++ ) {
201 pastix_starpu_register_cblk( spmtx, cblk, myrank, flttype );
205 if ( cblkmin2d < cblknbr ) {
206 struct starpu_data_filter filter = { .filter_func = pastix_starpu_filter_interface };
208 size_t *sizetab = NULL;
209 pastix_int_t nchildren, sizenbr = 0;
214 cblk = spmtx->
solvmtx->cblktab + cblkmin2d;
218 sizetab = malloc( sizenbr *
sizeof(
size_t ) );
219 assert( sizenbr >= 1 );
221 for ( cblknum = cblkmin2d, n = 0; cblknum < cblknbr;
222 cblknum++, n++, cblk++, cblkhandle++ ) {
223 pastix_starpu_register_cblk( spmtx, cblk, myrank, flttype );
225 if ( !( cblk->cblktype & CBLK_TASKS_2D ) ) {
230 blok = cblk[0].fblokptr;
231 lblok = cblk[1].fblokptr;
233 if ( ( lblok - blok ) >= sizenbr ) {
234 sizenbr = ( lblok - blok ) + 1;
236 sizetab = malloc( sizenbr *
sizeof(
size_t ) );
244 sizetab[nchildren + 1] = 1;
251 for ( ; blok < lblok; blok++ ) {
254 while ( ( blok + 1 < lblok ) &&
255 ( blok[0].fcblknm == blok[1].fcblknm ) &&
256 ( blok[0].lcblknm == blok[1].lcblknm ) )
263 sizetab[nchildren + 1] = sizetab[nchildren] + size;
266 filter.nchildren = nchildren;
267 filter.filter_arg_ptr = sizetab;
271 cblkhandle->
handletab = (starpu_data_handle_t *)malloc(
272 2 * nchildren *
sizeof( starpu_data_handle_t ) );
274 starpu_data_partition_plan( cblk->handler[0], &filter, cblkhandle->
handletab );
276 starpu_data_partition_plan(
277 cblk->handler[1], &filter, cblkhandle->
handletab + nchildren );
281 (starpu_data_handle_t *)malloc( nchildren *
sizeof( starpu_data_handle_t ) );
283 starpu_data_partition_plan( cblk->handler[0], &filter, cblkhandle->
handletab );
287 blok = cblk[0].fblokptr;
288 lblok = cblk[1].fblokptr;
294 #if defined( PASTIX_WITH_MPI )
295 tag = tag_desc + 2 * ( blok - solvmtx->bloktab );
296 starpu_mpi_data_register( blok->
handler[0], tag, cblk->ownerid );
300 #if defined( PASTIX_WITH_MPI )
301 tag = tag_desc + 2 * ( blok - solvmtx->bloktab ) + 1;
302 starpu_mpi_data_register( blok->
handler[1], tag, cblk->ownerid );
314 for ( ; blok < lblok; blok++ ) {
316 #if defined( PASTIX_WITH_MPI )
317 tag = tag_desc + 2 * ( blok - solvmtx->bloktab );
318 starpu_mpi_data_register( blok->
handler[0], tag, cblk->ownerid );
322 #if defined( PASTIX_WITH_MPI )
323 tag = tag_desc + 2 * ( blok - solvmtx->bloktab ) + 1;
324 starpu_mpi_data_register( blok->
handler[1], tag, cblk->ownerid );
332 while ( ( blok < lblok ) && ( blok[0].fcblknm == blok[1].fcblknm ) &&
333 ( blok[0].lcblknm == blok[1].lcblknm ) ) {
341 if ( sizetab != NULL ) {
345 solvmtx->starpu_desc = spmtx;
371 cblk = spmtx->
solvmtx->cblktab;
372 for ( i = 0; i < spmtx->
solvmtx->cblknbr; i++, cblk++ ) {
375 #if defined( PASTIX_WITH_MPI )
376 starpu_mpi_cache_flush( spmtx->
solvmtx->solv_comm, cblk->
handler[0] );
379 starpu_data_acquire_cb( cblk->
handler[0],
381 (
void( * )(
void * ) ) & starpu_data_release,
386 #if defined( PASTIX_WITH_MPI )
387 starpu_mpi_cache_flush( spmtx->
solvmtx->solv_comm, cblk->
handler[1] );
390 starpu_data_acquire_cb( cblk->
handler[1],
392 (
void( * )(
void * ) ) & starpu_data_release,
418 pastix_int_t i, cblkmin2d;
420 cblkmin2d = spmtx->
solvmtx->cblkmin2d;
421 cblk = spmtx->
solvmtx->cblktab;
422 for ( i = 0; i < cblkmin2d; i++, cblk++ ) {
424 starpu_data_unregister( cblk->
handler[0] );
427 starpu_data_unregister( cblk->
handler[1] );
436 for ( i = cblkmin2d; i < spmtx->
solvmtx->cblknbr; i++, cblk++, cblkhandle++ ) {
437 if ( cblk->cblktype & CBLK_TASKS_2D ) {
438 if ( cblk->handler[0] ) {
439 starpu_data_partition_clean(
442 if ( cblk->handler[1] ) {
443 starpu_data_partition_clean( cblk->handler[1],
451 if ( cblk->handler[0] ) {
452 starpu_data_unregister( cblk->handler[0] );
453 if ( cblk->handler[1] ) {
454 starpu_data_unregister( cblk->handler[1] );
458 cblk->handler[0] = NULL;
459 cblk->handler[1] = NULL;
466 pastix_starpu_tag_release( spmtx->
mpitag );
487 starpu_data_handle_t cblkhandle = cblk->
handler[side];
489 starpu_data_handle_t *blokhandles = starpu_cblk->
handletab + side * nsubparts;
491 starpu_data_partition_submit( cblkhandle, nsubparts, blokhandles );
514 starpu_data_handle_t cblkhandle = cblk->
handler[side];
516 starpu_data_handle_t *blokhandles =
519 #if defined( PASTIX_WITH_MPI )
522 for ( i = 0; i < nsubparts; i++ ) {
523 starpu_mpi_cache_flush( spmtx->
solvmtx->solv_comm, blokhandles[i] );
528 starpu_data_unpartition_submit( cblkhandle, nsubparts, blokhandles, STARPU_MAIN_RAM );
531 starpu_data_unpartition_submit( cblkhandle, nsubparts, blokhandles, -1 );