diff --git a/include/chameleon/tasks.h b/include/chameleon/tasks.h index bc7a59e6f0b36ae28602218d6579c1f47ddbf142..e4131d38409d99f13ffb05c50d4345cb4976078e 100644 --- a/include/chameleon/tasks.h +++ b/include/chameleon/tasks.h @@ -15,7 +15,8 @@ * @author Mathieu Faverge * @author Cedric Augonnet * @author Florent Pruvost - * @date 2023-07-06 + * @author Matthieu Kuhn + * @date 2023-08-31 * */ #ifndef _chameleon_tasks_h_ @@ -121,6 +122,10 @@ void INSERT_TASK_hgemm( const RUNTIME_option_t *options, const CHAM_desc_t *B, int Bm, int Bn, CHAMELEON_Real16_t beta, const CHAM_desc_t *C, int Cm, int Cn ); +void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options, + int m0, int m, int k, + const CHAM_ipiv_t *ipivdesc, int ipivk ); + #include "chameleon/tasks_z.h" #include "chameleon/tasks_d.h" #include "chameleon/tasks_c.h" diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index e63a4dd5e7203333b4890a2aa09c27f71fda66c4..52703433623b3edf0d3b7c59b028e8dd1f63b112 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -24,7 +24,7 @@ # @author Florent Pruvost # @author Philippe Virouleau # @author Matthieu Kuhn -# @date 2023-08-22 +# @date 2023-08-31 # ### @@ -124,6 +124,7 @@ set(CODELETS_ZSRC set(CODELETS_SRC codelets/codelet_map.c + codelets/codelet_ipiv_to_perm.c ) # Check for the subdirectories diff --git a/runtime/openmp/codelets/codelet_ipiv_to_perm.c b/runtime/openmp/codelets/codelet_ipiv_to_perm.c new file mode 100644 index 0000000000000000000000000000000000000000..c2fb60bccb08f7b1eaf980b2a0810cbf628254e3 --- /dev/null +++ b/runtime/openmp/codelets/codelet_ipiv_to_perm.c @@ -0,0 +1,37 @@ +/** + * + * @file openmp/codelet_ipiv_to_perm.c + * + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon OpenMP codelets to convert pivot to permutations + * + * @version 1.3.0 + * @author Mathieu Faverge + * @author Matthieu Kuhn + * @date 2023-08-31 + * + */ +#include "chameleon_openmp.h" +#include "chameleon/tasks.h" +#include "coreblas.h" + +void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options, + int m0, int m, int k, + const CHAM_ipiv_t *ipivdesc, int ipivk ) +{ + int *ipiv = NULL; // get pointer from ipivdesc + int *perm = NULL; // get pointer from ipivdesc + int *invp = NULL; // get pointer from ipivdesc + +#pragma omp task firstprivate( m0, m, k ) depend( in:ipiv[0] ) depend( inout:perm[0] ) depend( inout:invp[0] ) + { + CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp ); + } + + (void)options; + (void)ipivk; +} diff --git a/runtime/parsec/codelets/codelet_ipiv_to_perm.c b/runtime/parsec/codelets/codelet_ipiv_to_perm.c new file mode 100644 index 0000000000000000000000000000000000000000..9a972d879ede836a34dd66017274cc50e71792ee --- /dev/null +++ b/runtime/parsec/codelets/codelet_ipiv_to_perm.c @@ -0,0 +1,50 @@ +/** + * + * @file parsec/codelet_ipiv_to_perm.c + * + * @copyright 2023-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon Parsec codelets to convert pivot to permutations + * + * @version 1.3.0 + * @author Mathieu Faverge + * @author Matthieu Kuhn + * @date 2023-08-31 + * + */ +#include "chameleon_parsec.h" +#include "chameleon/tasks.h" +#include "coreblas.h" + +static inline int +CORE_ipiv_to_perm_parsec( parsec_execution_stream_t *context, + parsec_task_t *this_task ) +{ + int m0, m, k; + int *ipiv, *perm, *invp; + + parsec_dtd_unpack_args( + this_task, &m0, &m, &k, &ipiv, &perm, &invp ); + + CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp ); +} + +void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options, + int m0, int m, int k, + const CHAM_ipiv_t *ipivdesc, int ipivk ) +{ + parsec_taskpool_t* PARSEC_dtd_taskpool = (parsec_taskpool_t *)(options->sequence->schedopt); + + parsec_dtd_taskpool_insert_task( + PARSEC_dtd_taskpool, CORE_ipiv_to_perm_parsec, options->priority, "ipiv_to_perm", + sizeof(int), &m0, VALUE, + sizeof(int), &m, VALUE, + sizeof(int), &k, VALUE, + PASSED_BY_REF, RUNTIME_ipiv_getaddr( ipivdesc, ipivk ), chameleon_parsec_get_arena_index_ipiv( ipivdesc ) | INPUT, + PASSED_BY_REF, RUNTIME_perm_getaddr( ipivdesc, ipivk ), chameleon_parsec_get_arena_index_perm( ipivdesc ) | OUTPUT, + PASSED_BY_REF, RUNTIME_invp_getaddr( ipivdesc, ipivk ), chameleon_parsec_get_arena_index_invp( ipivdesc ) | OUTPUT, + PARSEC_DTD_ARG_END ); +} diff --git a/runtime/quark/codelets/codelet_ipiv_to_perm.c b/runtime/quark/codelets/codelet_ipiv_to_perm.c new file mode 100644 index 0000000000000000000000000000000000000000..8ccc7ddff26438bfc67e8160c5bb4de8419237f4 --- /dev/null +++ b/runtime/quark/codelets/codelet_ipiv_to_perm.c @@ -0,0 +1,48 @@ +/** + * + * @file quark/codelet_ipiv_to_perm.c + * + * @copyright 2023-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon Quark codelets to convert pivot to permutations + * + * @version 1.3.0 + * @author Mathieu Faverge + * @author Matthieu Kuhn + * @date 2023-08-31 + * + */ +#include "chameleon_quark.h" +#include "chameleon/tasks.h" +#include "coreblas.h" + +static inline void +CORE_ipiv_to_perm_quark( Quark *quark ) +{ + int m0, m, k; + int *ipiv, *perm, *invp; + + quark_unpack_args_6( quark, m0, m, k, ipiv, perm, invp ); + + CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp ); +} + +void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options, + int m0, int m, int k, + const CHAM_ipiv_t *ipivdesc, int ipivk ) +{ + quark_option_t *opt = (quark_option_t*)(options->schedopt); + + QUARK_Insert_Task( + opt->quark, CORE_ipiv_to_perm_quark, (Quark_Task_Flags*)opt, + sizeof(int), &m0, VALUE, + sizeof(int), &m, VALUE, + sizeof(int), &k, VALUE, + sizeof(int*), RUNTIME_ipiv_getaddr( ipivdesc, ipivk ), INPUT, + sizeof(int*), RUNTIME_perm_getaddr( ipivdesc, ipivk ), OUTPUT, + sizeof(int*), RUNTIME_invp_getaddr( ipivdesc, ipivk ), OUTPUT, + 0 ); +} diff --git a/runtime/starpu/codelets/codelet_ipiv_to_perm.c b/runtime/starpu/codelets/codelet_ipiv_to_perm.c new file mode 100644 index 0000000000000000000000000000000000000000..31183c11505a0f19fa3505691684c37810c0f10e --- /dev/null +++ b/runtime/starpu/codelets/codelet_ipiv_to_perm.c @@ -0,0 +1,69 @@ +/** + * + * @file starpu/codelet_ipiv_to_perm.c + * + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon StarPU codelets to convert pivot to permutations + * + * @version 1.3.0 + * @author Mathieu Faverge + * @author Matthieu Kuhn + * @date 2023-08-31 + * + */ +#include "chameleon_starpu.h" +#include "runtime_codelets.h" + +#if !defined(CHAMELEON_SIMULATION) +static void cl_ipiv_to_perm_cpu_func( void *descr[], void *cl_arg ) +{ + int m0, m, k; + int *ipiv, *perm, *invp; + + starpu_codelet_unpack_args( cl_arg, &m0, &m, &k ); + + ipiv = (int*)STARPU_VECTOR_GET_PTR(descr[0]); + perm = (int*)STARPU_VECTOR_GET_PTR(descr[1]); + invp = (int*)STARPU_VECTOR_GET_PTR(descr[2]); + + CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp ); +} +#endif /* !defined(CHAMELEON_SIMULATION) */ + +/* +* Codelet definition +*/ +static struct starpu_codelet cl_ipiv_to_perm = { + .where = STARPU_CPU, +#if defined(CHAMELEON_SIMULATION) + .cpu_funcs[0] = (starpu_cpu_func_t)1, +#else + .cpu_funcs[0] = cl_ipiv_to_perm_cpu_func, +#endif + .nbuffers = 3, + .model = NULL, + .name = "ipiv_to_perm" +}; + +void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options, + int m0, int m, int k, + const CHAM_ipiv_t *ipivdesc, int ipivk ) +{ + struct starpu_codelet *codelet = &cl_ipiv_to_perm; + + rt_starpu_insert_task( + codelet, + STARPU_VALUE, &m0, sizeof(int), + STARPU_VALUE, &m, sizeof(int), + STARPU_VALUE, &k, sizeof(int), + STARPU_R, RUNTIME_ipiv_getaddr( ipivdesc, ipivk ), + STARPU_W, RUNTIME_perm_getaddr( ipivdesc, ipivk ), + STARPU_W, RUNTIME_invp_getaddr( ipivdesc, ipivk ), + STARPU_PRIORITY, options->priority, + STARPU_EXECUTE_ON_WORKER, options->workerid, + 0 ); +} diff --git a/runtime/starpu/include/runtime_codelets.h b/runtime/starpu/include/runtime_codelets.h index c27d6b913bb231c4815dca09e67b7201e12697c7..72c7edc8cb46cc035e693bd6c653715d91990495 100644 --- a/runtime/starpu/include/runtime_codelets.h +++ b/runtime/starpu/include/runtime_codelets.h @@ -27,6 +27,8 @@ #include "runtime_codelet_profile.h" #if !defined(CHAMELEON_SIMULATION) +#include "coreblas.h" + #if defined(CHAMELEON_USE_CUDA) #include "gpucublas.h" #endif