Mentions légales du service

Skip to content
Snippets Groups Projects
codelet_zpotrf.c 5.27 KiB
Newer Older
 * @file starpu/codelet_zpotrf.c
Mathieu Faverge's avatar
Mathieu Faverge committed
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
 * @copyright 2012-2025 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
 * @brief Chameleon zpotrf StarPU codelet
 * @author Hatem Ltaief
 * @author Jakub Kurzak
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
BARROS DE ASSIS Lucas's avatar
BARROS DE ASSIS Lucas committed
 * @author Lucas Barros de Assis
Mathieu Faverge's avatar
Mathieu Faverge committed
 * @author Florent Pruvost
 * @author Samuel Thibault
 * @author Terry Cojean
#include "runtime_codelet_z.h"
struct cl_zpotrf_args_s {
    cham_uplo_t         uplo;
    int                 n;
    int                 iinfo;
    RUNTIME_sequence_t *sequence;
    RUNTIME_request_t  *request;
};

#if !defined(CHAMELEON_SIMULATION)
static void
cl_zpotrf_cpu_func(void *descr[], void *cl_arg)
{
    struct cl_zpotrf_args_s *clargs = (struct cl_zpotrf_args_s *)cl_arg;
    int info = 0;

    assert( tileA->flttype == ChamComplexDouble );

    TCORE_zpotrf( clargs->uplo, clargs->n, tileA, &info );
    if ( (clargs->sequence->status == CHAMELEON_SUCCESS) && (info != 0) ) {
        RUNTIME_sequence_flush( NULL, clargs->sequence, clargs->request, clargs->iinfo+info );
    }
}
#endif /* !defined(CHAMELEON_SIMULATION) */

/*
 * Codelet definition
 */
#if defined(CHAMELEON_SIMULATION) && defined(CHAMELEON_SIMULATION_EXTENDED)
CODELETS( zpotrf, cl_zpotrf_cpu_func, cl_zpotrf_cuda_func, STARPU_CUDA_ASYNC )
#else
#if defined(CHAMELEON_STARPU_USE_INSERT)
void INSERT_TASK_zpotrf( const RUNTIME_option_t *options,
                         cham_uplo_t uplo, int n, int nb,
                         const CHAM_desc_t *A, int Am, int An,
                         int iinfo )
    void (*callback)(void*);
    struct cl_zpotrf_args_s *clargs  = NULL;
    int                      exec    = 0;
    const char              *cl_name = "zpotrf";
    CHAMELEON_BEGIN_ACCESS_DECLARATION;
    CHAMELEON_ACCESS_RW(A, Am, An);
    exec = __chameleon_need_exec;
    CHAMELEON_END_ACCESS_DECLARATION;
    if ( exec ) {
        clargs = malloc( sizeof( struct cl_zpotrf_args_s ) );
        clargs->uplo     = uplo;
        clargs->n        = n;
        clargs->iinfo    = iinfo;
        clargs->sequence = options->sequence;
        clargs->request  = options->request;
    }

    /* Callback fro profiling information */
    callback = options->profiling ? cl_zpotrf_callback : NULL;

    /* Refine name */
    cl_name = chameleon_codelet_name( cl_name, 1,
                                      A->get_blktile( A, Am, An ) );
        &cl_zpotrf,
        /* Task codelet arguments */
        STARPU_CL_ARGS, clargs, sizeof(struct cl_zpotrf_args_s),
        STARPU_RW,     RTBLKADDR(A, ChamComplexDouble, Am, An),

        /* Common task arguments */
        STARPU_PRIORITY,          options->priority,
        STARPU_CALLBACK,          callback,
        STARPU_EXECUTE_ON_WORKER, options->workerid,
        STARPU_POSSIBLY_PARALLEL, options->parallel,

#else

void INSERT_TASK_zpotrf( const RUNTIME_option_t *options,
                         cham_uplo_t uplo, int n, int nb,
                         const CHAM_desc_t *A, int Am, int An,
                         int iinfo )
{
    INSERT_TASK_COMMON_PARAMETERS( zpotrf, 1 );

    /*
     * Set the data handles and initialize exchanges if needed
     */
    starpu_cham_exchange_init_params( options, &params, A->get_rankof( A, Am, An ) );
    starpu_cham_exchange_data_before_execution( options, &params, &nbdata, descrs, A, Am, An, STARPU_RW );

    /*
     * Not involved, let's return
     */
    if ( nbdata == 0 ) {
        return;
    }

    if ( params.do_execute )
    {
        int ret;
        struct starpu_task *task = starpu_task_create();
        task->cl = cl;

        /* Set codelet parameters */
        clargs = malloc( sizeof( struct cl_zpotrf_args_s ) );
        clargs->uplo     = uplo;
        clargs->n        = n;
        clargs->iinfo    = iinfo;
        clargs->sequence = options->sequence;
        clargs->request  = options->request;

        task->cl_arg      = clargs;
        task->cl_arg_size = sizeof( struct cl_zpotrf_args_s );
        task->cl_arg_free = 1;

        /* Set common parameters */
        starpu_cham_task_set_options( options, task, nbdata, descrs, cl_zpotrf_callback );

        /* Flops */
        task->flops = flops_zpotrf( n );

        /* Refine name */
        task->name = chameleon_codelet_name( cl_name, 1,
                                             A->get_blktile( A, Am, An ) );

        ret = starpu_task_submit( task );
        if ( ret == -ENODEV ) {
            task->destroy = 0;
            starpu_task_destroy( task );
            chameleon_error( "INSERT_TASK_zpotrf", "Failed to submit the task to StarPU" );
            return;
        }
    }

    starpu_cham_task_exchange_data_after_execution( options, params, nbdata, descrs );

    (void)nb;
}

#endif