diff --git a/src/fmpi_futhark.c b/src/fmpi_futhark.c index 991d4dfaa3a24b330c86ec1828156472d128081f..90350bd4a87038e72cc3fa55ff88c81a4bb204f5 100644 --- a/src/fmpi_futhark.c +++ b/src/fmpi_futhark.c @@ -172,11 +172,7 @@ void * fmpi_futhark_get_data_sync( assert(out != NULL); assert(dim_cnt <= FMPI_DIM_MAX); const size_t idx = FMPI_PRIV_FUTHARK_FUNC_IDX(dim_cnt, type); - const int err = fmpi_futhark_get_data_func_list[idx](ctx, in, out); - if(err != FUTHARK_SUCCESS) { - FMPI_RAISE_FUTHARK_ERROR(ctx, "futhark_values_##T##_##D##d() failed!"); - return NULL; - } + fmpi_futhark_get_data_func_list[idx](ctx, in, out); fmpi_futhark_sync(ctx); if(fmpi_futhark_check_error(ctx, "futhark_values_##T##_##D##d") == true) { return NULL; @@ -237,7 +233,11 @@ int fmpi_futhark_values_##D##d_##T( \ assert(ctx != NULL); \ assert(in != NULL); \ assert(out != NULL); \ - return futhark_values_##T##_##D##d(ctx->ctx, in, out); \ + const int err = futhark_values_##T##_##D##d(ctx->ctx, in, out); \ + if(err != FUTHARK_SUCCESS) { \ + FMPI_RAISE_FUTHARK_ERROR(ctx, CPL_STRINGIFY(futhark_free_##T##_##D##d)"() failed!"); \ + } \ + return err; \ } FMPI_DEFINE_FUNCS_DT(FMPI_FUTHARK_DEFINITION, 1, FMPI_FUTHARK_TYPES)