diff --git a/examples/array_sum/main.c b/examples/array_sum/main.c index 3278d8484c167c64a196a5aa1a2106305c8fcae3..53103475a455edf39809c489dcc462534a797785 100644 --- a/examples/array_sum/main.c +++ b/examples/array_sum/main.c @@ -36,7 +36,7 @@ int main(int argc, char * argv[]) fmpi_data_out(ctx, &out), fmpi_data_1d_in(ctx, in, in_size) ); - fmpi_task_run_sync(ctx, &array_sum_task); + fmpi_run_task(ctx, &array_sum_task); printf("rank=%d sum=%ld\n", fmpi_world_rank(ctx), out); fmpi_exit(&ctx); return EXIT_SUCCESS; diff --git a/include/fmpi_core.h b/include/fmpi_core.h index f379529855907b39d5fe265d2444063e6d45d474..0a91cd550780bb6f3caa46116fe5e5fd1de54a2f 100644 --- a/include/fmpi_core.h +++ b/include/fmpi_core.h @@ -126,6 +126,10 @@ int fmpi_world_rank(const struct fmpi_ctx * ctx); fmpi_world_barrier() ------------------------------------------------------------------------------*/ int fmpi_world_barrier(const struct fmpi_ctx * ctx); +/*------------------------------------------------------------------------------ + fmpi_run_task() +------------------------------------------------------------------------------*/ +int fmpi_run_task(const struct fmpi_ctx * ctx, const struct fmpi_task * task); /*============================================================================== MACRO ==============================================================================*/ diff --git a/src/fmpi_core.c b/src/fmpi_core.c index 99a4ff2d2181455f14b0319905527d81560c4eec..7eeb456cb946e514c7f5283e961337efaa134833 100644 --- a/src/fmpi_core.c +++ b/src/fmpi_core.c @@ -28,6 +28,7 @@ #include <stdio.h> // fprintf() #include <stdlib.h> // NULL, abort() // Internal +#include "fmpi_task.h" #include "internal/fmpi_ctx.h" #include "internal/fmpi_error.h" #include "internal/fmpi_mpi.h" @@ -94,3 +95,16 @@ int fmpi_world_barrier(const struct fmpi_ctx * const ctx) } return err_id; } +/*------------------------------------------------------------------------------ + fmpi_run_task() +------------------------------------------------------------------------------*/ +int fmpi_run_task( + const struct fmpi_ctx * const ctx, const struct fmpi_task * const task +){ + assert(ctx != NULL); + assert(task != NULL); + if(task->type == FMPI_TASK_TYPE_SYNC) { + return fmpi_task_run_sync(ctx, task); + } + return fmpi_task_run_async(ctx, task); +}