From 8aee6e961f5c43c44dba3376ecdbc8c9253d8130 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Thu, 25 Aug 2016 15:40:39 +0000
Subject: [PATCH] chameleon: add new versions of random mat generator to fill
 only half of a symmetric matrix

---
 compute/CMakeLists.txt |   4 +
 compute/pzplghe2.c     |  93 ++++++++++++++
 compute/pzplgsy2.c     |  88 ++++++++++++++
 compute/zplghe2.c      | 268 +++++++++++++++++++++++++++++++++++++++++
 compute/zplgsy2.c      | 267 ++++++++++++++++++++++++++++++++++++++++
 control/compute_z.h    |   4 +
 include/morse_z.h      |   6 +
 7 files changed, 730 insertions(+)
 create mode 100644 compute/pzplghe2.c
 create mode 100644 compute/pzplgsy2.c
 create mode 100644 compute/zplghe2.c
 create mode 100644 compute/zplgsy2.c

diff --git a/compute/CMakeLists.txt b/compute/CMakeLists.txt
index 35c94da45..e8aa512c7 100644
--- a/compute/CMakeLists.txt
+++ b/compute/CMakeLists.txt
@@ -97,7 +97,9 @@ set(ZSRC
     pzlaset.c
     pzlauum.c
     pzplghe.c
+    pzplghe2.c
     pzplgsy.c
+    pzplgsy2.c
     pzplrnt.c
     pzpotrf.c
     pzsytrf.c
@@ -133,7 +135,9 @@ set(ZSRC
     zlaset.c
     zlauum.c
     zplghe.c
+    zplghe2.c
     zplgsy.c
+    zplgsy2.c
     zplrnt.c
     zposv.c
     zsysv.c
diff --git a/compute/pzplghe2.c b/compute/pzplghe2.c
new file mode 100644
index 000000000..439e3fc12
--- /dev/null
+++ b/compute/pzplghe2.c
@@ -0,0 +1,93 @@
+/**
+ *
+ * @copyright (c) 2009-2014 The University of Tennessee and The University
+ *                          of Tennessee Research Foundation.
+ *                          All rights reserved.
+ * @copyright (c) 2012-2016 Inria. All rights reserved.
+ * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
+ *
+ **/
+
+/**
+ *
+ * @file pzplghe2.c
+ *
+ *  MORSE auxiliary routines
+ *  MORSE is a software package provided by Univ. of Tennessee,
+ *  Univ. of California Berkeley and Univ. of Colorado Denver
+ *
+ * @version 2.5.0
+ * @comment This file is a copy from pzplghe.c
+ *          wich has been automatically generated
+ *          from Plasma 2.5.0 for MORSE 1.0.0
+ * @author Mathieu Faverge
+ * @author Emmanuel Agullo
+ * @author Cedric Castagnede
+ * @author Rade Mathis
+ * @date 2016-08-01
+ * @precisions normal z -> c
+ *
+ **/
+#include "control/common.h"
+
+#define A(m,n) A,  m,  n
+/***************************************************************************//**
+ *  Parallel tile Cholesky factorization - dynamic scheduling - half generation
+ **/
+void morse_pzplghe2( double bump, MORSE_desc_t *A, unsigned long long int seed,
+                     MORSE_enum uplo, MORSE_sequence_t *sequence,
+                     MORSE_request_t *request )
+{
+    MORSE_context_t *morse;
+    MORSE_option_t options;
+
+    int m, n;
+    int ldam;
+    int tempmm, tempnn;
+
+    morse = morse_context_self();
+    if (sequence->status != MORSE_SUCCESS)
+        return;
+    RUNTIME_options_init(&options, morse, sequence, request);
+
+    /*
+     *  MorseLower
+     */
+    if (uplo == MorseLower) {
+        for (m = 0; m < A->mt; m++) {
+        tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
+            ldam = BLKLDD(A, m);
+
+            for (n = 0; n <= m; n++) {
+                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
+
+                options.priority = m + n;
+                MORSE_TASK_zplghe(
+                    &options,
+                    bump, tempmm, tempnn, A(m, n), ldam,
+                    A->m, m*A->mb, n*A->nb, seed );
+            }
+        }
+    }
+    /*
+     * MorseUpper
+     */
+    else {
+        for (m = 0; m < A->mt; m++) {
+            tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
+            ldam = BLKLDD(A, m);
+
+            for (n = m; n < A->nt; n++) {
+                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
+
+                options.priority = m + n;
+                MORSE_TASK_zplghe(
+                    &options,
+                    bump, tempmm, tempnn, A(m, n), ldam,
+                    A->m, m*A->mb, n*A->nb, seed );
+            }
+        }
+    }
+    RUNTIME_options_finalize(&options, morse);
+    MORSE_TASK_dataflush_all();
+}
diff --git a/compute/pzplgsy2.c b/compute/pzplgsy2.c
new file mode 100644
index 000000000..6d44848ff
--- /dev/null
+++ b/compute/pzplgsy2.c
@@ -0,0 +1,88 @@
+/**
+ *
+ * @copyright (c) 2009-2014 The University of Tennessee and The University
+ *                          of Tennessee Research Foundation.
+ *                          All rights reserved.
+ * @copyright (c) 2012-2016 Inria. All rights reserved.
+ * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
+ *
+ **/
+
+/**
+ *
+ * @file pzplgsy2.c
+ *
+ *  MORSE auxiliary routines
+ *  MORSE is a software package provided by Univ. of Tennessee,
+ *  Univ. of California Berkeley and Univ. of Colorado Denver
+ *
+ * @version 2.5.0
+ * @comment This file is a copy of pzplgsy.c,
+            wich has been automatically generated
+ *          from Plasma 2.5.0 for MORSE 1.0.0
+ * @author Mathieu Faverge
+ * @author Emmanuel Agullo
+ * @author Cedric Castagnede
+ * @author Rade Mathis
+ * @date 2016-08-01
+ * @precisions normal z -> c d s
+ *
+ **/
+#include "control/common.h"
+
+#define A(m,n) A,  m,  n
+/***************************************************************************//**
+ *  Parallel tile random 'half' simetrical matrix generation- dynamic scheduling
+ **/
+void morse_pzplgsy2( MORSE_Complex64_t bump, MORSE_desc_t *A,
+                     unsigned long long int seed, MORSE_enum uplo,
+                     MORSE_sequence_t *sequence, MORSE_request_t *request )
+{
+    MORSE_context_t *morse;
+    MORSE_option_t options;
+
+    int m, n;
+    int ldam;
+    int tempmm, tempnn;
+
+    morse = morse_context_self();
+    if (sequence->status != MORSE_SUCCESS)
+        return;
+    RUNTIME_options_init(&options, morse, sequence, request);
+
+    for (m = 0; m < A->mt; m++) {
+        tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
+        ldam = BLKLDD(A, m);
+
+        /*
+         * MorseLower
+         */
+        if (uplo == MorseLower) {
+            for (n = 0; n <= m; n++) {
+                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
+
+                options.priority = m + n;
+                MORSE_TASK_zplgsy(
+                    &options,
+                    bump, tempmm, tempnn, A(m, n), ldam,
+                    A->m, m*A->mb, n*A->nb, seed );
+            }
+        }
+        /*
+         * MorseUpper
+         */
+        else {
+            for (n = m; n < A->nt; n++) {
+                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
+
+                options.priority = m + n;
+                MORSE_TASK_zplgsy(
+                    &options,
+                    bump, tempmm, tempnn, A(m, n), ldam,
+                    A->m, m*A->mb, n*A->nb, seed );
+            }
+        }
+    }
+    RUNTIME_options_finalize(&options, morse);
+    MORSE_TASK_dataflush_all();
+}
diff --git a/compute/zplghe2.c b/compute/zplghe2.c
new file mode 100644
index 000000000..689e2d67c
--- /dev/null
+++ b/compute/zplghe2.c
@@ -0,0 +1,268 @@
+/**
+ *
+ * @copyright (c) 2009-2014 The University of Tennessee and The University
+ *                          of Tennessee Research Foundation.
+ *                          All rights reserved.
+ * @copyright (c) 2012-2016 Inria. All rights reserved.
+ * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
+ *
+ **/
+
+/**
+ *
+ * @file zplghe2.c
+ *
+ *  MORSE computational routines
+ *  MORSE is a software package provided by Univ. of Tennessee,
+ *  Univ. of California Berkeley and Univ. of Colorado Denver
+ *
+ * @version 2.5.0
+ * @comment This file is a copy of zplghe.c
+ *          wich has been automatically generated
+ *          from Plasma 2.5.0 for MORSE 1.0.0
+ * @author Mathieu Faverge
+ * @author Emmanuel Agullo
+ * @author Cedric Castagnede
+ * @author Rade Mathis
+ * @date 2016-08-01
+ * @precisions normal z -> c
+ *
+ **/
+#include "control/common.h"
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t
+ *
+ *  MORSE_zplghe2 - One 'half' of a random hermitian matrix by tiles.
+ *
+ *******************************************************************************
+ *
+ * @param[in] bump
+ *          The value to add to the diagonal to be sure
+ *          to have a positive definite matrix.
+ *
+ * @param[in] N
+ *          The order of the matrix A. N >= 0.
+ *
+ * @param[out] A
+ *          On exit, The random hermitian matrix A generated.
+ *
+ * @param[in] LDA
+ *          The leading dimension of the array A. LDA >= max(1,M).
+ *
+ * @param[in] seed
+ *          The seed used in the random generation.
+ *
+ * @param[in] uplo
+ *          The part of the Matrix wich will be generated.
+ *
+ *******************************************************************************
+ *
+ * @return
+ *          \retval MORSE_SUCCESS successful exit
+ *          \retval <0 if -i, the i-th argument had an illegal value
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplghe2_Tile
+ * @sa MORSE_zplghe2_Tile_Async
+ * @sa MORSE_cplghe2
+ * @sa MORSE_dplghe2
+ * @sa MORSE_splghe2
+ * @sa MORSE_zplgsy2
+ *
+ ******************************************************************************/
+int MORSE_zplghe2( double bump, int N,
+                   MORSE_Complex64_t *A, int LDA,
+                   unsigned long long int seed, MORSE_enum uplo )
+{
+    int NB;
+    int status;
+    MORSE_context_t *morse;
+    MORSE_sequence_t *sequence = NULL;
+    MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
+    MORSE_desc_t descA;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplghe2", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    /* Check input arguments */
+    if (N < 0) {
+        morse_error("MORSE_zplghe2", "illegal value of N");
+        return -2;
+    }
+    if (LDA < max(1, N)) {
+        morse_error("MORSE_zplghe2", "illegal value of LDA");
+        return -4;
+    }
+    /* Quick return */
+    if (max(0, N) == 0)
+        return MORSE_SUCCESS;
+
+    /* Tune NB depending on M, N & NRHS; Set NBNB */
+    status = morse_tune(MORSE_FUNC_ZGEMM, N, N, 0);
+    if (status != MORSE_SUCCESS) {
+        morse_error("MORSE_zplghe2", "morse_tune() failed");
+        return status;
+    }
+
+    /* Set NT */
+    NB = MORSE_NB;
+    morse_sequence_create(morse, &sequence);
+
+    morse_zdesc_alloc(descA, NB, NB, LDA, N, 0, 0, N, N, morse_desc_mat_free(&descA));
+
+    /* Call the tile interface */
+    MORSE_zplghe2_Tile_Async( bump, &descA, seed, uplo, sequence, &request );
+
+    morse_zooptile2lap(descA, A, NB, NB, LDA, N,  sequence, &request);
+    morse_sequence_wait(morse, sequence);
+    morse_desc_mat_free(&descA);
+
+    status = sequence->status;
+    morse_sequence_destroy(morse, sequence);
+
+    return status;
+}
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t_Tile
+ *
+ *  MORSE_zplghe2_Tile - Generate 'half' of a random hermitian matrix by tiles.
+ *  Tile equivalent of MORSE_zplghe2().
+ *  Operates on matrices stored by tiles.
+ *  All matrices are passed through descriptors.
+ *  All dimensions are taken from the descriptors.
+ *
+ *******************************************************************************
+ *
+ * @param[in] bump
+ *          The value to add to the diagonal to be sure
+ *          to have a positive definite matrix.
+ *
+ * @param[in] A
+ *          On exit, The random hermitian matrix A generated.
+ *
+ * @param[in] seed
+ *          The seed used in the random generation.
+ *
+ * @param[in] uplo
+ *          The part of the Matrix wich will be generated.
+ *
+ *******************************************************************************
+ *
+ * @return
+ *          \retval MORSE_SUCCESS successful exit
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplghe2
+ * @sa MORSE_zplghe2_Tile_Async
+ * @sa MORSE_cplghe2_Tile
+ * @sa MORSE_dplghe2_Tile
+ * @sa MORSE_splghe2_Tile
+ * @sa MORSE_zplgsy2_Tile
+ *
+ ******************************************************************************/
+int MORSE_zplghe2_Tile( double bump, MORSE_desc_t *A,
+                       unsigned long long int seed, MORSE_enum uplo )
+{
+    MORSE_context_t *morse;
+    MORSE_sequence_t *sequence = NULL;
+    MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
+    int status;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplghe2_Tile", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    morse_sequence_create(morse, &sequence);
+    MORSE_zplghe2_Tile_Async( bump, A, seed, uplo, sequence, &request );
+    morse_sequence_wait(morse, sequence);
+    status = sequence->status;
+    morse_sequence_destroy(morse, sequence);
+    return status;
+}
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t_Tile_Async
+ *
+ *  MORSE_zplghe2_Tile_Async - Generate a half random hermitian matrix by tiles.
+ *  Non-blocking equivalent of MORSE_zplghe2_Tile().
+ *  May return before the computation is finished.
+ *  Allows for pipelining of operations at runtime.
+ *
+ *******************************************************************************
+ *
+ * @param[in] sequence
+ *          Identifies the sequence of function calls that this call belongs to
+ *          (for completion checks and exception handling purposes).
+ *
+ * @param[out] request
+ *          Identifies this function call (for exception handling purposes).
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplghe2
+ * @sa MORSE_zplghe2_Tile
+ * @sa MORSE_cplghe2_Tile_Async
+ * @sa MORSE_dplghe2_Tile_Async
+ * @sa MORSE_splghe2_Tile_Async
+ * @sa MORSE_zplghe2_Tile_Async
+ * @sa MORSE_zplgsy2_Tile_Async
+ *
+ ******************************************************************************/
+int MORSE_zplghe2_Tile_Async( double                 bump,
+                              MORSE_desc_t             *A,
+                              unsigned long long int seed,
+                              MORSE_enum             uplo,
+                              MORSE_sequence_t  *sequence,
+                              MORSE_request_t    *request )
+{
+    MORSE_context_t *morse;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplghe2_Tile", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    if (sequence == NULL) {
+        morse_fatal_error("MORSE_zplghe2_Tile", "NULL sequence");
+        return MORSE_ERR_UNALLOCATED;
+    }
+    if (request == NULL) {
+        morse_fatal_error("MORSE_zplghe2_Tile", "NULL request");
+        return MORSE_ERR_UNALLOCATED;
+    }
+    /* Check sequence status */
+    if (sequence->status == MORSE_SUCCESS)
+        request->status = MORSE_SUCCESS;
+    else
+        return morse_request_fail(sequence, request, MORSE_ERR_SEQUENCE_FLUSHED);
+
+    /* Check descriptors for correctness */
+    if (morse_desc_check(A) != MORSE_SUCCESS) {
+        morse_error("MORSE_zplghe2_Tile", "invalid descriptor");
+        return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);
+    }
+    /* Check input arguments */
+    if (A->nb != A->mb) {
+        morse_error("MORSE_zplghe2_Tile", "only square tiles supported");
+        return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);
+    }
+
+    /* Quick return */
+    if (min( A->m, A->n ) == 0)
+        return MORSE_SUCCESS;
+
+
+    morse_pzplghe2(bump,      A, seed, uplo, sequence,  request);
+
+    return MORSE_SUCCESS;
+}
diff --git a/compute/zplgsy2.c b/compute/zplgsy2.c
new file mode 100644
index 000000000..05b2682c7
--- /dev/null
+++ b/compute/zplgsy2.c
@@ -0,0 +1,267 @@
+/**
+ *
+ * @copyright (c) 2009-2014 The University of Tennessee and The University
+ *                          of Tennessee Research Foundation.
+ *                          All rights reserved.
+ * @copyright (c) 2012-2016 Inria. All rights reserved.
+ * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
+ *
+ **/
+
+/**
+ *
+ * @file zplgsy2.c
+ *
+ *  MORSE computational routines
+ *  MORSE is a software package provided by Univ. of Tennessee,
+ *  Univ. of California Berkeley and Univ. of Colorado Denver
+ *
+ * @version 2.5.0
+ * @comment This file is a copy of zplgsy.c,
+ *          wich has been automatically generated
+ *          from Plasma 2.5.0 for MORSE 1.0.0
+ * @author Mathieu Faverge
+ * @author Emmanuel Agullo
+ * @author Cedric Castagnede
+ * @author Rade Mathis
+ * @date 2016-08-01
+ * @precisions normal z -> c d s
+ *
+ **/
+#include "control/common.h"
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t
+ *
+ *  MORSE_zplgsy2 - Generate 'half' of a random simetrical matrix by tiles.
+ *
+ *******************************************************************************
+ *
+ * @param[in] bump
+ *          The value to add to the diagonal to be sure
+ *          to have a positive definite matrix.
+ *
+ * @param[in] N
+ *          The order of the matrix A. N >= 0.
+ *
+ * @param[out] A
+ *          On exit, The random hermitian matrix A generated.
+ *
+ * @param[in] LDA
+ *          The leading dimension of the array A. LDA >= max(1,M).
+ *
+ * @param[in] seed
+ *          The seed used in the random generation.
+ *
+ * @param[in] uplo
+ *          The half of the matrix that will be generated.
+ *
+ *******************************************************************************
+ *
+ * @return
+ *          \retval MORSE_SUCCESS successful exit
+ *          \retval <0 if -i, the i-th argument had an illegal value
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplgsy2_Tile
+ * @sa MORSE_zplgsy2_Tile_Async
+ * @sa MORSE_cplgsy2
+ * @sa MORSE_dplgsy2
+ * @sa MORSE_splgsy2
+ * @sa MORSE_zplgsy2
+ *
+ ******************************************************************************/
+int MORSE_zplgsy2( MORSE_Complex64_t bump, int N,
+                   MORSE_Complex64_t *A, int LDA,
+                   unsigned long long int seed, MORSE_enum uplo )
+{
+    int NB;
+    int status;
+    MORSE_context_t *morse;
+    MORSE_sequence_t *sequence = NULL;
+    MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
+    MORSE_desc_t descA;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplgsy2", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    /* Check input arguments */
+    if (N < 0) {
+        morse_error("MORSE_zplgsy2", "illegal value of N");
+        return -2;
+    }
+    if (LDA < max(1, N)) {
+        morse_error("MORSE_zplgsy2", "illegal value of LDA");
+        return -4;
+    }
+    /* Quick return */
+    if (max(0, N) == 0)
+        return MORSE_SUCCESS;
+
+    /* Tune NB depending on M, N & NRHS; Set NBNB */
+    status = morse_tune(MORSE_FUNC_ZGEMM, N, N, 0);
+    if (status != MORSE_SUCCESS) {
+        morse_error("MORSE_zplgsy2", "morse_tune() failed");
+        return status;
+    }
+
+    /* Set NT */
+    NB = MORSE_NB;
+    morse_sequence_create(morse, &sequence);
+
+    morse_zdesc_alloc(descA, NB, NB, LDA, N, 0, 0, N, N, morse_desc_mat_free(&descA));
+
+    /* Call the tile interface */
+    MORSE_zplgsy2_Tile_Async( bump, &descA, seed, uplo, sequence, &request );
+
+    morse_zooptile2lap(descA, A, NB, NB, LDA, N,  sequence, &request);
+    morse_sequence_wait(morse, sequence);
+    morse_desc_mat_free(&descA);
+
+    status = sequence->status;
+    morse_sequence_destroy(morse, sequence);
+
+    return status;
+}
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t_Tile
+ *
+ *  MORSE_zplgsy2_Tile - Generate 'half' of a random simetrical matrix by tiles.
+ *  Tile equivalent of MORSE_zplgsy2().
+ *  Operates on matrices stored by tiles.
+ *  All matrices are passed through descriptors.
+ *  All dimensions are taken from the descriptors.
+ *
+ *******************************************************************************
+ *
+ * @param[in] bump
+ *          The value to add to the diagonal to be sure
+ *          to have a positive definite matrix.
+ *
+ * @param[in] A
+ *          On exit, The random hermitian matrix A generated.
+ *
+ * @param[in] seed
+ *          The seed used in the random generation.
+ *
+ * @param[in] uplo
+ *          The half of the matrix that will be generated.
+ *
+ *******************************************************************************
+ *
+ * @return
+ *          \retval MORSE_SUCCESS successful exit
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplgsy2
+ * @sa MORSE_zplgsy2_Tile_Async
+ * @sa MORSE_cplgsy2_Tile
+ * @sa MORSE_dplgsy2_Tile
+ * @sa MORSE_splgsy2_Tile
+ * @sa MORSE_zplgsy2_Tile
+ *
+ ******************************************************************************/
+int MORSE_zplgsy2_Tile( MORSE_Complex64_t bump, MORSE_desc_t *A,
+                        unsigned long long int seed, MORSE_enum uplo )
+{
+    MORSE_context_t *morse;
+    MORSE_sequence_t *sequence = NULL;
+    MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
+    int status;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplgsy2_Tile", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    morse_sequence_create(morse, &sequence);
+    MORSE_zplgsy2_Tile_Async( bump, A, seed, uplo, sequence, &request );
+    morse_sequence_wait(morse, sequence);
+    status = sequence->status;
+    morse_sequence_destroy(morse, sequence);
+    return status;
+}
+
+/***************************************************************************//**
+ *
+ * @ingroup MORSE_Complex64_t_Tile_Async
+ *
+ *  MORSE_zplgsy2_Tile_Async - Generate a random hermitian matrix by tiles.
+ *  Non-blocking equivalent of MORSE_zplgsy2_Tile().
+ *  May return before the computation is finished.
+ *  Allows for pipelining of operations at runtime.
+ *
+ *******************************************************************************
+ *
+ * @param[in] sequence
+ *          Identifies the sequence of function calls that this call belongs to
+ *          (for completion checks and exception handling purposes).
+ *
+ * @param[out] request
+ *          Identifies this function call (for exception handling purposes).
+ *
+ *******************************************************************************
+ *
+ * @sa MORSE_zplgsy
+ * @sa MORSE_zplgsy_Tile
+ * @sa MORSE_cplgsy_Tile_Async
+ * @sa MORSE_dplgsy_Tile_Async
+ * @sa MORSE_splgsy_Tile_Async
+ * @sa MORSE_zplgsy_Tile_Async
+ * @sa MORSE_zplgsy_Tile_Async
+ *
+ ******************************************************************************/
+int MORSE_zplgsy2_Tile_Async( MORSE_Complex64_t      bump,
+                             MORSE_desc_t             *A,
+                             unsigned long long int seed,
+                             MORSE_enum             uplo,
+                             MORSE_sequence_t  *sequence,
+                             MORSE_request_t    *request )
+{
+    MORSE_context_t *morse;
+
+    morse = morse_context_self();
+    if (morse == NULL) {
+        morse_fatal_error("MORSE_zplgsy2_Tile", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    if (sequence == NULL) {
+        morse_fatal_error("MORSE_zplgsy2_Tile", "NULL sequence");
+        return MORSE_ERR_UNALLOCATED;
+    }
+    if (request == NULL) {
+        morse_fatal_error("MORSE_zplgsy2_Tile", "NULL request");
+        return MORSE_ERR_UNALLOCATED;
+    }
+    /* Check sequence status */
+    if (sequence->status == MORSE_SUCCESS)
+        request->status = MORSE_SUCCESS;
+    else
+        return morse_request_fail(sequence, request, MORSE_ERR_SEQUENCE_FLUSHED);
+
+    /* Check descriptors for correctness */
+    if (morse_desc_check(A) != MORSE_SUCCESS) {
+        morse_error("MORSE_zplgsy2_Tile", "invalid descriptor");
+        return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);
+    }
+    /* Check input arguments */
+    if (A->nb != A->mb) {
+        morse_error("MORSE_zplgsy2_Tile", "only square tiles supported");
+        return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);
+    }
+
+    /* Quick return */
+    if (min( A->m, A->n ) == 0)
+        return MORSE_SUCCESS;
+
+    morse_pzplgsy2(bump, A, seed, uplo, sequence, request);
+
+    return MORSE_SUCCESS;
+}
diff --git a/control/compute_z.h b/control/compute_z.h
index 3d5cf4ae0..a7f502602 100644
--- a/control/compute_z.h
+++ b/control/compute_z.h
@@ -123,8 +123,12 @@ void morse_pzlaset2(MORSE_enum uplo, MORSE_Complex64_t alpha,
 void morse_pzlaswp(MORSE_desc_t *B, int *IPIV, int inc, MORSE_sequence_t *sequence, MORSE_request_t *request);
 void morse_pzlaswpc(MORSE_desc_t *B, int *IPIV, int inc, MORSE_sequence_t *sequence, MORSE_request_t *request);
 void morse_pzlauum(MORSE_enum uplo, MORSE_desc_t *A, MORSE_sequence_t *sequence, MORSE_request_t *request);
+#ifdef COMPLEX
 void morse_pzplghe(double bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request);
+void morse_pzplghe2(double bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo, MORSE_sequence_t *sequence, MORSE_request_t *request );
+#endif
 void morse_pzplgsy(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request );
+void morse_pzplgsy2(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo, MORSE_sequence_t *sequence, MORSE_request_t *request );
 void morse_pzplrnt(MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request );
 void morse_pzpotrf(MORSE_enum uplo, MORSE_desc_t *A, MORSE_sequence_t *sequence, MORSE_request_t *request);
 void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_desc_t *C, MORSE_sequence_t *sequence, MORSE_request_t *request);
