From 31737f95bd1273c043a44149f079bcb2b5a0ca33 Mon Sep 17 00:00:00 2001 From: "raphael.bach" <raphael.bach@etu.hesge.ch> Date: Thu, 19 May 2022 19:45:07 +0200 Subject: [PATCH] Make `fmpi_futhark_{new,free}()` take a `fmpi_futhark_ctx` instead of a `fmpi_ctx` --- include/internal/generic/fmpi_futhark_generic.h | 6 +++--- src/fmpi_data.c | 3 ++- src/fmpi_futhark.c | 16 ++++++++-------- src/fmpi_reduce.c | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/internal/generic/fmpi_futhark_generic.h b/include/internal/generic/fmpi_futhark_generic.h index 8b7bc08..f860baf 100644 --- a/include/internal/generic/fmpi_futhark_generic.h +++ b/include/internal/generic/fmpi_futhark_generic.h @@ -33,7 +33,7 @@ /*============================================================================== MACRO ==============================================================================*/ -struct fmpi_ctx; +struct fmpi_futhark_ctx; #define FMPI_FUTHARK_TYPES \ FMPI_TYPE_REAL @@ -63,10 +63,10 @@ struct fmpi_ctx; #define FMPI_FUTHARK_DECLARATION(D, T) \ struct futhark_##T##_##D##d * fmpi_futhark_new_##D##d_##T( \ - const struct fmpi_ctx * ctx, const T * array, size_t x, size_t y, size_t z \ + const struct fmpi_futhark_ctx * ctx, const T * array, size_t x, size_t y, size_t z \ ); \ void fmpi_futhark_free_##D##d_##T( \ - const struct fmpi_ctx * ctx, struct futhark_##T##_##D##d * array \ + const struct fmpi_futhark_ctx * ctx, struct futhark_##T##_##D##d * array \ ) FMPI_DECLARE_DIM_FUNCS(FMPI_FUTHARK_DECLARATION, 1, FMPI_FUTHARK_TYPES); diff --git a/src/fmpi_data.c b/src/fmpi_data.c index 217cf66..ce3544c 100644 --- a/src/fmpi_data.c +++ b/src/fmpi_data.c @@ -29,6 +29,7 @@ #include <stdio.h> // fprintf() #include <stdlib.h> // malloc() // Internal +#include "internal/fmpi_ctx.h" #include "internal/fmpi_futhark.h" #include "internal/generic/fmpi_type.h" /*============================================================================== @@ -56,7 +57,7 @@ struct fmpi_data fmpi_data_##D##d_in_new_##T( \ assert(ctx != NULL); \ assert(data != NULL); \ _Static_assert(D <= 3, ""); \ - struct futhark_##T##_##D##d * const start = fmpi_futhark_new_##D##d_##T(ctx, data, x, y, z); \ + struct futhark_##T##_##D##d * const start = fmpi_futhark_new_##D##d_##T(ctx->fut, data, x, y, z); \ return (struct fmpi_data){ \ .type = FMPI_TYPE_##T, \ .dims_length = {x, y, z}, \ diff --git a/src/fmpi_futhark.c b/src/fmpi_futhark.c index eabd518..f5a23bd 100644 --- a/src/fmpi_futhark.c +++ b/src/fmpi_futhark.c @@ -130,26 +130,26 @@ _Bool fmpi_futhark_check_error( #define FMPI_FUTHARK_DEFINITION(D, T) \ struct futhark_##T##_##D##d * fmpi_futhark_new_##D##d_##T( \ - const struct fmpi_ctx * const ctx, const T * const array, size_t x, size_t y, size_t z \ + const struct fmpi_futhark_ctx * const ctx, const T * const array, size_t x, size_t y, size_t z \ ){ \ assert(ctx != NULL); \ assert(array != NULL); \ - struct futhark_##T##_##D##d * data = FMPI_FUTHARK_NEW_##D(D, T, ctx->fut->ctx, array, x, y, z); \ + struct futhark_##T##_##D##d * data = FMPI_FUTHARK_NEW_##D(D, T, ctx->ctx, array, x, y, z); \ if(data == NULL) { \ - fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_new_##T##_##D##d)); \ + fmpi_futhark_check_error(ctx, CPL_STRINGIFY(futhark_new_##T##_##D##d)); \ } \ - fmpi_futhark_sync(ctx->fut); \ + fmpi_futhark_sync(ctx); \ return data; \ }\ void fmpi_futhark_free_##D##d_##T( \ - const struct fmpi_ctx * const ctx, struct futhark_##T##_##D##d * const array \ + const struct fmpi_futhark_ctx * const ctx, struct futhark_##T##_##D##d * const array \ ){ \ assert(ctx != NULL); \ assert(array != NULL); \ - fmpi_futhark_sync(ctx->fut);\ - const int err = futhark_free_##T##_##D##d(ctx->fut->ctx, array); \ + fmpi_futhark_sync(ctx);\ + const int err = futhark_free_##T##_##D##d(ctx->ctx, array); \ if(err != 0) { \ - fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_free_##T##_##D##d)); \ + fmpi_futhark_check_error(ctx, CPL_STRINGIFY(futhark_free_##T##_##D##d)); \ } \ } diff --git a/src/fmpi_reduce.c b/src/fmpi_reduce.c index b81ffea..3c0936e 100644 --- a/src/fmpi_reduce.c +++ b/src/fmpi_reduce.c @@ -46,14 +46,14 @@ T fmpi_local_reduce_prod_##T( \ ){ \ assert(ctx != NULL); \ assert(array != NULL); \ - struct futhark_##T##_1d * data = fmpi_futhark_new_1d_##T(ctx, array, length, 0, 0);\ + struct futhark_##T##_1d * data = fmpi_futhark_new_1d_##T(ctx->fut, array, length, 0, 0);\ T result = FMPI_TYPE_DEFAULT_##T; \ const int err = futhark_entry_reduce_prod_##T(ctx->fut->ctx, &result, data); \ if(err != 0) { \ fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_entry_reduce_prod_##T)); \ } \ fmpi_futhark_sync(ctx->fut); \ - fmpi_futhark_free_1d_##T(ctx, data); \ + fmpi_futhark_free_1d_##T(ctx->fut, data); \ return result; \ }\ T fmpi_reduce_prod_##T(const struct fmpi_ctx * const ctx, const T * const array) \ -- GitLab