codelet_zlange.c 3.7 KB
Newer Older
1
/**
2
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
3
 * @file starpu/codelet_zlange.c
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2014 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.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon zlange StarPU codelet
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15
 * @comment This file has been automatically generated
Mathieu Faverge's avatar
Mathieu Faverge committed
16
 *          from Plasma 2.6.0 for CHAMELEON 1.0.0
17 18 19 20 21 22
 * @author Julien Langou
 * @author Henricus Bouwmeester
 * @author Mathieu Faverge
 * @date 2010-11-15
 * @precisions normal z -> c d s
 *
23
 */
24 25
#include "chameleon_starpu.h"
#include "runtime_codelet_z.h"
26

Mathieu Faverge's avatar
Mathieu Faverge committed
27 28 29 30
void INSERT_TASK_zlange(const RUNTIME_option_t *options,
                       cham_normtype_t norm, int M, int N, int NB,
                       const CHAM_desc_t *A, int Am, int An, int LDA,
                       const CHAM_desc_t *B, int Bm, int Bn)
31 32 33 34
{
    (void)NB;
    struct starpu_codelet *codelet = &cl_zlange;
    void (*callback)(void*) = options->profiling ? cl_zlange_callback : NULL;
35

Mathieu Faverge's avatar
Mathieu Faverge committed
36 37 38 39
    CHAMELEON_BEGIN_ACCESS_DECLARATION;
    CHAMELEON_ACCESS_R(A, Am, An);
    CHAMELEON_ACCESS_W(B, Bm, Bn);
    CHAMELEON_END_ACCESS_DECLARATION;
THIBAULT Samuel's avatar
THIBAULT Samuel committed
40 41 42

    starpu_insert_task(
        starpu_mpi_codelet(codelet),
Mathieu Faverge's avatar
Mathieu Faverge committed
43
        STARPU_VALUE,    &norm,              sizeof(int),
THIBAULT Samuel's avatar
THIBAULT Samuel committed
44 45
        STARPU_VALUE,    &M,                 sizeof(int),
        STARPU_VALUE,    &N,                 sizeof(int),
Mathieu Faverge's avatar
Mathieu Faverge committed
46
        STARPU_R,        RTBLKADDR(A, CHAMELEON_Complex64_t, Am, An),
THIBAULT Samuel's avatar
THIBAULT Samuel committed
47 48 49 50 51
        STARPU_VALUE,    &LDA,               sizeof(int),
        STARPU_SCRATCH,  options->ws_worker,
        STARPU_W,        RTBLKADDR(B, double, Bm, Bn),
        STARPU_PRIORITY, options->priority,
        STARPU_CALLBACK, callback,
52
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
53
        STARPU_NAME, "zlange",
54
#endif
THIBAULT Samuel's avatar
THIBAULT Samuel committed
55
        0);
56 57
}

58
#if !defined(CHAMELEON_SIMULATION)
59 60 61
static void cl_zlange_cpu_func(void *descr[], void *cl_arg)
{
    double *normA;
Mathieu Faverge's avatar
Mathieu Faverge committed
62
    cham_normtype_t norm;
63 64
    int M;
    int N;
Mathieu Faverge's avatar
Mathieu Faverge committed
65
    CHAMELEON_Complex64_t *A;
66 67 68
    int LDA;
    double *work;

Mathieu Faverge's avatar
Mathieu Faverge committed
69
    A     = (CHAMELEON_Complex64_t *)STARPU_MATRIX_GET_PTR(descr[0]);
70 71 72
    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);
Mathieu Faverge's avatar
Mathieu Faverge committed
73
    CORE_zlange( norm, M, N, A, LDA, work, normA );
74
}
75
#endif /* !defined(CHAMELEON_SIMULATION) */
76 77 78 79 80 81

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

Mathieu Faverge's avatar
Mathieu Faverge committed
82 83 84
void INSERT_TASK_zlange_max(const RUNTIME_option_t *options,
                           const CHAM_desc_t *A, int Am, int An,
                           const CHAM_desc_t *B, int Bm, int Bn)
85 86 87
{
    struct starpu_codelet *codelet = &cl_zlange_max;
    void (*callback)(void*) = options->profiling ? cl_zlange_callback : NULL;
88

Mathieu Faverge's avatar
Mathieu Faverge committed
89 90 91 92 93 94 95 96 97 98 99
    CHAMELEON_BEGIN_ACCESS_DECLARATION;
    CHAMELEON_ACCESS_R(  A, Am, An );
    CHAMELEON_ACCESS_RW( B, Bm, Bn );
    CHAMELEON_END_ACCESS_DECLARATION;

    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,
100
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
Mathieu Faverge's avatar
Mathieu Faverge committed
101
        STARPU_NAME, "zlange_max",
102
#endif
Mathieu Faverge's avatar
Mathieu Faverge committed
103
        0);
104 105
}

106
#if !defined(CHAMELEON_SIMULATION)
107 108 109
static void cl_zlange_max_cpu_func(void *descr[], void *cl_arg)
{
    double *A;
Mathieu Faverge's avatar
Mathieu Faverge committed
110
    double *B;
111

Mathieu Faverge's avatar
Mathieu Faverge committed
112 113
    A = (double *)STARPU_MATRIX_GET_PTR(descr[0]);
    B = (double *)STARPU_MATRIX_GET_PTR(descr[1]);
114

Mathieu Faverge's avatar
Mathieu Faverge committed
115 116 117
    if ( *A > *B ) {
        *B = *A;
    }
118
    (void)cl_arg;
119
}
120
#endif /* !defined(CHAMELEON_SIMULATION) */
121 122 123 124 125

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