Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 409c1fe1 authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'feature/map' into 'master'

Feature/map

See merge request solverstack/chameleon!111
parents 801bcf4d 84c6b474
......@@ -59,7 +59,9 @@ set(CHAMELEON_CONTROL
../control/tile.c
../control/chameleon_f77.c
../control/chameleon_mf77.c
# ../control/chameleonwinthread.c
# ../control/chameleonwinthread.c
map.c
pmap.c
)
set(flags_to_add "")
......
/**
*
* @file map.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon map wrappers
*
* @version 1.0.0
* @author Mathieu Faverge
* @date 2018-09-24
*
*/
#include "control/common.h"
/**
********************************************************************************
*
* @ingroup CHAMELEON_Tile
*
* Apply a given operator on each tile of the given matrix. Operates on
* matrices stored by tiles. All matrices are passed through descriptors. All
* dimensions are taken from the descriptors.
*
*******************************************************************************
*
* @param[in,out] uplo
* - ChamUpper: Only the upper triangular part of the matrix is touched
* - ChamLower: Only the lower triangular part of the matrix is touched
* - ChamUpperLower: The entire the matrix is touched
*
* @param[in,out] A
* On exit, the operator has been applied on each tile of the matrix A.
*
* @param[in] operator
* The operator function to apply on each tile of the matrix.
*
* @param[in,out] op_args
* The arguments structure passed to the operator function when applied
* on each tile. May be updated by the operator function.
*
*******************************************************************************
*
* @retval CHAMELEON_SUCCESS successful exit
*
*******************************************************************************
*
* @sa CHAMELEON_map_Tile_Async
*
*/
int CHAMELEON_map_Tile( cham_uplo_t uplo,
CHAM_desc_t *A,
cham_unary_operator_t operator,
void *op_args )
{
CHAM_context_t *chamctxt;
RUNTIME_sequence_t *sequence = NULL;
RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
int status;
chamctxt = chameleon_context_self();
if (chamctxt == NULL) {
chameleon_fatal_error("CHAMELEON_map_Tile", "CHAMELEON not initialized");
return CHAMELEON_ERR_NOT_INITIALIZED;
}
chameleon_sequence_create( chamctxt, &sequence );
CHAMELEON_map_Tile_Async( uplo, A, operator, op_args, sequence, &request );
CHAMELEON_Desc_Flush( A, sequence );
chameleon_sequence_wait( chamctxt, sequence );
status = sequence->status;
chameleon_sequence_destroy( chamctxt, sequence );
return status;
}
/**
********************************************************************************
*
* @ingroup CHAMELEON_Tile_Async
*
* Apply a given operator on each tile of the given matrix. Non-blocking equivalent of
* CHAMELEON_map_Tile(). May return before the computation is finished.
* Allows for pipelining of operations at runtime.
*
*******************************************************************************
*
* @param[in] sequence
* Identifies the sequence of function calls that this call belongs to
* (for completion checks and exception handling purposes).
*
* @param[out] request
* Identifies this function call (for exception handling purposes).
*
*******************************************************************************
*
* @retval CHAMELEON_SUCCESS successful exit
*
*******************************************************************************
*
* @sa CHAMELEON_map_Tile
*
*/
int CHAMELEON_map_Tile_Async( 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;
chamctxt = chameleon_context_self();
if (chamctxt == NULL) {
chameleon_fatal_error("CHAMELEON_map_Tile_Async", "CHAMELEON not initialized");
return CHAMELEON_ERR_NOT_INITIALIZED;
}
if (sequence == NULL) {
chameleon_fatal_error("CHAMELEON_map_Tile_Async", "NULL sequence");
return CHAMELEON_ERR_UNALLOCATED;
}
if (request == NULL) {
chameleon_fatal_error("CHAMELEON_map_Tile_Async", "NULL request");
return CHAMELEON_ERR_UNALLOCATED;
}
/* Check sequence status */
if (sequence->status == CHAMELEON_SUCCESS) {
request->status = CHAMELEON_SUCCESS;
}
else {
return chameleon_request_fail(sequence, request, CHAMELEON_ERR_SEQUENCE_FLUSHED);
}
/* Check descriptors for correctness */
if (chameleon_desc_check(A) != CHAMELEON_SUCCESS) {
chameleon_error("CHAMELEON_map_Tile_Async", "invalid descriptor");
return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
}
/* Quick return */
if (chameleon_min( A->m, A->n ) == 0) {
return CHAMELEON_SUCCESS;
}
chameleon_pmap( uplo, A, operator, op_args, sequence, request );
return CHAMELEON_SUCCESS;
}
/**
*
* @file pmap.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon map parallel algorithm
*
* @version 1.0.0
* @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);
}
......@@ -108,6 +108,10 @@ extern char *chameleon_lapack_constants[];
extern "C" {
#endif
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 );
#include "control/compute_s.h"
#include "control/compute_d.h"
#include "control/compute_c.h"
......
......@@ -857,21 +857,23 @@
* heevd: eigenvalues/eigenvectors computation with A Hermitian
* *Extra routines*
* *Norms*
* lange: computes norm of a matrix (Max, One, Inf, Frobenius)
* lange: compute norm of a matrix (Max, One, Inf, Frobenius)
* lanhe: lange with A Hermitian
* lansy: lange with A symmetric
* lantr: lange with A triangular
* *Random matrices generation*
* plghe: generates a random Hermitian matrix
* plgsy: generates a random symmetrix matrix
* plrnt: generates a random matrix
* plghe: generate a random Hermitian matrix
* plgsy: generate a random symmetrix matrix
* plrnt: generate a random matrix
* *Others*
* geadd: general matrix matrix addition
* lacpy: copy matrix into another
* lascal: scales a matrix
* lascal: scale a matrix
* laset: copy the triangular part of a matrix into another, set a
value for the diagonal and off-diagonal part
* tradd: trapezoidal matrices addition
* *Map functions*
* map: apply a user operator on each tile of the matrix
**** Options routines
Enable CHAMELEON feature.
......
......@@ -54,6 +54,17 @@
/* ****************************************************************************
* CHAMELEON functionnalities
*/
int CHAMELEON_map_Tile( cham_uplo_t uplo,
CHAM_desc_t *A,
cham_unary_operator_t operator,
void *op_args );
int CHAMELEON_map_Tile_Async( cham_uplo_t uplo,
CHAM_desc_t *A,
cham_unary_operator_t operator,
void *op_args,
RUNTIME_sequence_t *sequence,
RUNTIME_request_t *request );
#include "chameleon/chameleon_z.h"
#include "chameleon/chameleon_c.h"
#include "chameleon/chameleon_d.h"
......
......@@ -86,6 +86,14 @@ typedef enum chameleon_tasktype_e {
TASK_NBKERNELS
} cham_tasktype_t;
typedef int (*cham_unary_operator_t)( const CHAM_desc_t *desc,
cham_uplo_t uplo, int m, int n,
void *data, void *op_args );
void INSERT_TASK_map( const RUNTIME_option_t *options,
cham_uplo_t uplo, const CHAM_desc_t *A, int Am, int An,
cham_unary_operator_t operator, void *op_args );
#include "chameleon/tasks_z.h"
#include "chameleon/tasks_d.h"
#include "chameleon/tasks_c.h"
......
......@@ -105,6 +105,10 @@ set(CODELETS_ZSRC
codelets/codelet_zbuild.c
)
set(CODELETS_SRC
codelets/codelet_map.c
)
# Check for the subdirectories
# ----------------------------
if( CHAMELEON_SCHED_QUARK )
......
......@@ -101,6 +101,7 @@ precisions_rules_py(RUNTIME_SRCS_GENERATED "${ZSRC}"
set(RUNTIME_SRCS
${RUNTIME_COMMON}
${RUNTIME_SRCS_GENERATED}
${CODELETS_SRC}
)
# Force generation of sources
......
/**
*
* @file codelet_map.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon map PaRSEC codelet
*
* @version 1.0.0
* @author Mathieu Faverge
* @date 2018-09-24
*
*/
#include "chameleon_parsec.h"
#include "chameleon/tasks.h"
static inline int
CORE_map_parsec( parsec_execution_stream_t *context,
parsec_task_t *this_task )
{
const CHAM_desc_t *desc;
cham_uplo_t uplo;
int m;
int n;
void *data;
cham_unary_operator_t operator;
void *op_args;
parsec_dtd_unpack_args(
this_task, desc, uplo, m, n, data, operator, op_args );
operator( desc, uplo, m, n, data, op_args );
(void)context;
return PARSEC_HOOK_RETURN_DONE;
}
void INSERT_TASK_map( const RUNTIME_option_t *options,
cham_uplo_t uplo, const CHAM_desc_t *A, int Am, int An,
cham_unary_operator_t operator, void *op_args )
{
parsec_taskpool_t* PARSEC_dtd_taskpool = (parsec_taskpool_t *)(options->sequence->schedopt);
parsec_dtd_taskpool_insert_task(
PARSEC_dtd_taskpool, CORE_map_parsec, options->priority, "map",
sizeof(CHAM_desc_t*), &A, VALUE,
sizeof(cham_uplo_t), &uplo, VALUE,
sizeof(int), &Am, VALUE,
sizeof(int), &An, VALUE,
PASSED_BY_REF, RTBLKADDR(A, void, Am, An), chameleon_parsec_get_arena_index( A ) | INOUT,
sizeof(cham_unary_operator_t), &operator, VALUE,
sizeof(void*), &op_args, VALUE,
PARSEC_DTD_ARG_END );
}
......@@ -102,6 +102,7 @@ precisions_rules_py(RUNTIME_SRCS_GENERATED "${ZSRC}"
set(RUNTIME_SRCS
${RUNTIME_COMMON}
${RUNTIME_SRCS_GENERATED}
${CODELETS_SRC}
)
# Force generation of sources
......
/**
*
* @file codelet_map.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon map Quark codelet
*
* @version 1.0.0
* @author Mathieu Faverge
* @date 2018-09-24
*
*/
#include "chameleon_quark.h"
#include "chameleon/tasks.h"
void CORE_map_quark(Quark *quark)
{
const CHAM_desc_t *desc;
cham_uplo_t uplo;
int m;
int n;
void *data;
cham_unary_operator_t operator;
void *op_args;
quark_unpack_args_7( quark, desc, uplo, m, n, data, operator, op_args );
operator( desc, uplo, m, n, data, op_args );
}
void INSERT_TASK_map( const RUNTIME_option_t *options,
cham_uplo_t uplo, const CHAM_desc_t *A, int Am, int An,
cham_unary_operator_t operator, void *op_args )
{
quark_option_t *opt = (quark_option_t*)(options->schedopt);
QUARK_Insert_Task(
opt->quark, CORE_map_quark, (Quark_Task_Flags*)opt,
sizeof(CHAM_desc_t*), &A, VALUE,
sizeof(cham_uplo_t), &uplo, VALUE,
sizeof(int), &Am, VALUE,
sizeof(int), &An, VALUE,
sizeof(char), RTBLKADDR(A, void, Am, An), INOUT,
sizeof(cham_unary_operator_t), &operator, VALUE,
sizeof(void*), &op_args, VALUE,
0);
}
......@@ -118,6 +118,7 @@ precisions_rules_py(RUNTIME_SRCS_GENERATED "${ZSRC}"
set(RUNTIME_SRCS
${RUNTIME_COMMON}
${RUNTIME_SRCS_GENERATED}
${CODELETS_SRC}
)
# Force generation of sources
......
/**
*
* @file codelet_map.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon map StarPU codelet
*
* @version 1.0.0
* @author Mathieu Faverge
* @date 2018-09-24
*
*/
#include "chameleon_starpu.h"
#include "runtime_codelet_z.h"
CHAMELEON_CL_CB(map, starpu_matrix_get_nx(task->handles[0]), starpu_matrix_get_ny(task->handles[0]), 0, M*N);
#if !defined(CHAMELEON_SIMULATION)
static void cl_map_cpu_func(void *descr[], void *cl_arg)
{
const CHAM_desc_t *desc;
cham_uplo_t uplo;
int m;
int n;
void *data;
cham_unary_operator_t operator;
void *op_args;
data = (void *)STARPU_MATRIX_GET_PTR(descr[0]);
starpu_codelet_unpack_args(cl_arg, &desc, &uplo, &m, &n, &operator, &op_args );
operator( desc, uplo, m, n, data, op_args );
}
#endif /* !defined(CHAMELEON_SIMULATION) */
/*
* Codelet definition
*/
CODELETS_CPU(map, 1, cl_map_cpu_func)
void INSERT_TASK_map( const RUNTIME_option_t *options,
cham_uplo_t uplo, const CHAM_desc_t *A, int Am, int An,
cham_unary_operator_t operator, void *op_args )
{
struct starpu_codelet *codelet = &cl_map;
void (*callback)(void*) = options->profiling ? cl_map_callback : NULL;
CHAMELEON_BEGIN_ACCESS_DECLARATION;
CHAMELEON_ACCESS_RW(A, Am, An);
CHAMELEON_END_ACCESS_DECLARATION;
starpu_insert_task(
starpu_mpi_codelet(codelet),
STARPU_VALUE, &A, sizeof(CHAM_desc_t*),
STARPU_VALUE, &uplo, sizeof(cham_uplo_t),
STARPU_VALUE, &Am, sizeof(int),
STARPU_VALUE, &An, sizeof(int),
STARPU_RW, RTBLKADDR(A, void, Am, An),
STARPU_VALUE, &operator, sizeof(cham_unary_operator_t),
STARPU_VALUE, &op_args, sizeof(void*),
STARPU_PRIORITY, options->priority,
STARPU_CALLBACK, callback,
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
STARPU_NAME, "map",
#endif
0);
}
......@@ -117,9 +117,6 @@
#define CCODELETS_HEADER(name) CODELETS_HEADER(c##name)
#define ZCODELETS_HEADER(name) CODELETS_HEADER(z##name)
#define SCODELETS_CPU_HEADER(name) CODELETS_CPU_HEADER(s##name)
#define DCODELETS_CPU_HEADER(name) CODELETS_CPU_HEADER(d##name)
#define CCODELETS_CPU_HEADER(name) CODELETS_CPU_HEADER(c##name)
#define ZCODELETS_CPU_HEADER(name) CODELETS_CPU_HEADER(z##name)
CODELETS_HEADER(map);
#endif /* _CODELETS_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment