From 04b4a33fcdb778ee2a9d0b2c6c642bb1103b63d8 Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Fri, 16 Sep 2022 19:19:25 +0200 Subject: [PATCH] Descriptors: use the chameleon_get.. functions from the helpers and remove them from other places --- compute/CMakeLists.txt | 1 + control/descriptor.c | 21 -------- control/descriptor.h | 100 --------------------------------------- include/CMakeLists.txt | 1 + include/chameleon.h | 1 + testing/testing_zprint.c | 28 ----------- 6 files changed, 3 insertions(+), 149 deletions(-) diff --git a/compute/CMakeLists.txt b/compute/CMakeLists.txt index 815eb60bf..e42f0917b 100644 --- a/compute/CMakeLists.txt +++ b/compute/CMakeLists.txt @@ -38,6 +38,7 @@ set(CHAMELEON_CONTROL ../control/control.c ../control/descriptor.c ../control/descriptor_rec.c + ../control/descriptor_helpers.c ../control/workspace.c ../control/tile.c ../control/chameleon_f77.c diff --git a/control/descriptor.c b/control/descriptor.c index 7e4e6117b..09130a5c3 100644 --- a/control/descriptor.c +++ b/control/descriptor.c @@ -113,27 +113,6 @@ void chameleon_desc_init_tiles( CHAM_desc_t *desc, blkrankof_fct_t rankof ) } } -/** - * Internal function to return MPI rank of element A(m,n) with m,n = block indices - */ -int chameleon_getrankof_2d( const CHAM_desc_t *A, int m, int n ) -{ - int mm = m + A->i / A->mb; - int nn = n + A->j / A->nb; - return (mm % A->p) * A->q + (nn % A->q); -} - -/** - * Internal function to return MPI rank of element DIAG(m,0) with m,n = block indices - */ -int chameleon_getrankof_2d_diag( const CHAM_desc_t *A, int m, int n ) -{ - int mm = m + A->i / A->mb; - assert( m == n ); - (void)n; - return (mm % A->p) * A->q + (mm % A->q); -} - /** ****************************************************************************** * diff --git a/control/descriptor.h b/control/descriptor.h index 1e0d883f6..50eb614b6 100644 --- a/control/descriptor.h +++ b/control/descriptor.h @@ -37,20 +37,6 @@ extern "C" { /** * Internal routines */ -inline static void* chameleon_geteltaddr(const CHAM_desc_t *A, int m, int n, int eltsize); -inline static void* chameleon_getaddr_cm (const CHAM_desc_t *A, int m, int n); -inline static void* chameleon_getaddr_ccrb (const CHAM_desc_t *A, int m, int n); -inline static void* chameleon_getaddr_null (const CHAM_desc_t *A, int m, int n); -inline static void* chameleon_getaddr_diag (const CHAM_desc_t *A, int m, int n); -inline static int chameleon_getblkldd_cm (const CHAM_desc_t *A, int m); -inline static int chameleon_getblkldd_ccrb(const CHAM_desc_t *A, int m); - -/** - * Data distributions - */ -int chameleon_getrankof_2d(const CHAM_desc_t *desc, int m, int n); -int chameleon_getrankof_2d_diag(const CHAM_desc_t *desc, int m, int n); - static inline int chameleon_getrankof_tile(const CHAM_desc_t *desc, int m, int n) { CHAM_tile_t *tile = desc->get_blktile( desc, m, n ); assert( tile != NULL ); @@ -87,78 +73,6 @@ CHAM_desc_t* chameleon_desc_submatrix( CHAM_desc_t *descA, int i, int j, int m, void chameleon_desc_destroy ( CHAM_desc_t *desc ); int chameleon_desc_check ( const CHAM_desc_t *desc ); -/** - * Internal function to return address of block (m,n) with m,n = block indices - */ -inline static void* chameleon_getaddr_ccrb(const CHAM_desc_t *A, int m, int n) -{ - size_t mm = m + A->i / A->mb; - size_t nn = n + A->j / A->nb; - size_t eltsize = CHAMELEON_Element_Size(A->dtyp); - size_t offset = 0; - -#if defined(CHAMELEON_USE_MPI) - assert( A->myrank == A->get_rankof( A, mm, nn) ); - mm = mm / A->p; - nn = nn / A->q; -#endif - - if (mm < (size_t)(A->llm1)) { - if (nn < (size_t)(A->lln1)) - offset = (size_t)(A->bsiz) * (mm + (size_t)(A->llm1) * nn); - else - offset = A->A12 + ((size_t)(A->mb * (A->lln%A->nb)) * mm); - } - else { - if (nn < (size_t)(A->lln1)) - offset = A->A21 + ((size_t)((A->llm%A->mb) * A->nb) * nn); - else - offset = A->A22; - } - - return (void*)((intptr_t)A->mat + (offset*eltsize) ); -} - -/** - * Internal function to return address of block (m,n) with m,n = block indices - */ -inline static void *chameleon_getaddr_cm(const CHAM_desc_t *A, int m, int n) -{ - size_t mm = m + A->i / A->mb; - size_t nn = n + A->j / A->nb; - size_t eltsize = CHAMELEON_Element_Size(A->dtyp); - size_t offset = 0; - -#if defined(CHAMELEON_USE_MPI) - assert( A->myrank == A->get_rankof( A, mm, nn) ); - mm = mm / A->p; - nn = nn / A->q; -#endif - - offset = (size_t)(A->llm * A->nb) * nn + (size_t)(A->mb) * mm; - return (void*)((intptr_t)A->mat + (offset*eltsize) ); -} - -/** - * Internal function to return address of block (m,n) with m,n = block indices - */ -inline static void *chameleon_getaddr_diag( const CHAM_desc_t *A, int m, int n ) -{ - assert( m == n ); - (void)n; - return chameleon_getaddr_ccrb( A, m, 0 ); -} - -/** - * Internal function to return address of block (m,n) with m,n = block indices - * This version lets the runtime allocate on-demand. - */ -inline static void *chameleon_getaddr_null(const CHAM_desc_t *A, int m, int n) -{ - (void)A; (void)m; (void)n; - return NULL; -} - /** * Internal function to return address of block (m,n) with m,n = block indices */ @@ -204,20 +118,6 @@ inline static void* chameleon_geteltaddr(const CHAM_desc_t *A, int m, int n, int return (void*)((intptr_t)A->mat + (offset*eltsize) ); } -/** - * Internal function to return the leading dimension of element A(m,*) with m,n = block indices - */ -inline static int chameleon_getblkldd_ccrb(const CHAM_desc_t *A, int m) -{ - int mm = m + A->i / A->mb; - return ( ((mm+1) == A->lmt) && ((A->lm % A->mb) != 0)) ? A->lm % A->mb : A->mb; -} - -inline static int chameleon_getblkldd_cm(const CHAM_desc_t *A, int m) { - (void)m; - return A->llm; -} - /** * Detect if the tile is local or not */ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 19dce3852..da47c6e21 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -58,6 +58,7 @@ set(CHAMELEON_HDRS chameleon/timer.h chameleon/types.h chameleon/flops.h + chameleon/descriptor_helpers.h ) # Add generated headers diff --git a/include/chameleon.h b/include/chameleon.h index 175cb73f7..2dd55582a 100644 --- a/include/chameleon.h +++ b/include/chameleon.h @@ -30,6 +30,7 @@ #include "chameleon/constants.h" #include "chameleon/types.h" #include "chameleon/struct.h" +#include "chameleon/descriptor_helpers.h" /* **************************************************************************** * CHAMELEON runtime common API diff --git a/testing/testing_zprint.c b/testing/testing_zprint.c index 46ae4f983..ccc9c7fa0 100644 --- a/testing/testing_zprint.c +++ b/testing/testing_zprint.c @@ -22,34 +22,6 @@ #include "testing_zcheck.h" #include <chameleon/flops.h> -/** - * Internal function to return address of block (m,n) with m,n = block indices - */ -inline static void * -chameleon_getaddr_cm( const CHAM_desc_t *A, int m, int n ) -{ - size_t mm = m + A->i / A->mb; - size_t nn = n + A->j / A->nb; - size_t eltsize = CHAMELEON_Element_Size( A->dtyp ); - size_t offset = 0; - -#if defined(CHAMELEON_USE_MPI) - assert( A->myrank == A->get_rankof( A, mm, nn ) ); - mm = mm / A->p; - nn = nn / A->q; -#endif - - offset = (size_t)( A->llm * A->nb ) * nn + (size_t)( A->mb ) * mm; - return (void *)( (intptr_t)A->mat + ( offset * eltsize ) ); -} - -inline static int -chameleon_getblkldd_cm( const CHAM_desc_t *A, int m ) -{ - (void)m; - return A->llm; -} - int testing_zprint_desc( run_arg_list_t *args, int check ) { -- GitLab