From fd64842acb0413b481fa7d3b994903de59582b3b Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 2 Oct 2015 23:18:53 +0000
Subject: [PATCH] morse_ functions are internal functions, they should not be
 used in user program

---
 example/lapack_to_morse/step1.c |  5 ++++-
 example/lapack_to_morse/step2.c | 25 +++++++++----------------
 example/lapack_to_morse/step3.c | 19 ++++++-------------
 example/lapack_to_morse/step4.c | 22 ++++++++--------------
 example/lapack_to_morse/step5.c | 20 +++++++-------------
 example/lapack_to_morse/step6.c | 24 +++++++++---------------
 6 files changed, 43 insertions(+), 72 deletions(-)

diff --git a/example/lapack_to_morse/step1.c b/example/lapack_to_morse/step1.c
index e9a88b034..63933855e 100644
--- a/example/lapack_to_morse/step1.c
+++ b/example/lapack_to_morse/step1.c
@@ -89,7 +89,10 @@ int main(int argc, char *argv[]) {
     print_header( argv[0], iparam);
 
     /* Initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
+    }
 
     /*
      * allocate memory for our data using a C macro (see step1.h)
diff --git a/example/lapack_to_morse/step2.c b/example/lapack_to_morse/step2.c
index 488100dd7..87fca9420 100644
--- a/example/lapack_to_morse/step2.c
+++ b/example/lapack_to_morse/step2.c
@@ -54,10 +54,6 @@ int main(int argc, char *argv[]) {
     double anorm, bnorm, xnorm, eps, res;
     int hres;
 
-    /* Morse structure containing parameters and a structure to interact with
-     * the Runtime system */
-    MORSE_context_t *morse;
-
     /* initialize some parameters with default values */
     int iparam[IPARAM_SIZEOF];
     memset(iparam, 0, IPARAM_SIZEOF*sizeof(int));
@@ -87,6 +83,15 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
+     /* Initialize MORSE with main parameters */
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
+    }
+
+    /* Question morse to get the block (tile) size (number of columns) */
+    MORSE_Get( MORSE_TILE_SIZE, &NB );
+
     /*
      * Allocate memory for our data using a C macro (see step2.h)
      *     - matrix A                   : size N x N
@@ -98,18 +103,6 @@ int main(int argc, char *argv[]) {
     PASTE_CODE_ALLOCATE_MATRIX( X, double, N, NRHS );
     PASTE_CODE_ALLOCATE_MATRIX( Acpy, double, N, N );
 
-    /* initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
-
-    morse = morse_context_self();
-    if (morse == NULL) {
-        morse_fatal_error("step2", "MORSE not initialized");
-        return MORSE_ERR_NOT_INITIALIZED;
-    }
-
-    /* question morse to get the block (tile) size (number of columns) */
-    NB = morse->nb;
-
     /*
      * Initialize the structure required for MORSE tile interface
      * MORSE_desc_t is a structure wrapping your data allowing MORSE to get
diff --git a/example/lapack_to_morse/step3.c b/example/lapack_to_morse/step3.c
index d5325acad..5330666ed 100644
--- a/example/lapack_to_morse/step3.c
+++ b/example/lapack_to_morse/step3.c
@@ -55,10 +55,6 @@ int main(int argc, char *argv[]) {
     double anorm, bnorm, xnorm, eps, res;
     int hres;
 
-    /* Morse structure containing parameters and a structure to interact with
-     * the Runtime system */
-    MORSE_context_t *morse;
-
     /* initialize some parameters with default values */
     int iparam[IPARAM_SIZEOF];
     memset(iparam, 0, IPARAM_SIZEOF*sizeof(int));
@@ -88,17 +84,14 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-    /* initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
-
-    morse = morse_context_self();
-    if (morse == NULL) {
-        morse_fatal_error("step3", "MORSE not initialized");
-        return MORSE_ERR_NOT_INITIALIZED;
+     /* Initialize MORSE with main parameters */
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
     }
 
-    /* question morse to get the block (tile) size (number of columns) */
-    NB = morse->nb;;
+    /* Question morse to get the block (tile) size (number of columns) */
+    MORSE_Get( MORSE_TILE_SIZE, &NB );
 
     /* allocate tile data */
     matA = allocate_tile_matrix(N, N, NB);
diff --git a/example/lapack_to_morse/step4.c b/example/lapack_to_morse/step4.c
index c9d5c08fe..7e585ac10 100644
--- a/example/lapack_to_morse/step4.c
+++ b/example/lapack_to_morse/step4.c
@@ -56,9 +56,6 @@ int main(int argc, char *argv[]) {
     double anorm, bnorm, xnorm, eps, res;
     int hres;
 
-    /* Morse structure containing parameters and a structure to interact with
-     * the Runtime system */
-    MORSE_context_t *morse;
     /* MORSE sequence uniquely identifies a set of asynchronous function calls
      * sharing common exception handling */
     MORSE_sequence_t *sequence = NULL;
@@ -95,17 +92,14 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-    /* initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
-
-    morse = morse_context_self();
-    if (morse == NULL) {
-        morse_fatal_error("step4", "MORSE not initialized");
-        return MORSE_ERR_NOT_INITIALIZED;
+     /* Initialize MORSE with main parameters */
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
     }
 
