diff --git a/compute/pzgetrf.c b/compute/pzgetrf.c index d95b415d9bbe5473f38be0d3b304c7c3c898adf1..5ecbe29594a53dcbbc32898b19d6269aa5f8e24a 100644 --- a/compute/pzgetrf.c +++ b/compute/pzgetrf.c @@ -214,10 +214,6 @@ chameleon_pzgetrf_panel_facto_blocked( struct chameleon_pzgetrf_s *ws, int m, h, b, nbblock; int tempkm, tempkn, tempmm, minmn; - if ( ! ws->involved ) { - return; - } - tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb; tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb; minmn = chameleon_min( tempkm, tempkn ); @@ -340,25 +336,10 @@ chameleon_pzgetrf_panel_facto( struct chameleon_pzgetrf_s *ws, int k, RUNTIME_option_t *options ) { -#if defined ( CHAMELEON_USE_MPI ) - int *proc_involved = malloc( sizeof( int ) * chameleon_min( A->p, A->mt - k) ); - int b; - - /* 2DBC only */ - ws->involved = 0; - for ( b = k; (b < A->mt) && ((b-k) < A->p); b ++ ) { - int rank = chameleon_getrankof_2d( A, b, k ); - proc_involved[ b-k ] = rank; - if ( rank == A->myrank ) { - ws->involved = 1; - } - } - ws->proc_involved = proc_involved; - if ( ws->involved == 0 ) { - free( proc_involved ); + chameleon_get_proc_involved_in_panelk_2dbc( A, k, k, ws ); + if ( !ws->involved ) { return; } -#endif /* TODO: Should be replaced by a function pointer */ switch( ws->alg ) { @@ -388,9 +369,6 @@ chameleon_pzgetrf_panel_facto( struct chameleon_pzgetrf_s *ws, default: chameleon_pzgetrf_panel_facto_nopiv( ws, A, ipiv, k, options ); } -#if defined ( CHAMELEON_USE_MPI ) - free( proc_involved ); -#endif } /** diff --git a/compute/zgetrf.c b/compute/zgetrf.c index 8fb6734d3e15fe2cc25fb9c1664db8bc9a0f6987..da434379c2c18388dd95c1d6cf398c87f08f5ad7 100644 --- a/compute/zgetrf.c +++ b/compute/zgetrf.c @@ -67,6 +67,12 @@ CHAMELEON_zgetrf_WS_Alloc( const CHAM_desc_t *A ) ws->alg = ChamGetrfPPiv; ws->ib = CHAMELEON_IB; +#if defined (CHAMELEON_USE_MPI) + ws->proc_involved = malloc( sizeof( int ) * A->p ); + ws->involved = 0; + ws->np_involved = 0; +#endif + { char *algostr = chameleon_getenv( "CHAMELEON_GETRF_ALGO" ); @@ -160,6 +166,10 @@ CHAMELEON_zgetrf_WS_Free( void *user_ws ) { struct chameleon_pzgetrf_s *ws = (struct chameleon_pzgetrf_s *)user_ws; +#if defined (CHAMELEON_USE_MPI) + free( ws->proc_involved ); +#endif + if ( ( ws->alg == ChamGetrfNoPivPerColumn ) || ( ws->alg == ChamGetrfPPiv ) || ( ws->alg == ChamGetrfPPivPerColumn ) ) diff --git a/control/descriptor_helpers.c b/control/descriptor_helpers.c index 9cae1883552fc8f418aca49140cf904dbcdcbed8..b49cb69e9b751e4494ae01de14571010c64e980c 100644 --- a/control/descriptor_helpers.c +++ b/control/descriptor_helpers.c @@ -100,6 +100,52 @@ int chameleon_involved_in_panelk_2dbc( const CHAM_desc_t *A, int k ) { return ( myrank % A->q == k % A->q ); } +/** + * @brief Test if the current MPI process is involved in the panel k for 2DBC distributions. + * + * @param[in] A + * The matrix descriptor. + * + * @param[in] k + * The index of the panel to test. + * + * @param[in] n + * The index of the panel to test. + * + * @param[inout] ws_getrf + * The i. + * + */ +void chameleon_get_proc_involved_in_panelk_2dbc( const CHAM_desc_t *A, + int k, + int n, + void *ws_getrf ) +{ +#if defined (CHAMELEON_USE_MPI) + struct chameleon_pzgetrf_s *ws = (struct chameleon_pzgetrf_s *)ws_getrf; + int *proc_involved = ws->proc_involved; + int b, rank, np; + + np = 0; + ws->involved = 0; + for ( b = k; (b < A->mt) && ((b-k) < A->p); b ++ ) { + rank = chameleon_getrankof_2d( A, b, n ); + proc_involved[ b-k ] = rank; + np ++; + if ( rank == A->myrank ) { + ws->involved = 1; + } + } + ws->proc_involved = proc_involved; + ws->np_involved = np; +#else + (void)A; + (void)k; + (void)n; + (void)ws_getrf; +#endif +} + /** * @brief Initializes a custom distribution based on an external file. * diff --git a/include/chameleon/descriptor_helpers.h b/include/chameleon/descriptor_helpers.h index da79d04863f4180e6c6ce929fee6b33235998fc3..7bfdeb77ba565c2da0f9668f5d7d347e6e44112c 100644 --- a/include/chameleon/descriptor_helpers.h +++ b/include/chameleon/descriptor_helpers.h @@ -64,6 +64,10 @@ int chameleon_getrankof_custom ( const CHAM_desc_t *A, int m, int n ); */ int chameleon_involved_in_panelk_2dbc( const CHAM_desc_t *A, int An ); +void chameleon_get_proc_involved_in_panelk_2dbc( const CHAM_desc_t *A, + int k, + int n, + void *ws_getrf ); /** * @}