codelet_zlange.c 3.9 KB
Newer Older
1 2 3 4 5
/**
 *
 * @copyright (c) 2009-2014 The University of Tennessee and The University
 *                          of Tennessee Research Foundation.
 *                          All rights reserved.
6
 * @copyright (c) 2012-2016 Inria. All rights reserved.
7
 * @copyright (c) 2012-2014, 2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 **/

/**
 *
 * @file codelet_zlange.c
 *
 *  MORSE codelets kernel
 *  MORSE is a software package provided by Inria Bordeaux - Sud-Ouest, LaBRI,
 *  University of Bordeaux, Bordeaux INP
 *
 * @version 2.6.0
 * @comment This file has been automatically generated
 *          from Plasma 2.6.0 for MORSE 1.0.0
 * @author Julien Langou
 * @author Henricus Bouwmeester
 * @author Mathieu Faverge
 * @date 2010-11-15
 * @precisions normal z -> c d s
 *
 **/
29
#include "runtime/starpu/include/morse_starpu.h"
30
#include "runtime/starpu/include/runtime_codelet_z.h"
31
#include "chameleon/morse_tasks_z.h"
32

33
void MORSE_TASK_zlange(const MORSE_option_t *options,
34
                       MORSE_enum norm, int M, int N, int NB,
35 36
                       const MORSE_desc_t *A, int Am, int An, int LDA,
                       const MORSE_desc_t *B, int Bm, int Bn)
37 38 39 40
{
    (void)NB;
    struct starpu_codelet *codelet = &cl_zlange;
    void (*callback)(void*) = options->profiling ? cl_zlange_callback : NULL;
41

THIBAULT Samuel's avatar
THIBAULT Samuel committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    MORSE_BEGIN_ACCESS_DECLARATION;
    MORSE_ACCESS_R(A, Am, An);
    MORSE_ACCESS_W(B, Bm, Bn);
    MORSE_END_ACCESS_DECLARATION;

    starpu_insert_task(
        starpu_mpi_codelet(codelet),
        STARPU_VALUE,    &norm,              sizeof(MORSE_enum),
        STARPU_VALUE,    &M,                 sizeof(int),
        STARPU_VALUE,    &N,                 sizeof(int),
        STARPU_R,        RTBLKADDR(A, MORSE_Complex64_t, Am, An),
        STARPU_VALUE,    &LDA,               sizeof(int),
        STARPU_SCRATCH,  options->ws_worker,
        STARPU_W,        RTBLKADDR(B, double, Bm, Bn),
        STARPU_PRIORITY, options->priority,
        STARPU_CALLBACK, callback,
58
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
59
        STARPU_NAME, "zlange",
60
#endif
THIBAULT Samuel's avatar
THIBAULT Samuel committed
61
        0);
62 63
}

64
#if !defined(CHAMELEON_SIMULATION)
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
static void cl_zlange_cpu_func(void *descr[], void *cl_arg)
{
    double *normA;
    MORSE_enum norm;
    int M;
    int N;
    MORSE_Complex64_t *A;
    int LDA;
    double *work;

    A     = (MORSE_Complex64_t *)STARPU_MATRIX_GET_PTR(descr[0]);
    work  = (double *)STARPU_MATRIX_GET_PTR(descr[1]);
    normA = (double *)STARPU_MATRIX_GET_PTR(descr[2]);
    starpu_codelet_unpack_args(cl_arg, &norm, &M, &N, &LDA);
    CORE_zlange( norm, M, N, A, LDA, work, normA);
}
81
#endif /* !defined(CHAMELEON_SIMULATION) */
82 83 84 85 86 87

/*
 * Codelet definition
 */
CODELETS_CPU(zlange, 3, cl_zlange_cpu_func)

88
void MORSE_TASK_zlange_max(const MORSE_option_t *options,
89 90
                           const MORSE_desc_t *A, int Am, int An,
                           const MORSE_desc_t *B, int Bm, int Bn)
91 92 93
{
    struct starpu_codelet *codelet = &cl_zlange_max;
    void (*callback)(void*) = options->profiling ? cl_zlange_callback : NULL;
94

95
    if ( morse_desc_islocal( A, Am, An ) ||
96 97 98 99 100 101 102 103
         morse_desc_islocal( B, Bm, Bn ) )
    {
        starpu_insert_task(
            starpu_mpi_codelet(codelet),
            STARPU_R,        RTBLKADDR(A, double, Am, An),
            STARPU_RW,       RTBLKADDR(B, double, Bm, Bn),
            STARPU_PRIORITY, options->priority,
            STARPU_CALLBACK, callback,
104
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
105
            STARPU_NAME, "zlange_max",
106
#endif
107
            0);
108 109 110
    }
}

111
#if !defined(CHAMELEON_SIMULATION)
112 113 114 115 116 117 118 119 120 121
static void cl_zlange_max_cpu_func(void *descr[], void *cl_arg)
{
    double *A;
    double *normA;

    A     = (double *)STARPU_MATRIX_GET_PTR(descr[0]);
    normA = (double *)STARPU_MATRIX_GET_PTR(descr[1]);

    if ( *A > *normA )
        *normA = *A;
122 123

    (void)cl_arg;
124
}
125
#endif /* !defined(CHAMELEON_SIMULATION) */
126 127 128 129 130

/*
 * Codelet definition
 */
CODELETS_CPU(zlange_max, 2, cl_zlange_max_cpu_func)