codelet_zgeqrt.c 4.26 KB
Newer Older
Mathieu Faverge's avatar
Mathieu Faverge committed
1
/**
2
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
3
 * @file parsec/codelet_zgeqrt.c
Mathieu Faverge's avatar
Mathieu Faverge committed
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2015 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
Mathieu Faverge's avatar
Mathieu Faverge committed
7
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8
 *                      Univ. Bordeaux. All rights reserved.
Mathieu Faverge's avatar
Mathieu Faverge committed
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
Mathieu Faverge's avatar
Mathieu Faverge committed
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon zgeqrt PaRSEC codelet
Mathieu Faverge's avatar
Mathieu Faverge committed
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
Mathieu Faverge's avatar
Mathieu Faverge committed
15 16 17
 * @author Reazul Hoque
 * @precisions normal z -> c d s
 *
18
 */
19
#include "chameleon_parsec.h"
Mathieu Faverge's avatar
Mathieu Faverge committed
20
#include "chameleon/tasks_z.h"
21
#include "coreblas/coreblas_z.h"
Mathieu Faverge's avatar
Mathieu Faverge committed
22

23
/**
Mathieu Faverge's avatar
Mathieu Faverge committed
24
 *
PRUVOST Florent's avatar
PRUVOST Florent committed
25
 * @ingroup INSERT_TASK_Complex64_t
Mathieu Faverge's avatar
Mathieu Faverge committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
 *
 *  CORE_zgeqrt computes a QR factorization of a complex M-by-N tile A:
 *  A = Q * R.
 *
 *  The tile Q is represented as a product of elementary reflectors
 *
 *    Q = H(1) H(2) . . . H(k), where k = min(M,N).
 *
 *  Each H(i) has the form
 *
 *    H(i) = I - tau * v * v'
 *
 *  where tau is a complex scalar, and v is a complex vector with
 *  v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
 *  and tau in TAU(i).
 *
 *******************************************************************************
 *
 * @param[in] M
 *          The number of rows of the tile A.  M >= 0.
 *
 * @param[in] N
 *         The number of columns of the tile A.  N >= 0.
 *
 * @param[in] IB
 *         The inner-blocking size.  IB >= 0.
 *
 * @param[in,out] A
 *         On entry, the M-by-N tile A.
 *         On exit, the elements on and above the diagonal of the array
 *         contain the min(M,N)-by-N upper trapezoidal tile R (R is
 *         upper triangular if M >= N); the elements below the diagonal,
 *         with the array TAU, represent the unitary tile Q as a
 *         product of elementary reflectors (see Further Details).
 *
 * @param[in] LDA
 *         The leading dimension of the array A.  LDA >= max(1,M).
 *
 * @param[out] T
 *         The IB-by-N triangular factor T of the block reflector.
 *         T is upper triangular by block (economic storage);
 *         The rest of the array is not referenced.
 *
 * @param[in] LDT
 *         The leading dimension of the array T. LDT >= IB.
 *
 * @param[out] TAU
 *         The scalar factors of the elementary reflectors (see Further
 *         Details).
 *
 * @param[out] WORK
 *
 *******************************************************************************
 *
 * @return
Mathieu Faverge's avatar
Mathieu Faverge committed
81
 *          \retval CHAMELEON_SUCCESS successful exit
Mathieu Faverge's avatar
Mathieu Faverge committed
82 83
 *          \retval <0 if -i, the i-th argument had an illegal value
 *
84
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
85 86 87
static inline int
CORE_zgeqrt_parsec ( parsec_execution_stream_t *context,
                    parsec_task_t             *this_task )
Mathieu Faverge's avatar
Mathieu Faverge committed
88
{
89 90 91
    int m;
    int n;
    int ib;
Mathieu Faverge's avatar
Mathieu Faverge committed
92
    CHAMELEON_Complex64_t *A;
93
    int lda;
Mathieu Faverge's avatar
Mathieu Faverge committed
94
    CHAMELEON_Complex64_t *T;
95
    int ldt;
Mathieu Faverge's avatar
Mathieu Faverge committed
96 97
    CHAMELEON_Complex64_t *TAU;
    CHAMELEON_Complex64_t *WORK;
Mathieu Faverge's avatar
Mathieu Faverge committed
98

Mathieu Faverge's avatar
Mathieu Faverge committed
99
    parsec_dtd_unpack_args(
100
        this_task, &m, &n, &ib, &A, &lda, &T, &ldt, &TAU, &WORK );
Mathieu Faverge's avatar
Mathieu Faverge committed
101

Mathieu Faverge's avatar
Mathieu Faverge committed
102
    CORE_zlaset( ChamUpperLower, ib, n, 0., 0., T, ldt );
103
    CORE_zgeqrt( m, n, ib, A, lda, T, ldt, TAU, WORK );
Mathieu Faverge's avatar
Mathieu Faverge committed
104

Mathieu Faverge's avatar
Mathieu Faverge committed
105
    (void)context;
106
    return PARSEC_HOOK_RETURN_DONE;
Mathieu Faverge's avatar
Mathieu Faverge committed
107 108
}

Mathieu Faverge's avatar
Mathieu Faverge committed
109
void INSERT_TASK_zgeqrt(const RUNTIME_option_t *options,
Mathieu Faverge's avatar
Mathieu Faverge committed
110
                       int m, int n, int ib, int nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
111 112
                       const CHAM_desc_t *A, int Am, int An, int lda,
                       const CHAM_desc_t *T, int Tm, int Tn, int ldt)
Mathieu Faverge's avatar
Mathieu Faverge committed
113
{
Mathieu Faverge's avatar
Mathieu Faverge committed
114
    parsec_taskpool_t* PARSEC_dtd_taskpool = (parsec_taskpool_t *)(options->sequence->schedopt);
Mathieu Faverge's avatar
Mathieu Faverge committed
115

Mathieu Faverge's avatar
Mathieu Faverge committed
116 117
    parsec_dtd_taskpool_insert_task(
        PARSEC_dtd_taskpool, CORE_zgeqrt_parsec, options->priority, "geqrt",
118 119 120
        sizeof(int),           &m,                             VALUE,
        sizeof(int),           &n,                             VALUE,
        sizeof(int),           &ib,                            VALUE,
Mathieu Faverge's avatar
Mathieu Faverge committed
121
        PASSED_BY_REF,         RTBLKADDR( A, CHAMELEON_Complex64_t, Am, An ), chameleon_parsec_get_arena_index( A ) | INOUT | AFFINITY,
122
        sizeof(int),           &lda,                           VALUE,
Mathieu Faverge's avatar
Mathieu Faverge committed
123
        PASSED_BY_REF,         RTBLKADDR( T, CHAMELEON_Complex64_t, Tm, Tn ), chameleon_parsec_get_arena_index( T ) | OUTPUT,
124
        sizeof(int),           &ldt,                           VALUE,
Mathieu Faverge's avatar
Mathieu Faverge committed
125 126
        sizeof(CHAMELEON_Complex64_t)*nb,       NULL,                         SCRATCH,
        sizeof(CHAMELEON_Complex64_t)*ib*nb,    NULL,                         SCRATCH,
127
        PARSEC_DTD_ARG_END );
Mathieu Faverge's avatar
Mathieu Faverge committed
128
}