From 722857d916ae37ba509d114852164c337eee6e91 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Mon, 15 Dec 2014 17:45:52 +0000
Subject: [PATCH] MORSE_Desc_Create_User with NULL pointer cannot be used to
 allocate the data (mat) - when NULL is given to MORSE_Desc_Create_User means
 that the application manage the allocation - to let MORSE allocate its data
 -> use MORSE_Desc_Create with NULL pointer

---
 example/basic_zposv/zposv_morse_functions.c | 28 +++++-----------
 example/lapack_to_morse/step3.c             | 21 ++++--------
 example/lapack_to_morse/step6.c             | 36 +++++++--------------
 3 files changed, 26 insertions(+), 59 deletions(-)

diff --git a/example/basic_zposv/zposv_morse_functions.c b/example/basic_zposv/zposv_morse_functions.c
index 93ab35c57..cc53929f1 100644
--- a/example/basic_zposv/zposv_morse_functions.c
+++ b/example/basic_zposv/zposv_morse_functions.c
@@ -64,37 +64,25 @@ int main(int argc, char *argv[]) {
      * MORSE_desc_t is a structure wrapping your data allowing MORSE to get
      * pointers to tiles
      */
-    MORSE_Desc_Create_User(&descA, NULL, MorseComplexDouble,
-                           NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descA, NULL, MorseComplexDouble,
+                      NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1);
 
     /* generate A matrix with random values such that it is hermitian */
     MORSE_zplghe_Tile( (double)N, descA, 51 );
 
     /* generate RHS */
-    MORSE_Desc_Create_User(&descB, NULL, MorseComplexDouble,
-                           NB, NB, NB*NB, N, 1, 0, 0, N, 1, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descB, NULL, MorseComplexDouble,
+                      NB, NB, NB*NB, N, 1, 0, 0, N, 1, 1, 1);
     MORSE_zplrnt_Tile( descB, 7672 );
 
     /* copy A before facto. in order to check the result */
-    MORSE_Desc_Create_User(&descAC, NULL, MorseComplexDouble,
-                           NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descAC, NULL, MorseComplexDouble,
+                      NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1);
     MORSE_zlacpy_Tile(MorseUpperLower, descA, descAC);
 
     /* copy B before solving in order to check the result */
-    MORSE_Desc_Create_User(&descX, NULL, MorseComplexDouble,
-                           NB, NB, NB*NB, N, 1, 0, 0, N, 1, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descX, NULL, MorseComplexDouble,
+                      NB, NB, NB*NB, N, 1, 0, 0, N, 1, 1, 1);
     MORSE_zlacpy_Tile(MorseUpperLower, descB, descX);
 
     /* solve the system AX = B using the Cholesky factorization,
diff --git a/example/lapack_to_morse/step3.c b/example/lapack_to_morse/step3.c
index 833ff6696..d5325acad 100644
--- a/example/lapack_to_morse/step3.c
+++ b/example/lapack_to_morse/step3.c
@@ -131,21 +131,12 @@ int main(int argc, char *argv[]) {
      * is equivalent to a call to MORSE_Desc_Create (morse_get... are the
      * functions used inside MORSE_Desc_Create).
      */
-    MORSE_Desc_Create_User(&descB, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
-    MORSE_Desc_Create_User(&descX, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
-    MORSE_Desc_Create_User(&descAC, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descB, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1);
+    MORSE_Desc_Create(&descX, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS, 1, 1);
+    MORSE_Desc_Create(&descAC, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, N, 0, 0, N, N, 1, 1);
 
     /* generate A matrix with random values such that it is spd */
     MORSE_dplgsy_Tile( (double)N, descA, 51 );
diff --git a/example/lapack_to_morse/step6.c b/example/lapack_to_morse/step6.c
index 4ed91da2e..407b03252 100644
--- a/example/lapack_to_morse/step6.c
+++ b/example/lapack_to_morse/step6.c
@@ -130,30 +130,18 @@ int main(int argc, char *argv[]) {
     }
 
     /* Initialize the structure required for MORSE tile interface */
-    MORSE_Desc_Create_User(&descA, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, N, 0, 0, N, N,
-                           GRID_P, GRID_Q,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
-    MORSE_Desc_Create_User(&descB, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS,
-                           GRID_P, GRID_Q,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
-    MORSE_Desc_Create_User(&descX, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS,
-                           GRID_P, GRID_Q,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
-    MORSE_Desc_Create_User(&descAC, NULL, MorseRealDouble,
-                           NB, NB, NB*NB, N, N, 0, 0, N, N,
-                           GRID_P, GRID_Q,
-                           morse_getaddr_ccrb,
-                           morse_getblkldd_ccrb,
-                           morse_getrankof_2d);
+    MORSE_Desc_Create(&descA, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, N, 0, 0, N, N,
+                      GRID_P, GRID_Q);
+    MORSE_Desc_Create(&descB, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS,
+                      GRID_P, GRID_Q);
+    MORSE_Desc_Create(&descX, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, NRHS, 0, 0, N, NRHS,
+                      GRID_P, GRID_Q);
+    MORSE_Desc_Create(&descAC, NULL, MorseRealDouble,
+                      NB, NB, NB*NB, N, N, 0, 0, N, N,
+                      GRID_P, GRID_Q);
 
     /* generate A matrix with random values such that it is spd */
     MORSE_dplgsy_Tile( (double)N, descA, 51 );
-- 
GitLab