diff --git a/include/morse_z.h b/include/morse_z.h
index 5587fa6fd..f9f4c7f63 100644
--- a/include/morse_z.h
+++ b/include/morse_z.h
@@ -87,8 +87,10 @@ int MORSE_zlaset(MORSE_enum uplo, int M, int N, MORSE_Complex64_t alpha, MORSE_C
 int MORSE_zlauum(MORSE_enum uplo, int N, MORSE_Complex64_t *A, int LDA);
 #ifdef COMPLEX
 int MORSE_zplghe( double bump, int N, MORSE_Complex64_t *A, int LDA, unsigned long long int seed );
+int MORSE_zplghe2( double bump, int N, MORSE_Complex64_t *A, int LDA, unsigned long long int seed, MORSE_enum uplo );
 #endif
 int MORSE_zplgsy( MORSE_Complex64_t bump, int N, MORSE_Complex64_t *A, int LDA, unsigned long long int seed );
+int MORSE_zplgsy2( MORSE_Complex64_t bump, int N, MORSE_Complex64_t *A, int LDA, unsigned long long int seed, MORSE_enum uplo );
 int MORSE_zplrnt( int M, int N, MORSE_Complex64_t *A, int LDA, unsigned long long int seed );
 int MORSE_zposv(MORSE_enum uplo, int N, int NRHS, MORSE_Complex64_t *A, int LDA, MORSE_Complex64_t *B, int LDB);
 int MORSE_zpotrf(MORSE_enum uplo, int N, MORSE_Complex64_t *A, int LDA);
@@ -163,8 +165,10 @@ int MORSE_zlaset_Tile(MORSE_enum uplo, MORSE_Complex64_t alpha, MORSE_Complex64_
 int MORSE_zlauum_Tile(MORSE_enum uplo, MORSE_desc_t *A);
 #ifdef COMPLEX
 int MORSE_zplghe_Tile(double bump, MORSE_desc_t *A, unsigned long long int seed );
+int MORSE_zplghe2_Tile(double bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo);
 #endif
 int MORSE_zplgsy_Tile(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed );
+int MORSE_zplgsy2_Tile(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo );
 int MORSE_zplrnt_Tile(MORSE_desc_t *A, unsigned long long int seed );
 int MORSE_zposv_Tile(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B);
 int MORSE_zpotrf_Tile(MORSE_enum uplo, MORSE_desc_t *A);
@@ -236,8 +240,10 @@ int MORSE_zlaset_Tile_Async(MORSE_enum uplo, MORSE_Complex64_t alpha, MORSE_Comp
 int MORSE_zlauum_Tile_Async(MORSE_enum uplo, MORSE_desc_t *A, MORSE_sequence_t *sequence, MORSE_request_t *request);
 #ifdef COMPLEX
 int MORSE_zplghe_Tile_Async(double bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request );
+int MORSE_zplghe2_Tile_Async(double bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo, MORSE_sequence_t *sequence, MORSE_request_t *request );
 #endif
 int MORSE_zplgsy_Tile_Async(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request );
+int MORSE_zplgsy2_Tile_Async(MORSE_Complex64_t bump, MORSE_desc_t *A, unsigned long long int seed, MORSE_enum uplo, MORSE_sequence_t *sequence, MORSE_request_t *request );
 int MORSE_zplrnt_Tile_Async(MORSE_desc_t *A, unsigned long long int seed, MORSE_sequence_t *sequence, MORSE_request_t *request );
 int MORSE_zposv_Tile_Async(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_sequence_t *sequence, MORSE_request_t *request);
 int MORSE_zpotrf_Tile_Async(MORSE_enum uplo, MORSE_desc_t *A, MORSE_sequence_t *sequence, MORSE_request_t *request);
-- 
GitLab