PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
pastix_starpu_interface.c
Go to the documentation of this file.
1/**
2 *
3 * @file pastix_starpu_interface.c
4 *
5 * Interface used by StarPU to handle factorization.
6 *
7 * @copyright 2021-2025 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author Nolan Bredel
12 * @author Mathieu Faverge
13 * @author Alycia Lisito
14 * @author Florent Pruvost
15 * @author Tom Moenne-Loccoz
16 * @date 2024-07-05
17 *
18 **/
19#include "common/common.h"
21#include "blend/solver.h"
26#include "pastix_starpu.h"
27
28#ifndef DOXYGEN_SHOULD_SKIP_THIS
29
30#if defined(PASTIX_STARPU_INTERFACE_DEBUG)
31#define pastix_starpu_logger fprintf( stderr, "pastix_starpu: %s\n", __func__ )
32#else
33#define pastix_starpu_logger do {} while(0)
34#endif
35
36static inline void
37psi_register_data_handle( starpu_data_handle_t handle, int home_node, void *data_interface )
38{
39 pastix_starpu_interface_t *interf = (pastix_starpu_interface_t *)data_interface;
40 int node;
41
42 pastix_starpu_logger;
43
44 for ( node = 0; node < STARPU_MAXNODES; node++ ) {
45 pastix_starpu_interface_t *local_interface =
46 (pastix_starpu_interface_t *)starpu_data_get_interface_on_node( handle, node );
47
48 memcpy( local_interface, interf, sizeof( pastix_starpu_interface_t ) );
49
50 if ( node != home_node ) {
51 local_interface->dataptr = NULL;
52 }
53 }
54}
55
56static inline starpu_ssize_t
57psi_allocate_data_on_node( void *data_interface, unsigned node )
58{
59 pastix_starpu_interface_t *interf = (pastix_starpu_interface_t *)data_interface;
60 starpu_ssize_t allocated_memory;
61 uintptr_t addr = 0;
62 uintptr_t handle;
63
64 pastix_starpu_logger;
65
66 allocated_memory = interf->allocsize;
67 if ( allocated_memory <= 0 ) {
68 return 0;
69 }
70
71 handle = starpu_malloc_on_node( node, allocated_memory );
72 if ( !handle ) {
73 return -ENOMEM;
74 }
75
76#if defined(PASTIX_DEBUG_STARPU)
77 {
78 const SolverCblk *cblk = interf->cblk;
79 if ( cblk->cblktype & CBLK_FANIN ) {
80 fprintf( stderr, "allocate fanin %d [%p](%ld)\n",
81 cblk->gfaninnum, (void*)handle, allocated_memory );
82 }
83 if ( cblk->cblktype & CBLK_RECV ) {
84 fprintf( stderr, "allocate recv %d [%p](%ld)\n",
85 cblk->gfaninnum, (void*)handle, allocated_memory );
86 }
87 }
88#endif
89
90 if ( starpu_node_get_kind( node ) != STARPU_OPENCL_RAM ) {
91 addr = handle;
92 }
93
94 /* update the data properly */
95 interf->dataptr = (void *)addr;
96
97 /* /\* Allocate the workspace for the low-rank blocks *\/ */
98 /* if ( interf->cblk->cblktype & CBLK_COMPRESSED ) */
99 /* { */
100 /* SolverBlok *blok = interf->cblk->fblokptr; */
101 /* pastix_lrblock_t *LRblock = interf->dataptr; */
102 /* int offset = pastix_imax( 0, interf->offset ); */
103 /* int i, ncols, M; */
104
105 /* assert( node == STARPU_MAIN_RAM ); */
106
107 /* ncols = cblk_colnbr( interf->cblk ); */
108 /* blok += offset; */
109 /* for ( i = 0; i < interf->nbblok; i++, blok++, LRblock++ ) { */
110 /* M = blok_rownbr( blok ); */
111
112 /* /\* Allocate the LR block to its max space *\/ */
113 /* switch ( interf->flttype ) { */
114 /* case PastixComplex64: */
115 /* core_zlralloc( M, ncols, -1, LRblock ); */
116 /* break; */
117 /* case PastixComplex32: */
118 /* core_clralloc( M, ncols, -1, LRblock ); */
119 /* break; */
120 /* case PastixDouble: */
121 /* core_dlralloc( M, ncols, -1, LRblock ); */
122 /* break; */
123 /* case PastixFloat: */
124 /* core_slralloc( M, ncols, -1, LRblock ); */
125 /* break; */
126 /* default: */
127 /* assert( 0 ); */
128 /* } */
129 /* } */
130 /* } */
131
132 return allocated_memory;
133}
134
135static inline void
136psi_free_data_on_node( void *data_interface, unsigned node )
137{
138 pastix_starpu_interface_t *interf = (pastix_starpu_interface_t *)data_interface;
139
140 /* SolverCblk *cblk = interf->cblk; */
141
142 pastix_starpu_logger;
143
144 starpu_free_on_node( node, (uintptr_t)interf->dataptr, interf->allocsize );
145
146 interf->dataptr = NULL;
147}
148
149static inline void
150psi_init( void *data_interface )
151{
152 pastix_starpu_interface_t *interf = data_interface;
154 interf->allocsize = -1;
155
156 pastix_starpu_logger;
157}
158
159static inline void *
160psi_to_pointer( void *data_interface, unsigned node )
161{
162 (void)node;
163 pastix_starpu_interface_t *interf = (pastix_starpu_interface_t *)data_interface;
164
165 pastix_starpu_logger;
166
167 return interf->dataptr;
168}
169
170static inline size_t
171psi_get_size( starpu_data_handle_t handle )
172{
174 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
175 const SolverCblk *cblk = interf->cblk;
176 pastix_int_t ncols = cblk_colnbr( cblk );
177 size_t nrows;
178 size_t size;
179
180 if ( interf->offset == -1 ) {
181 nrows = cblk->stride;
182 }
183 else {
184 SolverBlok *fblok = interf->cblk->fblokptr + interf->offset;
185 SolverBlok *lblok = fblok + interf->nbblok;
186
187 nrows = 0;
188 for( ; fblok < lblok; fblok++ ) {
189 nrows += blok_rownbr( fblok );
190 }
191 }
192
193 size = ncols * nrows;
194
195#ifdef STARPU_DEBUG
196 STARPU_ASSERT_MSG( interf->id == PASTIX_STARPU_INTERFACE_ID,
197 "psi_get_size: The given data is not a pastix interface for starpu." );
198#endif
199
200 return size;
201}
202
203static inline size_t
204psi_get_alloc_size( starpu_data_handle_t handle )
205{
207 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
208
209 pastix_starpu_logger;
210
211#ifdef STARPU_DEBUG
212 STARPU_ASSERT_MSG( interf->id == PASTIX_STARPU_INTERFACE_ID,
213 "psi_get_alloc_size: The given data is not a pastix interface for starpu." );
214#endif
215
216 STARPU_ASSERT_MSG( interf->allocsize != (size_t)-1,
217 "psi_get_alloc_size: The allocation size needs to be defined" );
218
219 return interf->allocsize;
220}
221
222static inline uint32_t
223psi_footprint( starpu_data_handle_t handle )
224{
226 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
227 const SolverCblk *cblk = interf->cblk;
228
229 pastix_starpu_logger;
230
231 return starpu_hash_crc32c_be( cblk->gcblknum, interf->offset + 1 );
232}
233
234static inline uint32_t
235psi_alloc_footprint( starpu_data_handle_t handle )
236{
238 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
239
240 pastix_starpu_logger;
241
242 return starpu_hash_crc32c_be( interf->allocsize, 0 );
243}
244
245static inline int
246psi_compare( void *data_interface_a, void *data_interface_b )
247{
248 pastix_starpu_interface_t *pastix_interface_a = (pastix_starpu_interface_t *)data_interface_a;
249 pastix_starpu_interface_t *pastix_interface_b = (pastix_starpu_interface_t *)data_interface_b;
250
251 const SolverCblk *solva = pastix_interface_a->cblk;
252 const SolverCblk *solvb = pastix_interface_b->cblk;
253
254 pastix_starpu_logger;
255
256 /* Two interfaces are considered compatible if they point to the same solver */
257 return ( solva == solvb );
258}
259
260static inline int
261psi_alloc_compare( void *data_interface_a, void *data_interface_b )
262{
263 pastix_starpu_interface_t *pastix_interface_a = (pastix_starpu_interface_t *)data_interface_a;
264 pastix_starpu_interface_t *pastix_interface_b = (pastix_starpu_interface_t *)data_interface_b;
265
266 pastix_starpu_logger;
267
268 /* Two matrices are considered compatible if they have the same allocated size */
269 return ( pastix_interface_a->allocsize == pastix_interface_b->allocsize );
270}
271
272static inline void
273psi_display( starpu_data_handle_t handle, FILE *f )
274{
276 (pastix_starpu_interface_t *)starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
277
278 const SolverCblk *cblk = interf->cblk;
279
280 pastix_starpu_logger;
281
282 if ( interf->offset == -1 ) {
283 fprintf( f, "Cblk%ld", (long)( cblk->gcblknum ) );
284 }
285 else {
286 fprintf( f, "Cblk%ldBlok%ld", (long)( cblk->gcblknum ), (long)( interf->offset ) );
287 }
288}
289
290static inline size_t
291psi_compute_size_lr( pastix_starpu_interface_t *interf )
292{
293 assert( interf->cblk->cblktype & CBLK_COMPRESSED );
294
295 size_t elemsize = pastix_size_of( interf->flttype );
296 pastix_lrblock_t *LRblock = interf->dataptr;
297 pastix_int_t N = cblk_colnbr( interf->cblk );
298 pastix_int_t suv, M;
299
300 SolverBlok *blok = interf->cblk->fblokptr + pastix_imax( 0, interf->offset );
301
302 pastix_starpu_logger;
303
304 suv = 0;
305 int i;
306 for ( i = 0; i < interf->nbblok; i++, blok++, LRblock++ ) {
307 M = blok_rownbr( blok );
308 suv += sizeof( int ) + core_zlrgetsize( M, N, LRblock ) * elemsize;
309 }
310 return suv;
311}
312
313static inline size_t
314psi_compute_size_fr( pastix_starpu_interface_t *interf )
315{
316 assert( !( interf->cblk->cblktype & CBLK_COMPRESSED ) );
317
318 pastix_starpu_logger;
319
320 return interf->allocsize;
321}
322
323static inline void
324psi_pack_lr( pastix_starpu_interface_t *interf, void **ptr )
325{
326 assert( interf->cblk->cblktype & CBLK_COMPRESSED );
327
328 char *tmp = *ptr;
329 pastix_lrblock_t *LRblock = interf->dataptr;
330 int N = cblk_colnbr( interf->cblk );
331 int j = 0;
332 int M;
333
334 SolverBlok *blok = interf->cblk->fblokptr + pastix_imax( 0, interf->offset );
335
336 pastix_starpu_logger;
337
338 for ( ; j < interf->nbblok; j++, blok++, LRblock++ ) {
339 M = blok_rownbr( blok );
340
341 switch ( interf->flttype ) {
342 case PastixComplex64:
343 tmp = core_zlrpack( M, N, LRblock, tmp );
344 break;
345 case PastixComplex32:
346 tmp = core_clrpack( M, N, LRblock, tmp );
347 break;
348 case PastixDouble:
349 tmp = core_dlrpack( M, N, LRblock, tmp );
350 break;
351 case PastixFloat:
352 tmp = core_slrpack( M, N, LRblock, tmp );
353 break;
354 default:
355 assert( 0 );
356 }
357 }
358}
359
360static inline void
361psi_pack_fr( pastix_starpu_interface_t *interf, void **ptr, starpu_ssize_t *count )
362{
363 assert( !( interf->cblk->cblktype & CBLK_COMPRESSED ) );
364
365 pastix_starpu_logger;
366
367 memcpy( *ptr, interf->dataptr, *count );
368}
369
370static inline int
371psi_pack_data( starpu_data_handle_t handle, unsigned node, void **ptr, starpu_ssize_t *count )
372{
373 STARPU_ASSERT( starpu_data_test_if_allocated_on_node( handle, node ) );
374
376 (pastix_starpu_interface_t *)starpu_data_get_interface_on_node( handle, node );
377
378 const SolverCblk *cblk = interf->cblk;
379
380 pastix_starpu_logger;
381
382 if ( cblk->cblktype & CBLK_COMPRESSED ) {
383 *count = psi_compute_size_lr( interf );
384 }
385 else {
386 *count = psi_compute_size_fr( interf );
387 }
388
389 if ( ptr != NULL ) {
390 *ptr = (void *)starpu_malloc_on_node_flags( node, *count, 0 );
391
392 if ( cblk->cblktype & CBLK_COMPRESSED ) {
393 psi_pack_lr( interf, ptr );
394 }
395 else {
396 psi_pack_fr( interf, ptr, count );
397 }
398 }
399
400 return 0;
401}
402
403static inline void
404psi_unpack_lr( pastix_starpu_interface_t *interf, unsigned node, const void *ptr, size_t count )
405{
406 SolverBlok *blok = interf->cblk->fblokptr + pastix_imax( 0, interf->offset );
407 pastix_lrblock_t *LRblock;
408 const char *input = ptr;
409 char *output;
410 size_t lrsize = interf->nbblok * sizeof( pastix_lrblock_t );
411 int N = cblk_colnbr( interf->cblk );
412 int i;
413
414 pastix_starpu_logger;
415
416 assert( interf->cblk->cblktype & CBLK_COMPRESSED );
417 assert( interf->allocsize == 0 );
418
419 /* Remove the size of all the rk */
420 count -= interf->nbblok * sizeof( int );
421
422 interf->allocsize = count + lrsize;
423 psi_allocate_data_on_node( interf, node );
424
425 LRblock = interf->dataptr;
426 output = interf->dataptr;
427 output += lrsize;
428
429 for ( i=0; i < interf->nbblok; i++, blok++, LRblock++ ) {
430 int M = blok_rownbr( blok );
431
432 /* Allocate the LR block to its tight space */
433 switch ( interf->flttype ) {
434 case PastixComplex64:
435 input = core_zlrunpack2( M, N, LRblock, input, &output );
436 break;
437 case PastixComplex32:
438 input = core_clrunpack2( M, N, LRblock, input, &output );
439 break;
440 case PastixDouble:
441 input = core_dlrunpack2( M, N, LRblock, input, &output );
442 break;
443 case PastixFloat:
444 input = core_slrunpack2( M, N, LRblock, input, &output );
445 break;
446 default:
447 assert( 0 );
448 }
449 }
450}
451
452static inline void
453psi_unpack_fr( pastix_starpu_interface_t *interf, void *ptr, size_t count )
454{
455 pastix_starpu_logger;
456
457 assert( count == interf->allocsize );
458 memcpy( interf->dataptr, ptr, count );
459}
460
461static inline int
462psi_peek_data( starpu_data_handle_t handle, unsigned node, void *ptr, size_t count )
463{
465 (pastix_starpu_interface_t *)starpu_data_get_interface_on_node( handle, node );
466
467 STARPU_ASSERT( starpu_data_test_if_allocated_on_node( handle, node ) );
468
469 pastix_starpu_logger;
470
471 if ( interf->cblk->cblktype & CBLK_COMPRESSED ) {
472 psi_unpack_lr( interf, node, ptr, count );
473 }
474 else {
475 psi_unpack_fr( interf, ptr, count );
476 }
477
478 return 0;
479}
480
481static inline int
482psi_unpack_data( starpu_data_handle_t handle, unsigned node, void *ptr, size_t count )
483{
484 pastix_starpu_logger;
485
486 psi_peek_data( handle, node, ptr, count );
487
488 /* Free the received information */
489 starpu_free_on_node_flags( node, (uintptr_t)ptr, count, 0 );
490
491 return 0;
492}
493
494static inline starpu_ssize_t
495psi_describe( void *data_interface, char *buf, size_t size )
496{
497 pastix_starpu_interface_t *interf = (pastix_starpu_interface_t *)data_interface;
498 const SolverCblk *cblk = interf->cblk;
499
500 pastix_starpu_logger;
501
502 return snprintf( buf, size, "Cblk%ld", (long)( cblk->gcblknum ) );
503}
504
505static inline int
506psi_copy_any_to_any( void *src_interface,
507 unsigned src_node,
508 void *dst_interface,
509 unsigned dst_node,
510 void *async_data )
511{
512 pastix_starpu_interface_t *pastix_src = (pastix_starpu_interface_t *)src_interface;
513 pastix_starpu_interface_t *pastix_dst = (pastix_starpu_interface_t *)dst_interface;
514
515 int ret = 0;
516
517 pastix_starpu_logger;
518
519 assert( !( pastix_src->cblk->cblktype & CBLK_COMPRESSED ) );
520 assert( pastix_dst->allocsize >= pastix_src->allocsize );
521
522 if ( starpu_interface_copy( (uintptr_t)pastix_src->dataptr, 0, src_node,
523 (uintptr_t)pastix_dst->dataptr, 0, dst_node,
524 pastix_src->allocsize,
525 async_data ) )
526 {
527 ret = -EAGAIN;
528 }
529 starpu_interface_data_copy( src_node, dst_node, pastix_src->allocsize );
530
531 return ret;
532}
533
534static const struct starpu_data_copy_methods psi_copy_methods = {
535 .any_to_any = psi_copy_any_to_any,
536};
537#endif /* DOXYGEN_SHOULD_SKIP_THIS */
538
539/**
540 * @ingroup pastix_starpu
541 * @{
542 *
543 * @brief TODO
544 */
545struct starpu_data_interface_ops pastix_starpu_interface_ops = {
546 .register_data_handle = psi_register_data_handle,
547 .allocate_data_on_node = psi_allocate_data_on_node,
548 .free_data_on_node = psi_free_data_on_node,
549 .init = psi_init,
550 .copy_methods = &psi_copy_methods,
551 .to_pointer = psi_to_pointer,
552 .get_size = psi_get_size,
553 .get_alloc_size = psi_get_alloc_size,
554 .footprint = psi_footprint,
555 .alloc_footprint = psi_alloc_footprint,
556 .compare = psi_compare,
557 .alloc_compare = psi_alloc_compare,
558 .display = psi_display,
559 .describe = psi_describe,
560 .pack_data = psi_pack_data,
561#if defined( HAVE_STARPU_DATA_PEEK )
562 .peek_data = psi_peek_data,
563#endif
564 .unpack_data = psi_unpack_data,
565 .interfaceid = STARPU_UNKNOWN_INTERFACE_ID,
566 .interface_size = sizeof( pastix_starpu_interface_t ),
567 .dontcache = 0, /* Should we set it to 1 */
568 .name = "PASTIX_STARPU_INTERFACE"
569};
570
571/**
572 *******************************************************************************
573 *
574 * @brief Initialize the interface ID
575 *
576 ********************************************************************************/
577void
579{
580 if ( pastix_starpu_interface_ops.interfaceid == STARPU_UNKNOWN_INTERFACE_ID ) {
581 pastix_starpu_interface_ops.interfaceid = starpu_data_interface_get_next_id();
582
583 /*
584 * TODO : Add mpi datatype
585 */
586
587 /* #if defined(PASTIX_STARPU_USE_MPI_DATATYPES) */
588 /* #if defined(HAVE_STARPU_MPI_INTERFACE_DATATYPE_NODE_REGISTER) */
589 /* starpu_mpi_interface_datatype_node_register( pastix_starpu_interface_ops.interfaceid, */
590 /* psi_allocate_datatype_node, */
591 /* psi_free_datatype ); */
592 /* #else */
593 /* starpu_mpi_interface_datatype_register( pastix_starpu_interface_ops.interfaceid, */
594 /* psi_allocate_datatype, */
595 /* psi_free_datatype ); */
596 /* #endif */
597 /* #endif */
598 }
599}
600
601/**
602 *******************************************************************************
603 *
604 * @brief Finalize the interface and reset the ID
605 *
606 ********************************************************************************/
607void
609{
610 if ( pastix_starpu_interface_ops.interfaceid != STARPU_UNKNOWN_INTERFACE_ID ) {
611 /* #if defined(PASTIX_STARPU_USE_MPI_DATATYPES) */
612 /* starpu_mpi_interface_datatype_unregister( pastix_starpu_interface_ops.interfaceid ); */
613 /* #endif */
614 pastix_starpu_interface_ops.interfaceid = STARPU_UNKNOWN_INTERFACE_ID;
615 }
616}
617
618/**
619 *
620 *******************************************************************************
621 *
622 * @brief Register a cblk at the StarPU level
623 *
624 *******************************************************************************
625 *
626 * @param[out] handleptr
627 * The StarPU data handle to the registered data. Space must be allocated on call.
628 *
629 * @param[in] home_node
630 * The StarPU memory node enum to specify where the initial data is located
631 * -1 if not local, STARPU_MAIN_RAM if local.
632 *
633 * @param[in] cblk
634 * The cblk to register
635 *
636 * @param[in] side
637 * Specify which part of the cblk (Upper or Lower) to register
638 *
639 * @param[in] flttype
640 * Specify the arithmetic floating type of the coefficients
641 *
642 ********************************************************************************/
643void
644pastix_starpu_register( starpu_data_handle_t *handleptr,
645 const SolverCblk *cblk,
647 pastix_coeftype_t flttype )
648{
651 .flttype = flttype,
652 .offset = -1,
653 .nbblok = 0,
654 .allocsize = -1,
655 .cblk = cblk,
656 .dataptr = NULL,
657 };
658 SolverBlok *fblok = cblk[0].fblokptr;
659 SolverBlok *lblok = cblk[1].fblokptr;
660 size_t size = 0;
661 int home_node = -1;
662
663 assert( side != PastixLUCoef );
664
665 pastix_starpu_logger;
666
667 /*
668 * Get the right dataptr
669 * coeftab if the cblk is not compressed
670 * else lrblock
671 */
672 if ( !( cblk->cblktype & CBLK_COMPRESSED ) ) {
673 size = cblk->stride * cblk_colnbr( cblk ) * pastix_size_of( flttype );
674 interf.dataptr = side == PastixLCoef ? cblk->lcoeftab : cblk->ucoeftab;
675 if ( interf.dataptr != NULL ) {
676 home_node = STARPU_MAIN_RAM;
677 }
678 }
679 else {
680 interf.dataptr = cblk->fblokptr->LRblock[side];
681 if ( interf.dataptr != NULL )
682 {
683 size = ( lblok - fblok ) * sizeof( pastix_lrblock_t );
684 home_node = STARPU_MAIN_RAM;
685 }
686 /* FANIN / 1D */
687 if ( (cblk->cblktype & CBLK_FANIN ) &&
688 !(cblk->cblktype & CBLK_TASKS_2D) )
689 {
690 size = ( lblok - fblok ) * sizeof( pastix_lrblock_t );
691 }
692 }
693
694 interf.nbblok = lblok - fblok;
695 interf.allocsize = size;
696
697#if defined(PASTIX_STARPU_INTERFACE_DEBUG)
698 fprintf( stderr,
699 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
700 cblk->cblktype & CBLK_COMPRESSED ? "Low-rank" : "Full-rank",
701 interf.allocsize, (long)(interf.nbblok) );
702#endif
703
704 starpu_data_register( handleptr, home_node, &interf, &pastix_starpu_interface_ops );
705}
706
707void
708pastix_starpu_register_ws( starpu_data_handle_t *handleptr,
709 const SolverCblk *cblk,
710 pastix_coeftype_t flttype )
711{
714 .flttype = flttype,
715 .offset = -1,
716 .nbblok = 0,
717 .allocsize = -1,
718 .cblk = cblk,
719 .dataptr = NULL,
720 };
721 SolverBlok *fblok = cblk[0].fblokptr;
722 SolverBlok *lblok = cblk[1].fblokptr;
723 size_t size = 0;
724 pastix_int_t M = cblk->stride;
725 pastix_int_t N = cblk_colnbr( cblk );
726
727 pastix_starpu_logger;
728
729 /*
730 * Get the correct size to allocate
731 */
732 interf.nbblok = lblok - fblok;
733 if ( (M - N) > 0 ) /* Check for useless cases where we have only a diagonal block */
734 {
735 if ( (cblk->cblktype & CBLK_COMPRESSED) &&
736 (cblk_getdataL( cblk ) != NULL) )
737 {
738 size = M * N * pastix_size_of( flttype );
739 size += interf.nbblok * sizeof( pastix_lrblock_t );
740 }
741
742 if ( !(cblk->cblktype & CBLK_COMPRESSED) )
743 {
744 size = M * N * pastix_size_of( flttype );
745 }
746 }
747 interf.allocsize = size;
748
749#if defined(PASTIX_STARPU_INTERFACE_DEBUG)
750 fprintf( stderr,
751 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
752 cblk->cblktype & CBLK_COMPRESSED ? "Low-rank" : "Full-rank",
753 interf.allocsize, (long)(interf.nbblok) );
754#endif
755
756 starpu_data_register( handleptr, -1, &interf, &pastix_starpu_interface_ops );
757}
758
759void
760pastix_starpu_register_blok( starpu_data_handle_t *handleptr,
761 const SolverCblk *cblk,
762 const SolverBlok *blok,
763 pastix_coeftype_t flttype )
764{
767 .flttype = flttype,
768 .offset = -1,
769 .nbblok = 1,
770 .allocsize = -1,
771 .cblk = cblk,
772 .dataptr = NULL,
773 };
774 SolverBlok *fblok = cblk[0].fblokptr;
775 SolverBlok *lblok = cblk[1].fblokptr;
776 size_t size = 0;
777 pastix_int_t M = blok_rownbr( blok );
778 pastix_int_t N = cblk_colnbr( cblk );
779
780 pastix_starpu_logger;
781
782 /* Count the number of blocks and number of rows */
783 {
784 const SolverBlok *cblok = blok;
785
786 while( (cblok[0].lcblknm == cblok[1].lcblknm) &&
787 (cblok[0].fcblknm == cblok[1].fcblknm) )
788 {
789 cblok++;
790 interf.nbblok++;
791 M += blok_rownbr( cblok );
792 }
793 }
794
795 /*
796 * Get the right dataptr
797 * coeftab if the cblk is not compressed
798 * else lrblock
799 */
800 if ( !( cblk->cblktype & CBLK_COMPRESSED ) )
801 {
802 size = M * N * pastix_size_of( flttype );
803 }
804
805 interf.nbblok = lblok - fblok;
806 interf.allocsize = size;
807
808#if defined(PASTIX_STARPU_INTERFACE_DEBUG)
809 fprintf( stderr,
810 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
811 cblk->cblktype & CBLK_COMPRESSED ? "Low-rank" : "Full-rank",
812 interf.allocsize, (long)(interf.nbblok) );
813#endif
814
815 starpu_data_register( handleptr, -1, &interf, &pastix_starpu_interface_ops );
816}
817/**
818 * @}
819 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
struct pastix_lrblock_s pastix_lrblock_t
The block low-rank structure to hold a matrix in low-rank form.
The block low-rank structure to hold a matrix in low-rank form.
const char * core_clrunpack2(pastix_int_t M, pastix_int_t N, pastix_lrblock_t *A, const char *input, char **outptr)
Unpack low rank data and fill the cblk concerned by the computation.
char * core_dlrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
char * core_slrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
char * core_zlrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
size_t core_zlrgetsize(pastix_int_t M, pastix_int_t N, pastix_lrblock_t *A)
Compute the size of a block to send in LR.
const char * core_zlrunpack2(pastix_int_t M, pastix_int_t N, pastix_lrblock_t *A, const char *input, char **outptr)
Unpack low rank data and fill the cblk concerned by the computation.
const char * core_dlrunpack2(pastix_int_t M, pastix_int_t N, pastix_lrblock_t *A, const char *input, char **outptr)
Unpack low rank data and fill the cblk concerned by the computation.
char * core_clrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
const char * core_slrunpack2(pastix_int_t M, pastix_int_t N, pastix_lrblock_t *A, const char *input, char **outptr)
Unpack low rank data and fill the cblk concerned by the computation.
spm_coeftype_t pastix_coeftype_t
Arithmetic types.
Definition api.h:294
enum pastix_coefside_e pastix_coefside_t
Data blocks used in the kernel.
@ PastixLCoef
Definition api.h:478
@ PastixLUCoef
Definition api.h:480
enum starpu_data_interface_id id
const SolverCblk * cblk
pastix_coeftype_t flttype
struct starpu_data_interface_ops pastix_starpu_interface_ops
TODO.
void pastix_starpu_interface_init()
Initialize the interface ID.
void pastix_starpu_interface_fini()
Finalize the interface and reset the ID.
#define PASTIX_STARPU_INTERFACE_ID
Alias to get the Interface id.
struct pastix_starpu_interface_s pastix_starpu_interface_t
Interface data structure to register the pieces of data in StarPU.
void pastix_starpu_register(starpu_data_handle_t *handleptr, const SolverCblk *cblk, pastix_coefside_t side, pastix_coeftype_t flttype)
Register a cblk at the StarPU level.
Interface data structure to register the pieces of data in StarPU.
static pastix_int_t blok_rownbr(const SolverBlok *blok)
Compute the number of rows of a block.
Definition solver.h:395
void * ucoeftab
Definition solver.h:178
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Definition solver.h:329
pastix_int_t gfaninnum
Definition solver.h:176
SolverBlok * fblokptr
Definition solver.h:168
static void * cblk_getdataL(const SolverCblk *cblk)
Get the pointer to the data associated to the lower part of the cblk.
Definition solver.h:342
pastix_lrblock_t * LRblock[2]
Definition solver.h:155
pastix_int_t gcblknum
Definition solver.h:174
pastix_int_t stride
Definition solver.h:169
int8_t cblktype
Definition solver.h:164
void * lcoeftab
Definition solver.h:177
Solver block structure.
Definition solver.h:141
Solver column block structure.
Definition solver.h:161