pmap.c 1.99 KB
Newer Older
Mathieu Faverge's avatar
Mathieu Faverge committed
1 2 3 4
/**
 *
 * @file pmap.c
 *
PRUVOST Florent's avatar
PRUVOST Florent committed
5
 * @copyright 2018-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
Mathieu Faverge's avatar
Mathieu Faverge committed
6 7 8 9 10 11
 *                      Univ. Bordeaux. All rights reserved.
 *
 ***
 *
 * @brief Chameleon map parallel algorithm
 *
PRUVOST Florent's avatar
PRUVOST Florent committed
12
 * @version 0.9.2
Mathieu Faverge's avatar
Mathieu Faverge committed
13 14 15 16 17 18 19 20 21 22 23 24 25 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
 * @author Mathieu Faverge
 * @date 2018-09-24
 *
 */
#include "control/common.h"

#define A(m, n) A,  m,  n
/**
 *  chameleon_pmap - Generate a random matrix by tiles.
 */
void chameleon_pmap( cham_uplo_t uplo, CHAM_desc_t *A,
                     cham_unary_operator_t operator, void *op_args,
                     RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
{
    CHAM_context_t *chamctxt;
    RUNTIME_option_t options;
    int m, n;

    chamctxt = chameleon_context_self();
    if (sequence->status != CHAMELEON_SUCCESS)
        return;
    RUNTIME_options_init(&options, chamctxt, sequence, request);

    switch( uplo ) {
    case ChamUpper:
        for (n = 0; n < A->nt; n++) {
            for (m = 0; m < n; m++) {
                INSERT_TASK_map(
                    &options,
                    ChamUpperLower, A(m, n),
                    operator, op_args );
            }
            INSERT_TASK_map(
                &options,
                uplo, A(n, n),
                operator, op_args );
        }
        break;

    case ChamLower:
        for (n = 0; n < A->nt; n++) {
            INSERT_TASK_map(
                &options,
                uplo, A(n, n),
                operator, op_args );
            for (m = n+1; m < A->mt; m++) {
                INSERT_TASK_map(
                    &options,
                    ChamUpperLower, A(m, n),
                    operator, op_args );
            }
        }
        break;

    case ChamUpperLower:
    default:
        for (m = 0; m < A->mt; m++) {
            for (n = 0; n < A->nt; n++) {
                INSERT_TASK_map(
                    &options,
                    uplo, A(m, n),
                    operator, op_args );
            }
        }
    }

    RUNTIME_options_finalize(&options, chamctxt);
}