Skip to content
Snippets Groups Projects
Verified Commit 302a019b authored by raphael.bach's avatar raphael.bach
Browse files

Add `fmpi_futhark_new_{2,3}d()` macros

parent e5f25929
No related branches found
No related tags found
No related merge requests found
......@@ -150,8 +150,15 @@ _Bool fmpi_futhark_check_error(const struct fmpi_futhark_ctx * ctx, const char *
* TODO
* }
*/
#define fmpi_futhark_new_1d(ctx, array, length) \
FMPI_GENERIC_FUNC(array, new_1d, FMPI_FUTHARK_TYPES)(ctx, array, length)
#define fmpi_futhark_new_1d(ctx, array, x) \
FMPI_GENERIC_FUNC(array, new_1d, FMPI_FUTHARK_TYPES)(ctx, array, x, 0, 0)
#define fmpi_futhark_new_2d(ctx, array, x, y) \
FMPI_GENERIC_FUNC(array, new_2d, FMPI_FUTHARK_TYPES)(ctx, array, x, y, 0)
#define fmpi_futhark_new_3d(ctx, array, x, y, z) \
FMPI_GENERIC_FUNC(array, new_2d, FMPI_FUTHARK_TYPES)(ctx, array, x, y, z)
/*------------------------------------------------------------------------------
fmpi_futhark_init()
------------------------------------------------------------------------------*/
......
......@@ -38,9 +38,32 @@ struct fmpi_ctx;
#define FMPI_FUTHARK_TYPES \
FMPI_TYPE_REAL
#if defined(__GNUC__) || defined(__GNUG__)
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
_Pragma("GCC diagnostic push")
#elif defined(__clang__)
_Pragma("clang diagnostic ignored \"-Wunused-parameter\"")
_Pragma("clang diagnostic push")
#endif
#define FMPI_FUTHARK_NEW_1(D, T, ctx, array, x, y, z) \
futhark_new_##T##_1d(ctx, array, (int64_t)(x));
#define FMPI_FUTHARK_NEW_2(D, T, ctx, array, x, y, z) \
futhark_new_##T##_2d(ctx, array, (int64_t)(x), (int64_t)(y));
#if defined(__GNUC__) || defined(__GNUG__)
_Pragma("GCC diagnostic push")
#elif defined(__clang__)
_Pragma("clang diagnostic push")
#endif
#define FMPI_FUTHARK_NEW_3(D, T, ctx, array, x, y, z) \
futhark_new_##T##_3d(ctx, array, (int64_t)(x), (int64_t)(y), (int64_t)(z));
#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 length \
const struct fmpi_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 \
......
......@@ -127,28 +127,32 @@ _Bool fmpi_futhark_check_error(
}
return false;
}
#define FMPI_FUTHARK_DEFINITION(D, T) \
struct futhark_##T##_1d * fmpi_futhark_new_1d_##T( \
const struct fmpi_ctx * const ctx, const T * const array, const size_t length \
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 \
){ \
assert(ctx != NULL); \
assert(array != NULL); \
struct futhark_##T##_1d * data = futhark_new_##T##_1d(ctx->fut->ctx, array, (int64_t)length); \
struct futhark_##T##_##D##d * data = FMPI_FUTHARK_NEW_##D(D, T, ctx->fut->ctx, array, x, y, z); \
if(data == NULL) { \
fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_new_##T##_1d)); \
fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_new_##T##_##D##d)); \
} \
fmpi_futhark_sync(ctx->fut); \
return data; \
}\
void fmpi_futhark_free_1d_##T( \
const struct fmpi_ctx * const ctx, struct futhark_##T##_1d * const array \
void fmpi_futhark_free_##D##d_##T( \
const struct fmpi_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##_1d(ctx->fut->ctx, array); \
const int err = futhark_free_##T##_##D##d(ctx->fut->ctx, array); \
if(err != 0) { \
fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_free_##T##_1d)); \
fmpi_futhark_check_error(ctx->fut, CPL_STRINGIFY(futhark_free_##T##_##D##d)); \
} \
}
FMPI_DEFINE_DIM_FUNCS(FMPI_FUTHARK_DEFINITION, -, FMPI_FUTHARK_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_FUTHARK_DEFINITION, 1, FMPI_FUTHARK_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_FUTHARK_DEFINITION, 2, FMPI_FUTHARK_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_FUTHARK_DEFINITION, 3, FMPI_FUTHARK_TYPES)
......@@ -46,7 +46,7 @@ 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);\
struct futhark_##T##_1d * data = fmpi_futhark_new_1d_##T(ctx, 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) { \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment