19 #include "common/common.h"
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 #if defined(PASTIX_STARPU_INTERFACE_DEBUG)
31 #define pastix_starpu_logger fprintf( stderr, "pastix_starpu: %s\n", __func__ )
33 #define pastix_starpu_logger do {} while(0)
37 psi_register_data_handle( starpu_data_handle_t handle,
int home_node,
void *data_interface )
44 for ( node = 0; node < STARPU_MAXNODES; node++ ) {
50 if ( node != home_node ) {
51 local_interface->
dataptr = NULL;
56 static inline starpu_ssize_t
57 psi_allocate_data_on_node(
void *data_interface,
unsigned node )
60 starpu_ssize_t allocated_memory;
67 if ( allocated_memory <= 0 ) {
71 handle = starpu_malloc_on_node( node, allocated_memory );
76 if ( starpu_node_get_kind( node ) != STARPU_OPENCL_RAM ) {
118 return allocated_memory;
122 psi_free_data_on_node(
void *data_interface,
unsigned node )
128 pastix_starpu_logger;
136 psi_init(
void *data_interface )
142 pastix_starpu_logger;
146 psi_to_pointer(
void *data_interface,
unsigned node )
151 pastix_starpu_logger;
157 psi_get_size( starpu_data_handle_t handle )
160 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
166 if ( interf->
offset == -1 ) {
174 for( ; fblok < lblok; fblok++ ) {
179 size = ncols * nrows;
183 "psi_get_size: The given data is not a pastix interface for starpu." );
190 psi_get_alloc_size( starpu_data_handle_t handle )
193 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
195 pastix_starpu_logger;
199 "psi_get_alloc_size: The given data is not a pastix interface for starpu." );
202 STARPU_ASSERT_MSG( interf->
allocsize != (
size_t)-1,
203 "psi_get_alloc_size: The allocation size needs to be defined" );
208 static inline uint32_t
209 psi_footprint( starpu_data_handle_t handle )
212 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
215 pastix_starpu_logger;
217 return starpu_hash_crc32c_be( cblk->
gcblknum, interf->
offset + 1 );
220 static inline uint32_t
221 psi_alloc_footprint( starpu_data_handle_t handle )
224 starpu_data_get_interface_on_node( handle, STARPU_MAIN_RAM );
226 pastix_starpu_logger;
228 return starpu_hash_crc32c_be( interf->
allocsize, 0 );
232 psi_compare(
void *data_interface_a,
void *data_interface_b )
240 pastix_starpu_logger;
243 return ( solva == solvb );
247 psi_alloc_compare(
void *data_interface_a,
void *data_interface_b )
252 pastix_starpu_logger;
259 psi_display( starpu_data_handle_t handle, FILE *f )
266 pastix_starpu_logger;
268 if ( interf->
offset == -1 ) {
269 fprintf( f,
"Cblk%ld", (
long)( cblk->
gcblknum ) );
272 fprintf( f,
"Cblk%ldBlok%ld", (
long)( cblk->
gcblknum ), (
long)( interf->
offset ) );
281 size_t elemsize = pastix_size_of( interf->
flttype );
288 pastix_starpu_logger;
292 for ( i = 0; i < interf->
nbblok; i++, blok++, LRblock++ ) {
302 assert( !( interf->
cblk->
cblktype & CBLK_COMPRESSED ) );
304 pastix_starpu_logger;
322 pastix_starpu_logger;
324 for ( ; j < interf->
nbblok; j++, blok++, LRblock++ ) {
328 case PastixComplex64:
331 case PastixComplex32:
349 assert( !( interf->
cblk->
cblktype & CBLK_COMPRESSED ) );
351 pastix_starpu_logger;
353 memcpy( *ptr, interf->
dataptr, *count );
357 psi_pack_data( starpu_data_handle_t handle,
unsigned node,
void **ptr, starpu_ssize_t *count )
359 STARPU_ASSERT( starpu_data_test_if_allocated_on_node( handle, node ) );
366 pastix_starpu_logger;
368 if ( cblk->
cblktype & CBLK_COMPRESSED ) {
369 *count = psi_compute_size_lr( interf );
372 *count = psi_compute_size_fr( interf );
376 *ptr = (
void *)starpu_malloc_on_node_flags( node, *count, 0 );
378 if ( cblk->
cblktype & CBLK_COMPRESSED ) {
379 psi_pack_lr( interf, ptr );
382 psi_pack_fr( interf, ptr, count );
394 const char *input = ptr;
400 pastix_starpu_logger;
406 count -= interf->
nbblok *
sizeof( int );
409 psi_allocate_data_on_node( interf, node );
415 for ( i=0; i < interf->
nbblok; i++, blok++, LRblock++ ) {
420 case PastixComplex64:
423 case PastixComplex32:
441 pastix_starpu_logger;
444 memcpy( interf->
dataptr, ptr, count );
448 psi_peek_data( starpu_data_handle_t handle,
unsigned node,
void *ptr,
size_t count )
453 STARPU_ASSERT( starpu_data_test_if_allocated_on_node( handle, node ) );
455 pastix_starpu_logger;
458 psi_unpack_lr( interf, node, ptr, count );
461 psi_unpack_fr( interf, ptr, count );
468 psi_unpack_data( starpu_data_handle_t handle,
unsigned node,
void *ptr,
size_t count )
470 pastix_starpu_logger;
472 psi_peek_data( handle, node, ptr, count );
475 starpu_free_on_node_flags( node, (uintptr_t)ptr, count, 0 );
480 static inline starpu_ssize_t
481 psi_describe(
void *data_interface,
char *buf,
size_t size )
486 pastix_starpu_logger;
488 return snprintf( buf, size,
"Cblk%ld", (
long)( cblk->
gcblknum ) );
492 psi_copy_any_to_any(
void *src_interface,
503 pastix_starpu_logger;
505 assert( !( pastix_src->
cblk->
cblktype & CBLK_COMPRESSED ) );
507 if ( starpu_interface_copy( (uintptr_t)pastix_src->
dataptr, 0, src_node,
508 (uintptr_t)pastix_dst->
dataptr, 0, dst_node,
514 starpu_interface_data_copy( src_node, dst_node, pastix_src->
allocsize );
519 static const struct starpu_data_copy_methods psi_copy_methods = {
520 .any_to_any = psi_copy_any_to_any,
531 .register_data_handle = psi_register_data_handle,
532 .allocate_data_on_node = psi_allocate_data_on_node,
533 .free_data_on_node = psi_free_data_on_node,
535 .copy_methods = &psi_copy_methods,
536 .to_pointer = psi_to_pointer,
537 .get_size = psi_get_size,
538 .get_alloc_size = psi_get_alloc_size,
539 .footprint = psi_footprint,
540 .alloc_footprint = psi_alloc_footprint,
541 .compare = psi_compare,
542 .alloc_compare = psi_alloc_compare,
543 .display = psi_display,
544 .describe = psi_describe,
545 .pack_data = psi_pack_data,
546 #if defined( HAVE_STARPU_DATA_PEEK )
547 .peek_data = psi_peek_data,
549 .unpack_data = psi_unpack_data,
550 .interfaceid = STARPU_UNKNOWN_INTERFACE_ID,
553 .name =
"PASTIX_STARPU_INTERFACE"
650 pastix_starpu_logger;
657 if ( !( cblk->
cblktype & CBLK_COMPRESSED ) ) {
660 if ( interf.
dataptr != NULL ) {
661 home_node = STARPU_MAIN_RAM;
669 home_node = STARPU_MAIN_RAM;
673 interf.
nbblok = lblok - fblok;
676 #if defined(PASTIX_STARPU_INTERFACE_DEBUG)
678 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
679 cblk->
cblktype & CBLK_COMPRESSED ?
"Low-rank" :
"Full-rank",
687 pastix_starpu_register_ws( starpu_data_handle_t *handleptr,
706 pastix_starpu_logger;
711 interf.
nbblok = lblok - fblok;
714 if ( (cblk->
cblktype & CBLK_COMPRESSED) &&
717 size = M * N * pastix_size_of( flttype );
721 if ( !(cblk->
cblktype & CBLK_COMPRESSED) )
723 size = M * N * pastix_size_of( flttype );
728 #if defined(PASTIX_STARPU_INTERFACE_DEBUG)
730 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
731 cblk->
cblktype & CBLK_COMPRESSED ?
"Low-rank" :
"Full-rank",
739 pastix_starpu_register_blok( starpu_data_handle_t *handleptr,
759 pastix_starpu_logger;
765 while( (cblok[0].lcblknm == cblok[1].lcblknm) &&
766 (cblok[0].fcblknm == cblok[1].fcblknm) )
779 if ( !( cblk->
cblktype & CBLK_COMPRESSED ) )
781 size = M * N * pastix_size_of( flttype );
784 interf.
nbblok = lblok - fblok;
787 #if defined(PASTIX_STARPU_INTERFACE_DEBUG)
789 "cblk (%9s, size=%8zu, nbblok=%2ld )\n",
790 cblk->
cblktype & CBLK_COMPRESSED ?
"Low-rank" :
"Full-rank",
BEGIN_C_DECLS typedef int pastix_int_t
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_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.
char * core_clrpack(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_dlrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
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.
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_zlrpack(pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A, char *buffer)
Pack low-rank data by side.
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.
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.
spm_coeftype_t pastix_coeftype_t
Arithmetic types.
enum pastix_coefside_e pastix_coefside_t
Data blocks used in the kernel.
enum starpu_data_interface_id id
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.
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
static void * cblk_getdataL(const SolverCblk *cblk)
Get the pointer to the data associated to the lower part of the cblk.
pastix_lrblock_t * LRblock[2]
Solver column block structure.