Commit a9a28b6d authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'descriptors' into 'master'

Factorize a bit the descriptors functions

See merge request !133
parents 7a5f42b5 05f4bc11
......@@ -23,9 +23,9 @@
#define A(m, n) A, m, n
#define T(m, n) T, m, n
#define D(k) D, (k)-1, 0
#define D(k) &D, (k)-1, 0
#define AT(k) AT, k, 0
#define AT(k) &AT, k, 0
#if defined(CHAMELEON_COPY_DIAG)
#define E(m, n) E, m, 0
......@@ -42,8 +42,8 @@ void chameleon_pzhetrd_he2hb(cham_uplo_t uplo,
{
CHAM_context_t *chamctxt;
RUNTIME_option_t options;
CHAM_desc_t *D = NULL;
CHAM_desc_t *AT = NULL;
CHAM_desc_t D;
CHAM_desc_t AT;
size_t ws_worker = 0;
size_t ws_host = 0;
......@@ -87,15 +87,12 @@ void chameleon_pzhetrd_he2hb(cham_uplo_t uplo,
RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );
/* Copy of the diagonal tiles to keep the general version of the tile all along the computation */
D = (CHAM_desc_t*)malloc(sizeof(CHAM_desc_t));
chameleon_zdesc_alloc_diag(*D, A->mb, A->nb, chameleon_min(A->m, A->n) - A->mb, A->nb, 0, 0, chameleon_min(A->m, A->n) - A->mb, A->nb, A->p, A->q);
chameleon_zdesc_alloc_diag( &D, A->mb, A->m, A->n, A->p, A->q );
AT = (CHAM_desc_t*)malloc(sizeof(CHAM_desc_t));
*AT = chameleon_desc_init(
ChamComplexDouble, A->mb, A->nb, (A->mb*A->nb),
chameleon_min(A->mt, A->nt) * A->mb, A->nb, 0, 0, chameleon_min(A->mt, A->nt) * A->mb, A->nb, 1, 1);
chameleon_desc_mat_alloc( AT );
RUNTIME_desc_create( AT );
chameleon_desc_init( &AT, CHAMELEON_MAT_ALLOC_GLOBAL, ChamComplexDouble, A->mb, A->nb, (A->mb*A->nb),
chameleon_min(A->mt, A->nt) * A->mb, A->nb, 0, 0,
chameleon_min(A->mt, A->nt) * A->mb, A->nb, 1, 1,
NULL, NULL, NULL );
/* Let's extract the diagonal in a temporary copy that contains A and A' */
for (k = 1; k < A->nt; k++){
......@@ -437,8 +434,8 @@ void chameleon_pzhetrd_he2hb(cham_uplo_t uplo,
RUNTIME_options_finalize(&options, chamctxt);
CHAMELEON_Sequence_Wait(sequence);
CHAMELEON_Desc_Destroy( &D );
CHAMELEON_Desc_Destroy( &AT );
chameleon_desc_destroy( &D );
chameleon_desc_destroy( &AT );
(void)E;
}
This diff is collapsed.
This diff is collapsed.
......@@ -297,8 +297,7 @@ int CHAMELEON_zgelqf_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -297,8 +297,7 @@ int CHAMELEON_zgelqf_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -339,8 +339,7 @@ int CHAMELEON_zgelqs_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *B,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -346,8 +346,7 @@ int CHAMELEON_zgelqs_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -432,8 +432,7 @@ int CHAMELEON_zgels_Tile_Async( cham_trans_t trans, CHAM_desc_t *A,
CHAMELEON_Desc_Flush( B, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -428,8 +428,7 @@ int CHAMELEON_zgels_param_Tile_Async( const libhqr_tree_t *qrtree, cham_trans_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -296,8 +296,7 @@ int CHAMELEON_zgeqrf_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -319,8 +319,7 @@ int CHAMELEON_zgeqrf_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -334,8 +334,7 @@ int CHAMELEON_zgeqrs_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *B,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -335,8 +335,7 @@ int CHAMELEON_zgeqrs_param_Tile_Async( const libhqr_tree_t *qrtree,
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -331,8 +331,7 @@ int CHAMELEON_zgesv_incpiv_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *L, int *IPIV
CHAMELEON_Desc_Flush( Dptr, sequence );
CHAMELEON_Desc_Flush( B, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -471,7 +471,7 @@ int CHAMELEON_zgesvd_Tile_Async( cham_job_t jobu, cham_job_t jobvt,
#if defined(CHAMELEON_COPY_DIAG)
{
chameleon_zdesc_alloc(D, A->mb, A->nb, A->m, A->n, 0, 0, A->m, A->n, );
chameleon_zdesc_alloc_diag( &D, A->mb, A->m, A->n, A->p, A->q );
Dptr = &D;
}
#endif
......@@ -480,12 +480,12 @@ int CHAMELEON_zgesvd_Tile_Async( cham_job_t jobu, cham_job_t jobvt,
sequence, request );
/* Allocate band structure */
chameleon_zdesc_alloc_diag( descAB,
LDAB, NB,
LDAB, MINMN,
0, 0,
LDAB, MINMN,
1, 1 );
chameleon_zdesc_alloc( descAB,
LDAB, NB, /* mb, nb */
LDAB, N, /* lm, ln */
0, 0, /* i, j */
LDAB, N, /* m, n */
);
/* Convert matrix to band form */
chameleon_pztile2band( uplo,
......@@ -559,7 +559,7 @@ int CHAMELEON_zgesvd_Tile_Async( cham_job_t jobu, cham_job_t jobvt,
chameleon_sequence_wait( chamctxt, sequence );
#endif /* !defined(CHAMELEON_SIMULATION) */
chameleon_desc_mat_free( &descAB );
chameleon_desc_destroy( &descAB );
subA = NULL;
subT = NULL;
......@@ -640,8 +640,7 @@ int CHAMELEON_zgesvd_Tile_Async( cham_job_t jobu, cham_job_t jobvt,
free(E);
if ( Dptr ) {
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -298,8 +298,7 @@ int CHAMELEON_zgetrf_incpiv_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *L, int *IPI
CHAMELEON_Desc_Flush( L, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -534,9 +534,8 @@ int CHAMELEON_zheevd_Tile_Async( cham_job_t jobz, cham_uplo_t uplo,
free(Q2);
free(V);
free(E);
if (Dptr != NULL) {
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
if ( Dptr != NULL ) {
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -392,8 +392,7 @@ int CHAMELEON_zhetrd_Tile_Async( cham_job_t jobz,
NB = descA.mb;
#if defined(CHAMELEON_COPY_DIAG)
{
chameleon_zdesc_alloc_diag( D, A->mb, A->nb, chameleon_min(A->m, A->n), A->nb,
0, 0, chameleon_min(A->m, A->n), A->nb, A->p, A->q );
chameleon_zdesc_alloc_diag( &D, A->mb, A->m, A->n, A->p, A->q );
Dptr = &D;
}
#endif
......@@ -404,12 +403,12 @@ int CHAMELEON_zhetrd_Tile_Async( cham_job_t jobz,
LDAB = NB+1;
/* Allocate band structure */
chameleon_zdesc_alloc_diag( descAB,
LDAB, NB, /* mb, nb */
LDAB, N, /* lm, ln */
0, 0, /* i, j */
LDAB, N, /* m, n */
1, 1 );
chameleon_zdesc_alloc( descAB,
LDAB, NB, /* mb, nb */
LDAB, N, /* lm, ln */
0, 0, /* i, j */
LDAB, N, /* m, n */
);
/* Copy data into band structure */
chameleon_pztile2band( uplo, A, &descAB,
......@@ -432,10 +431,9 @@ int CHAMELEON_zhetrd_Tile_Async( cham_job_t jobz,
}
#endif /* !defined(CHAMELEON_SIMULATION) */
if (Dptr != NULL) {
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
chameleon_desc_mat_free( &descAB );
chameleon_desc_destroy( &descAB );
(void)D;
return CHAMELEON_SUCCESS;
}
......@@ -77,8 +77,8 @@ int CHAMELEON_zLapack_to_Tile( CHAMELEON_Complex64_t *Af77, int LDA, CHAM_desc_t
/* Create the B descriptor to handle the Lapack format matrix */
CHAMELEON_Desc_Create_User( &B, Af77, ChamComplexDouble, A->mb, A->nb, A->bsiz,
LDA, A->n, 0, 0, A->m, A->n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
LDA, A->n, 0, 0, A->m, A->n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
/* Start the computation */
chameleon_sequence_create( chamctxt, &sequence );
......@@ -154,8 +154,8 @@ int CHAMELEON_zTile_to_Lapack( CHAM_desc_t *A, CHAMELEON_Complex64_t *Af77, int
/* Create the B descriptor to handle the Lapack format matrix */
CHAMELEON_Desc_Create_User( &B, Af77, ChamComplexDouble, A->mb, A->nb, A->bsiz,
LDA, A->n, 0, 0, A->m, A->n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
LDA, A->n, 0, 0, A->m, A->n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
/* Start the computation */
chameleon_sequence_create( chamctxt, &sequence );
......
......@@ -426,8 +426,7 @@ int CHAMELEON_ztpgqrt_Tile_Async( int L,
CHAMELEON_Desc_Flush( Q2, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -322,8 +322,7 @@ int CHAMELEON_zunglq_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *Q,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -321,8 +321,7 @@ int CHAMELEON_zunglq_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -319,8 +319,7 @@ int CHAMELEON_zungqr_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *Q,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -328,8 +328,7 @@ int CHAMELEON_zungqr_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -381,8 +381,7 @@ int CHAMELEON_zunmlq_Tile_Async( cham_side_t side, cham_trans_t trans,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -382,8 +382,7 @@ int CHAMELEON_zunmlq_param_Tile_Async( const libhqr_tree_t *qrtree, cham_side_t
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -384,8 +384,7 @@ int CHAMELEON_zunmqr_Tile_Async( cham_side_t side, cham_trans_t trans,
CHAMELEON_Desc_Flush( T, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -389,8 +389,7 @@ int CHAMELEON_zunmqr_param_Tile_Async( const libhqr_tree_t *qrtree,
CHAMELEON_Desc_Flush( TT, sequence );
CHAMELEON_Desc_Flush( Dptr, sequence );
chameleon_sequence_wait( chamctxt, sequence );
RUNTIME_desc_destroy( Dptr );
chameleon_desc_mat_free( Dptr );
chameleon_desc_destroy( Dptr );
}
(void)D;
return CHAMELEON_SUCCESS;
......
......@@ -25,34 +25,6 @@
#ifndef _compute_z_h_
#define _compute_z_h_
/**
* LAPACK/Tile Descriptor accesses
*/
#define ChamDescInput 1
#define ChamDescOutput 2
#define ChamDescInout (ChamDescInput | ChamDescOutput)
/**
* Macro for matrix conversion / Lapack interface
*/
#define chameleon_zdesc_alloc_diag( descA, mb, nb, lm, ln, i, j, m, n, p, q) \
descA = chameleon_desc_init_diag( \
ChamComplexDouble, (mb), (nb), ((mb)*(nb)), \
(m), (n), (i), (j), (m), (n), p, q); \
chameleon_desc_mat_alloc( &(descA) ); \
RUNTIME_desc_create( &(descA) );
#define chameleon_zdesc_alloc( descA, mb, nb, lm, ln, i, j, m, n, free) \
descA = chameleon_desc_init( \
ChamComplexDouble, (mb), (nb), ((mb)*(nb)), \
(m), (n), (i), (j), (m), (n), 1, 1); \
if ( chameleon_desc_mat_alloc( &(descA) ) ) { \
chameleon_error( __func__, "chameleon_desc_mat_alloc() failed"); \
{free;}; \
return CHAMELEON_ERR_OUT_OF_RESOURCES; \
} \
RUNTIME_desc_create( &(descA) );
/**
* Declarations of internal sequential functions
*/
......@@ -148,6 +120,41 @@ void chameleon_pzungqr_param( int genD, int K, const libhqr_tree_t *qrtree,
RUNTIME_sequence_t *sequence, RUNTIME_request_t *request);
/**
* LAPACK/Tile Descriptor accesses
*/
#define ChamDescInput 1
#define ChamDescOutput 2
#define ChamDescInout (ChamDescInput | ChamDescOutput)
/**
* Macro for matrix conversion / Lapack interface
*/
static inline int
chameleon_zdesc_alloc_diag( CHAM_desc_t *descA, int nb, int m, int n, int p, int q ) {
int diag_m = chameleon_min( m, n );
return chameleon_desc_init( descA, CHAMELEON_MAT_ALLOC_GLOBAL,
ChamComplexDouble, nb, nb, nb*nb,
diag_m, nb, 0, 0, diag_m, nb, p, q,
chameleon_getaddr_diag,
chameleon_getblkldd_ccrb,
chameleon_getrankof_2d_diag );
}
#define chameleon_zdesc_alloc( descA, mb, nb, lm, ln, i, j, m, n, free) \
{ \
int rc; \
rc = chameleon_desc_init( &(descA), CHAMELEON_MAT_ALLOC_GLOBAL, \
ChamComplexDouble, (mb), (nb), ((mb)*(nb)), \
(m), (n), (i), (j), (m), (n), 1, 1, \
NULL, NULL, NULL ); \
if ( rc != CHAMELEON_SUCCESS ) { \
{free;} \
return rc; \
} \
}
/**
* @brief Internal function to convert the lapack format to tile format in
* LAPACK interface calls
......@@ -160,35 +167,28 @@ chameleon_zlap2tile( CHAM_context_t *chamctxt,
RUNTIME_sequence_t *seq, RUNTIME_request_t *req )
{
/* Initialize the Lapack descriptor */
*descAl = chameleon_desc_init_user( ChamComplexDouble, mb, nb, (mb)*(nb),
lm, ln, 0, 0, m, n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
descAl->mat = A;
chameleon_desc_init( descAl, A, ChamComplexDouble, mb, nb, (mb)*(nb),
lm, ln, 0, 0, m, n, 1, 1,
chameleon_getaddr_cm, chameleon_getblkldd_cm, NULL );
descAl->styp = ChamCM;
/* Initialize the tile descriptor */
*descAt = chameleon_desc_init( ChamComplexDouble, mb, nb, (mb)*(nb),
lm, ln, 0, 0, m, n, 1, 1 );
if ( CHAMELEON_TRANSLATION == ChamOutOfPlace ) {
if ( chameleon_desc_mat_alloc( descAt ) ) {
chameleon_error( "chameleon_zlap2tile", "chameleon_desc_mat_alloc() failed");
return CHAMELEON_ERR_OUT_OF_RESOURCES;
}
RUNTIME_desc_create( descAl );
RUNTIME_desc_create( descAt );
/* Initialize the tile descriptor */
chameleon_desc_init( descAt, CHAMELEON_MAT_ALLOC_GLOBAL, ChamComplexDouble, mb, nb, (mb)*(nb),
lm, ln, 0, 0, m, n, 1, 1,
chameleon_getaddr_ccrb, chameleon_getblkldd_ccrb, NULL );
if ( mode & ChamDescInput ) {
chameleon_pzlacpy( uplo, descAl, descAt, seq, req );
}
}
else {
chameleon_fatal_error( "chameleon_zlap2tile", "INPLACE translation not supported yet");
descAt->mat = A;
/* Initialize the tile descriptor */
chameleon_desc_init( descAt, A, ChamComplexDouble, mb, nb, (mb)*(nb),
lm, ln, 0, 0, m, n, 1, 1,
chameleon_getaddr_ccrb, chameleon_getblkldd_ccrb, NULL );
RUNTIME_desc_create( descAl );
RUNTIME_desc_create( descAt );
chameleon_fatal_error( "chameleon_zlap2tile", "INPLACE translation not supported yet");
if ( mode & ChamDescInput ) {
/* CHAMELEON_zgecfi_Async( lm, ln, A, ChamCM, mb, nb, */
......@@ -235,11 +235,8 @@ chameleon_ztile2lap( CHAM_context_t *chamctxt, CHAM_desc_t *descAl, CHAM_desc_t
static inline void
chameleon_ztile2lap_cleanup( CHAM_context_t *chamctxt, CHAM_desc_t *descAl, CHAM_desc_t *descAt )
{
if ( CHAMELEON_TRANSLATION == ChamOutOfPlace ) {
chameleon_desc_mat_free( descAt );
}
RUNTIME_desc_destroy( descAl );
RUNTIME_desc_destroy( descAt );
chameleon_desc_destroy( descAl );
chameleon_desc_destroy( descAt );
}
#endif /* _compute_z_h_ */
This diff is collapsed.
......@@ -37,6 +37,7 @@ inline static void* chameleon_geteltaddr(const CHAM_desc_t *A, int m, int n, int
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);
......@@ -46,21 +47,16 @@ inline static int chameleon_getblkldd_ccrb(const CHAM_desc_t *A, int m);
inline static int chameleon_getrankof_2d(const CHAM_desc_t *desc, int m, int n);
inline static int chameleon_getrankof_2d_diag(const CHAM_desc_t *desc, int m, int n);
CHAM_desc_t chameleon_desc_init(cham_flttype_t dtyp, int mb, int nb, int bsiz,
int lm, int ln, int i, int j, int m, int n, int p, int q);
CHAM_desc_t chameleon_desc_init_diag(cham_flttype_t dtyp, int mb, int nb, int bsiz,
int lm, int ln, int i, int j, int m, int n, int p, int q);
CHAM_desc_t chameleon_desc_init_user(cham_flttype_t dtyp, int mb, int nb, int bsiz,
int lm, int ln, int i, int j,
int m, int n, int p, int q,
void* (*get_blkaddr)( const CHAM_desc_t*, int, int ),
int (*get_blkldd)( const CHAM_desc_t*, int ),
int (*get_rankof)( const CHAM_desc_t*, int, int ));
CHAM_desc_t* chameleon_desc_submatrix(CHAM_desc_t *descA, int i, int j, int m, int n);
int chameleon_desc_check (const CHAM_desc_t *desc);
int chameleon_desc_mat_alloc(CHAM_desc_t *desc);
int chameleon_desc_mat_free (CHAM_desc_t *desc);
int chameleon_desc_init ( CHAM_desc_t *desc, void *mat,
cham_flttype_t dtyp, int mb, int nb, int bsiz,
int lm, int ln, int i, int j,
int m, int n, int p, int q,
void* (*get_blkaddr)( const CHAM_desc_t*, int, int ),
int (*get_blkldd) ( const CHAM_desc_t*, int ),
int (*get_rankof) ( const CHAM_desc_t*, int, int ) );
CHAM_desc_t* chameleon_desc_submatrix( CHAM_desc_t *descA, int i, int j, int m, int n );
void chameleon_desc_destroy ( CHAM_desc_t *desc );
int chameleon_desc_check ( const CHAM_desc_t *desc );
#define BLKLDD(A, k) A->get_blkldd( A, k )
......@@ -116,6 +112,15 @@ inline static void *chameleon_getaddr_cm(const CHAM_desc_t *A, int m, int n)
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 );
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.
......@@ -170,7 +175,6 @@ inline static int chameleon_getblkldd_cm(const CHAM_desc_t *A, int m) {
return A->llm;
}
/**
* Internal function to return MPI rank of element A(m,n) with m,n = block indices
*/
......@@ -187,7 +191,7 @@ inline static int chameleon_getrankof_2d(const CHAM_desc_t *A, int m, int n)
inline static int chameleon_getrankof_2d_diag(const CHAM_desc_t *A, int m, int n)
{
int mm = m + A->i / A->mb;
assert( n == 0 );
assert( m == n );
return (mm % A->p) * A->q + (mm % A->q);
}
......
......@@ -74,32 +74,7 @@ int chameleon_alloc_ibnb_tile(int M, int N, cham_tasktype_t func, int type, CHAM
lm = IB * MT;
ln = NB * NT;
/* Allocate and initialize descriptor */
*desc = (CHAM_desc_t*)malloc(sizeof(CHAM_desc_t));
if (*desc == NULL) {
chameleon_error("chameleon_alloc_ibnb_tile", "malloc() failed");
return CHAMELEON_ERR_OUT_OF_RESOURCES;
}
**desc = chameleon_desc_init(type, IB, NB, IB*NB, lm, ln, 0, 0, lm, ln, p, q);
/* Allocate matrix */
if (chameleon_desc_mat_alloc(*desc)) {
chameleon_error("chameleon_alloc_ibnb_tile", "malloc() failed");
free(*desc);
return CHAMELEON_ERR_OUT_OF_RESOURCES;
}
RUNTIME_desc_create( *desc );
/* Check that everything is ok */
status = chameleon_desc_check(*desc);
if (status != CHAMELEON_SUCCESS) {
chameleon_error("chameleon_alloc_ibnb_tile", "invalid descriptor");
free(*desc);
return status;
}
return CHAMELEON_SUCCESS;
return CHAMELEON_Desc_Create( desc, NULL, type, IB, NB, IB*NB, lm, ln, 0, 0, lm, ln, p, q );
}
/**
......@@ -144,18 +119,7 @@ int chameleon_alloc_ipiv(int M, int N, cham_tasktype_t func, int type, CHAM_desc
/* TODO: Fix the distribution for IPIV */
*IPIV = (int*)malloc( size );
*desc = (CHAM_desc_t*)malloc(sizeof(CHAM_desc_t));
**desc = chameleon_desc_init(type, IB, NB, IB*NB, lm, ln, 0, 0, lm, ln, p, q );
if ( chameleon_desc_mat_alloc(*desc) ) {
chameleon_error("chameleon_alloc_ipiv", "malloc() failed");
free(*desc);
return CHAMELEON_ERR_OUT_OF_RESOURCES;
}
RUNTIME_desc_create( *desc );
return CHAMELEON_SUCCESS;
return CHAMELEON_Desc_Create( desc, NULL, type, IB, NB, IB*NB, lm, ln, 0, 0, lm, ln, p, q );
}
/**
......@@ -193,8 +157,7 @@ int CHAMELEON_Dealloc_Workspace(CHAM_desc_t **desc)
chameleon_error("CHAMELEON_Dealloc_Worspace", "attempting to deallocate a NULL pointer");
return CHAMELEON_ERR_UNALLOCATED;
}
chameleon_desc_mat_free( *desc );
RUNTIME_desc_destroy( *desc );
chameleon_desc_destroy( *desc );
free(*desc);
*desc = NULL;
......
......@@ -208,6 +208,13 @@ typedef enum chameleon_translation_e {
ChamOutOfPlace = 2,
} cham_translation_t;
/**
* @brief Constant to describe how to initialize the mat pointer in descriptors
*/
#define CHAMELEON_MAT_ALLOC_GLOBAL NULL
#define CHAMELEON_MAT_ALLOC_TILE ((void*)-1)
#define CHAMELEON_MAT_OOC ((void*)-2)
/**
* CHAMELEON constants - success & error codes
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment