From 5b1fc4d2cb56ffdf930a31e1141c56d6a77010a0 Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Fri, 7 Jul 2023 17:51:34 +0200 Subject: [PATCH] runtime/starpu: extract the wontuse and mpi_data_register functions into header files to share them into multiple C files runtime/starpu/control/runtime_descriptor.c --- runtime/starpu/control/runtime_descriptor.c | 53 +----------------- runtime/starpu/include/chameleon_starpu.h.in | 5 +- runtime/starpu/include/runtime_mpi.h | 41 ++++++++++++++ runtime/starpu/include/runtime_wontuse.h | 57 ++++++++++++++++++++ 4 files changed, 103 insertions(+), 53 deletions(-) create mode 100644 runtime/starpu/include/runtime_mpi.h create mode 100644 runtime/starpu/include/runtime_wontuse.h diff --git a/runtime/starpu/control/runtime_descriptor.c b/runtime/starpu/control/runtime_descriptor.c index ee4817fe4..2ed4ba05a 100644 --- a/runtime/starpu/control/runtime_descriptor.c +++ b/runtime/starpu/control/runtime_descriptor.c @@ -20,26 +20,11 @@ * @author Raphael Boucherie * @author Samuel Thibault * @author Loris Lucido - * @date 2023-07-06 + * @date 2023-08-22 * */ #include "chameleon_starpu.h" -/** - * Set the tag sizes - */ -#if defined(CHAMELEON_USE_MPI) - -#ifndef HAVE_STARPU_MPI_DATA_REGISTER -#define starpu_mpi_data_register( handle_, tag_, owner_ ) \ - do { \ - starpu_data_set_rank( (handle_), (owner_) ); \ - starpu_data_set_tag( (handle_), (tag_) ); \ - } while(0) -#endif - -#endif - /** * Malloc/Free of the data */ @@ -289,42 +274,6 @@ void RUNTIME_flush() #endif } -/** - * Different implementations of the flush call based on StarPU version - */ -#if defined(HAVE_STARPU_DATA_WONT_USE) - -static inline void -chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { - starpu_data_wont_use( handle ); -} - -#elif defined(HAVE_STARPU_IDLE_PREFETCH) - -static inline void -chameleon_starpu_data_flush( void *_handle) -{ - starpu_data_handle_t handle = (starpu_data_handle_t)_handle; - starpu_data_idle_prefetch_on_node(handle, STARPU_MAIN_RAM, 1); - starpu_data_release_on_node(handle, -1); -} - -static inline void -chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { - starpu_data_acquire_on_node_cb( handle, -1, STARPU_R, - chameleon_starpu_data_flush, handle ); -} - -#else - -static inline void -chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { - starpu_data_acquire_cb( handle, STARPU_R, - (void (*)(void*))&starpu_data_release, handle ); -} - -#endif - void RUNTIME_desc_flush( const CHAM_desc_t *desc, const RUNTIME_sequence_t *sequence ) { diff --git a/runtime/starpu/include/chameleon_starpu.h.in b/runtime/starpu/include/chameleon_starpu.h.in index 8d421ddbb..407f1bb78 100644 --- a/runtime/starpu/include/chameleon_starpu.h.in +++ b/runtime/starpu/include/chameleon_starpu.h.in @@ -19,7 +19,7 @@ * @author Samuel Thibault * @author Loris Lucido * @author Terry Cojean - * @date 2023-07-06 + * @date 2023-08-22 * */ #ifndef _chameleon_starpu_h_ @@ -166,6 +166,9 @@ void chameleon_starpu_tag_release( int64_t min ); void RUNTIME_set_reduction_methods(starpu_data_handle_t handle, cham_flttype_t dtyp); +#include "runtime_mpi.h" +#include "runtime_wontuse.h" + #if defined(CHAMELEON_USE_MPI) && defined(HAVE_STARPU_MPI_CACHED_RECEIVE) static inline int chameleon_starpu_data_iscached(const CHAM_desc_t *A, int m, int n) diff --git a/runtime/starpu/include/runtime_mpi.h b/runtime/starpu/include/runtime_mpi.h new file mode 100644 index 000000000..6d307bc6a --- /dev/null +++ b/runtime/starpu/include/runtime_mpi.h @@ -0,0 +1,41 @@ +/** + * + * @file starpu/runtime_mpi.h + * + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon StarPU mpi function implementation + * + * @version 1.3.0 + * @author Mathieu Faverge + * @date 2023-08-22 + * + */ +#ifndef _runtime_mpi_h_ +#define _runtime_mpi_h_ + +/** + * Set the tag sizes + */ +#if defined(CHAMELEON_USE_MPI) + +#if !defined(HAVE_STARPU_MPI_DATA_REGISTER) +static inline starpu_mpi_data_register( starpu_data_handle_t handle, int64_t tag, int owner ) +{ + starpu_data_set_rank( handle, owner ); + starpu_data_set_tag( handle, tag ); +} +#endif + +#else + +static inline starpu_mpi_data_register( starpu_data_handle_t, int64_t, int ) +{ +} + +#endif + +#endif /* _runtime_mpi_h_ */ diff --git a/runtime/starpu/include/runtime_wontuse.h b/runtime/starpu/include/runtime_wontuse.h new file mode 100644 index 000000000..c5b1526d8 --- /dev/null +++ b/runtime/starpu/include/runtime_wontuse.h @@ -0,0 +1,57 @@ +/** + * + * @file starpu/runtime_wontuse.h + * + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon StarPU wont use implementations to flush pieces of data + * + * @version 1.3.0 + * @author Mathieu Faverge + * @date 2023-08-22 + * + */ +#ifndef _runtime_wontuse_h_ +#define _runtime_wontuse_h_ + +#include "chameleon_starpu.h" + +/** + * Different implementations of the flush call based on StarPU version + */ +#if defined(HAVE_STARPU_DATA_WONT_USE) + +static inline void +chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { + starpu_data_wont_use( handle ); +} + +#elif defined(HAVE_STARPU_IDLE_PREFETCH) + +static inline void +chameleon_starpu_data_flush( void *_handle) +{ + starpu_data_handle_t handle = (starpu_data_handle_t)_handle; + starpu_data_idle_prefetch_on_node( handle, STARPU_MAIN_RAM, 1 ); + starpu_data_release_on_node( handle, -1 ); +} + +static inline void +chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { + starpu_data_acquire_on_node_cb( handle, -1, STARPU_R, + chameleon_starpu_data_flush, handle ); +} + +#else + +static inline void +chameleon_starpu_data_wont_use( starpu_data_handle_t handle ) { + starpu_data_acquire_cb( handle, STARPU_R, + (void (*)(void*))&starpu_data_release, handle ); +} + +#endif +#endif /* _runtime_wontuse_h_ */ -- GitLab