-    /* question morse to get the block (tile) size (number of columns) */
-    NB = morse->nb;
+    /* Question morse to get the block (tile) size (number of columns) */
+    MORSE_Get( MORSE_TILE_SIZE, &NB );
 
     /* Initialize the structure required for MORSE tile interface */
     MORSE_Desc_Create(&descA,  NULL, MorseRealDouble,
@@ -136,7 +130,7 @@ int main(int argc, char *argv[]) {
 
     cpu_time = -cWtime();
 
-    morse_sequence_create(morse, &sequence);
+    MORSE_Sequence_Create(&sequence);
 
     /* Cholesky factorization:
      * A is replaced by its factorization L or L^T depending on uplo */
@@ -157,7 +151,7 @@ int main(int argc, char *argv[]) {
     RUNTIME_desc_getoncpu(descX);
 
     status = sequence->status;
-    morse_sequence_destroy(morse, sequence);
+    MORSE_Sequence_Destroy(sequence);
 
     cpu_time += cWtime();
 
diff --git a/example/lapack_to_morse/step5.c b/example/lapack_to_morse/step5.c
index 77c3ab073..a49a5ff82 100644
--- a/example/lapack_to_morse/step5.c
+++ b/example/lapack_to_morse/step5.c
@@ -4,7 +4,7 @@
  *                          of Tennessee Research Foundation.
  *                          All rights reserved.
  * @copyright (c) 2012-2014 Inria. All rights reserved.
- * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
+ * @copyright (c) 2012-2015 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
  *
  **/
 
@@ -56,9 +56,6 @@ int main(int argc, char *argv[]) {
     double anorm, bnorm, xnorm, eps, res;
     int hres;
 
-    /* Morse structure containing parameters and a structure to interact with
-     * the Runtime system */
-    MORSE_context_t *morse;
     /* MORSE sequence uniquely identifies a set of asynchronous function calls
      * sharing common exception handling */
     MORSE_sequence_t *sequence = NULL;
@@ -98,13 +95,10 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-    /* initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
-
-    morse = morse_context_self();
-    if (morse == NULL) {
-        morse_fatal_error("step5", "MORSE not initialized");
-        return MORSE_ERR_NOT_INITIALIZED;
+     /* Initialize MORSE with main parameters */
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
     }
 
     /* set some specific parameters related to MORSE: blocks size and inner-blocking size */
@@ -140,7 +134,7 @@ int main(int argc, char *argv[]) {
 
     cpu_time = -cWtime();
 
-    morse_sequence_create(morse, &sequence);
+    MORSE_Sequence_Create(&sequence);
 
     /* Cholesky factorization:
      * A is replaced by its factorization L or L^T depending on uplo */
@@ -161,7 +155,7 @@ int main(int argc, char *argv[]) {
     RUNTIME_desc_getoncpu(descX);
 
     status = sequence->status;
-    morse_sequence_destroy(morse, sequence);
+    MORSE_Sequence_Destroy(sequence);
 
     cpu_time += cWtime();
 
diff --git a/example/lapack_to_morse/step6.c b/example/lapack_to_morse/step6.c
index 5723f4a72..70e27d311 100644
--- a/example/lapack_to_morse/step6.c
+++ b/example/lapack_to_morse/step6.c
@@ -57,9 +57,6 @@ int main(int argc, char *argv[]) {
     double anorm, bnorm, xnorm, eps, res;
     int hres;
 
-    /* Morse structure containing parameters and a structure to interact with
-     * the Runtime system */
-    MORSE_context_t *morse;
     /* MORSE sequence uniquely identifies a set of asynchronous function calls
      * sharing common exception handling */
     MORSE_sequence_t *sequence = NULL;
@@ -74,9 +71,9 @@ int main(int argc, char *argv[]) {
 
     /* read arguments */
     read_args(argc, argv, iparam);
-    N          = iparam[IPARAM_N];
-    NB         = iparam[IPARAM_NB];
-    NRHS       = iparam[IPARAM_NRHS];
+    N    = iparam[IPARAM_N];
+    NB   = iparam[IPARAM_NB];
+    NRHS = iparam[IPARAM_NRHS];
 
     /* compute the algorithm complexity to evaluate performances */
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
@@ -96,13 +93,10 @@ int main(int argc, char *argv[]) {
     NCPU = iparam[IPARAM_THRDNBR];
     NGPU = iparam[IPARAM_NCUDAS];
 
-    /* initialize MORSE with main parameters */
-    MORSE_Init( NCPU, NGPU );
-
-    morse = morse_context_self();
-    if (morse == NULL) {
-        morse_fatal_error("step6", "MORSE not initialized");
-        return MORSE_ERR_NOT_INITIALIZED;
+     /* Initialize MORSE with main parameters */
+    if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
+        fprintf(stderr, "Error initializing MORSE library\n");
+        return EXIT_FAILURE;
     }
 
     /* set some specific parameters related to MORSE: blocks size and inner-blocking size */
@@ -162,7 +156,7 @@ int main(int argc, char *argv[]) {
 
     cpu_time = -cWtime();
 
-    morse_sequence_create(morse, &sequence);
+    MORSE_Sequence_Create(&sequence);
 
     /* Cholesky factorization:
      * A is replaced by its factorization L or L^T depending on uplo */
@@ -183,7 +177,7 @@ int main(int argc, char *argv[]) {
     RUNTIME_desc_getoncpu(descX);
 
     status = sequence->status;
-    morse_sequence_destroy(morse, sequence);
+    MORSE_Sequence_Destroy(sequence);
 
     cpu_time += cWtime();
 
-- 
GitLab