diff --git a/control/descriptor.c b/control/descriptor.c index 22ddfd71e15548d49d32b4af912203abade845fe..ff2732b2ccd670b250039ec9bdc899043964c589 100644 --- a/control/descriptor.c +++ b/control/descriptor.c @@ -222,10 +222,36 @@ int chameleon_desc_init_internal( CHAM_desc_t *desc, const char *name, void *mat /* If one of the function get_* is NULL, we switch back to the default */ desc->get_blktile = chameleon_desc_gettile; - desc->get_blkaddr = get_blkaddr ? get_blkaddr : chameleon_getaddr_ccrb; - desc->get_blkldd = get_blkldd ? get_blkldd : chameleon_getblkldd_ccrb; - desc->get_rankof = chameleon_getrankof_tile; - desc->get_rankof_init = get_rankof ? get_rankof : chameleon_getrankof_2d; + + /* Data addresses */ + if ( get_blkaddr ) { + desc->get_blkaddr = get_blkaddr; + } + else { + if ( (intptr_t)mat > 0 ) { + desc->get_blkaddr = chameleon_getaddr_cm; + } + else { + desc->get_blkaddr = chameleon_getaddr_ccrb; + } + } + + /* Data leading dimensions */ + if ( get_blkldd ) { + desc->get_blkldd = get_blkldd; + } + else { + if ( (intptr_t)mat > 0 ) { + desc->get_blkldd = chameleon_getblkldd_cm; + } + else { + desc->get_blkldd = chameleon_getblkldd_ccrb; + } + } + + /* Data distribution */ + desc->get_rankof = chameleon_getrankof_tile; + desc->get_rankof_init = get_rankof ? get_rankof : chameleon_getrankof_2d; desc->get_rankof_init_arg = get_rankof_arg; /* Matrix properties */ diff --git a/doc/user/chapters/using.org b/doc/user/chapters/using.org index 7b04d4bb4364c179fc09d889f91f7f08cc1f8e7f..405fde9910d6ce9ace43889539c3f2a49a8a8244 100644 --- a/doc/user/chapters/using.org +++ b/doc/user/chapters/using.org @@ -464,39 +464,44 @@ In Step2, we use the first way to create the descriptor: #+begin_example - CHAMELEON_Desc_Create(&descA, NULL, ChamRealDouble, + CHAMELEON_Desc_Create(&descA, A, ChamRealDouble, NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1); #+end_example * *descA* is the descriptor to create. * The second argument is a pointer to existing data. The existing - data must follow LAPACK/PLASMA matrix layout [[sec:tile][Tile Data Layout]] - (1-D array column-major) if *CHAMELEON_Desc_Create* is used to create + data must follow LAPACK Column major layout [[sec:tile][Tile Data Layout]] + (1-D array column-major) if *CHAMELEON_Desc_Create* is used to create the descriptor. The *CHAMELEON_Desc_Create_User* function can be used if you have data organized differently. This is discussed in the next paragraph [[sec:tuto_step3][Step3]]. Giving a *NULL* pointer means you let - the function allocate memory space. This requires to copy your - data in the memory allocated by the *Desc_Create. This can be - done with + the function allocate memory space. This requires to copy the + original data into the memory managed by the descriptor by + calling: #+begin_example - CHAMELEON_Lapack_to_Tile(A, N, descA); + CHAMELEON_Lap2Desc( ChamUpperLower, A, N, descA ); #+end_example - * Third argument of @code{Desc_Create} is the datatype (used for + * The third argument of @code{Desc_Create} is the datatype (used for memory allocation). - * Fourth argument until sixth argument stand for respectively, + * Fourth to eight arguments stand for respectively, the number of rows (*NB*), columns (*NB*) in each tile, the total number of values in a tile (*NB*NB*), the number of rows (*N*), - colmumns (*N*) in the entire matrix. - * Seventh argument until ninth argument stand for respectively, - the beginning row (0), column (0) indexes of the submatrix and - the number of rows (N), columns (N) in the submatrix. These + and colmumns (*N*) in the entire matrix stored in the + memory area. + * The ninth (@code{i}) and tenth (@code{j}) arguments are + deprecated and should be set to 0. Their are kept for API + backward compatibility.stand for respectively, + * The eleventh (@code{m}) and twelfth (@code{n}) gives the size + of the matrix used in the later algorithms. These arguments are specific and used in precise cases. If you do - not consider submatrices, just use 0, 0, NROWS, NCOLS. - * Two last arguments are the parameter of the 2-D block-cyclic + not consider submatrices, just use the same values as for the + entire matrix size. + * The last two arguments are the parameters of the 2-D block-cyclic distribution grid, see [[http://www.netlib.org/scalapack/slug/node75.html][ScaLAPACK]]. To be able to use other data distribution over the nodes, *CHAMELEON_Desc_Create_User* function - should be used. + should be used. These should be both set to *1* if you provide + the data pointer. **** Step3 <<sec:tuto_step3>> diff --git a/example/lapack_to_chameleon/step2.c b/example/lapack_to_chameleon/step2.c index e6e16883ac6fc843f6950499d39c8eea7a886545..f89c2b017f38d1be44c8a366252028b93c8da1cc 100644 --- a/example/lapack_to_chameleon/step2.c +++ b/example/lapack_to_chameleon/step2.c @@ -117,22 +117,15 @@ int main(int argc, char *argv[]) { * CHAMELEON_Desc_Create( ... , 0, 0, number of rows, number of columns, 1, 1); * Have a look to the documentation for details about these parameters. */ - CHAMELEON_Desc_Create(&descA, NULL, ChamRealDouble, + CHAMELEON_Desc_Create(&descA, A, ChamRealDouble, NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1); - CHAMELEON_Desc_Create(&descB, NULL, ChamRealDouble, + CHAMELEON_Desc_Create(&descB, B, ChamRealDouble, NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1); - CHAMELEON_Desc_Create(&descX, NULL, ChamRealDouble, + CHAMELEON_Desc_Create(&descX, X, ChamRealDouble, NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1); - CHAMELEON_Desc_Create(&descAC, NULL, ChamRealDouble, + CHAMELEON_Desc_Create(&descAC, Acpy, ChamRealDouble, NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1); - /* copy LAPACK matrices in CHAMELEON descriptors to be able to call the tile - * interface */ - CHAMELEON_dLap2Desc(UPLO, A, N, descA); - CHAMELEON_dLap2Desc(ChamUpperLower, B, N, descB); - CHAMELEON_dLap2Desc(ChamUpperLower, X, N, descX); - CHAMELEON_dLap2Desc(UPLO, Acpy, N, descAC); - /* You could alternatively create descriptors wrapping your allocated * matrices to avoid copies Lapack_to_Tile with the following */ //CHAMELEON_Desc_Create(&descA, A, ChamRealDouble, @@ -210,12 +203,6 @@ int main(int argc, char *argv[]) { res / N / eps / (anorm * xnorm + bnorm )); } - /* get back results in LAPACK format if needed */ - CHAMELEON_dDesc2Lap(UPLO, descA, A, N); - CHAMELEON_dDesc2Lap(ChamUpperLower, descB, B, N); - CHAMELEON_dDesc2Lap(ChamUpperLower, descX, X, N); - CHAMELEON_dDesc2Lap(UPLO, descAC, Acpy, N); - /* deallocate A, B, X, Acpy and associated descriptors descA, ... */ CHAMELEON_Desc_Destroy( &descA ); CHAMELEON_Desc_Destroy( &descB );