runtime_options.c 1.85 KB
Newer Older
Philippe Virouleau's avatar
Philippe Virouleau committed
1 2
/**
 *
Philippe Virouleau's avatar
Fix doc  
Philippe Virouleau committed
3
 * @file openmp/runtime_options.c
Philippe Virouleau's avatar
Philippe Virouleau committed
4 5 6
 *
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
Philippe Virouleau's avatar
Fix doc  
Philippe Virouleau committed
7
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
Philippe Virouleau's avatar
Philippe Virouleau committed
8 9 10 11 12 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
 *                      Univ. Bordeaux. All rights reserved.
 *
 ***
 *
 * @brief Chameleon StarPU options routines
 *
 * @version 1.0.0
 * @author Cedric Augonnet
 * @author Mathieu Faverge
 * @author Cedric Castagnede
 * @date 2010-11-15
 *
 */
#include <stdlib.h>
#include "chameleon_openmp.h"

void RUNTIME_options_init( RUNTIME_option_t *option, CHAM_context_t *chamctxt,
                           RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
{
    option->sequence   = sequence;
    option->request    = request;
    option->profiling  = CHAMELEON_PROFILING == CHAMELEON_TRUE;
    option->parallel   = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
    option->priority   = RUNTIME_PRIORITY_MIN;
    option->ws_wsize   = 0;
    option->ws_hsize   = 0;
    option->ws_worker  = NULL;
    option->ws_host    = NULL;
    return;
}

void RUNTIME_options_finalize( RUNTIME_option_t *option, CHAM_context_t *chamctxt )
{
    (void)option;
    (void)chamctxt;
    return;
}

int RUNTIME_options_ws_alloc( RUNTIME_option_t *options, size_t worker_size, size_t host_size )
{
    if (worker_size > 0) {
Philippe Virouleau's avatar
Philippe Virouleau committed
49 50 51 52 53
        /*
         * NOTE: we set the size, but instead of doing a malloc shared by multiple workers,
         * we just create a VLA in the relevant codelets, within the task's body.
         * This way we ensure the "scratch" is thread local and not shared by multiple threads.
         */
Philippe Virouleau's avatar
Philippe Virouleau committed
54 55 56 57 58 59 60 61 62 63 64 65
        options->ws_wsize = worker_size;
    }
    return CHAMELEON_SUCCESS;
}

int RUNTIME_options_ws_free( RUNTIME_option_t *options )
{
    if (options->ws_wsize) {
        options->ws_wsize = 0;
    }
    return CHAMELEON_SUCCESS;
}