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

Add `fmpi_data_{1,2,3}d_in{_new}?()` and `fmpi_data_{1,2,3}d_out()` macros

- Remove `fmpi_data_create()`
parent 302a019b
Branches
Tags
No related merge requests found
...@@ -34,11 +34,11 @@ int main(int argc, char * argv[]) ...@@ -34,11 +34,11 @@ int main(int argc, char * argv[])
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,17, 0,0,0,0,0,0,0,17,
}; };
T out = 0; T out;
struct fmpi_task array_sum_task = FMPI_TASK_REGISTER( struct fmpi_task array_sum_task = FMPI_TASK_REGISTER(
ctx, fut_array_sum, ctx, fut_array_sum,
fmpi_data_1d(ctx, &out, 1), fmpi_data_1d_out(ctx, &out, 1),
fmpi_data_1d(ctx, in, 64), fmpi_data_1d_in_new(ctx, in, 64),
); );
fmpi_task_run(ctx, &array_sum_task); fmpi_task_run(ctx, &array_sum_task);
if(fmpi_is_root(ctx)) { if(fmpi_is_root(ctx)) {
......
...@@ -72,8 +72,14 @@ typedef struct fmpi_data { ...@@ -72,8 +72,14 @@ typedef struct fmpi_data {
* TODO * TODO
* } * }
*/ */
#define fmpi_data_1d(ctx, data, x) \ #define fmpi_data_1d_in(ctx, data, x) \
FMPI_DATA_FUNC(data_1d, ctx, data, x, 0, 0) FMPI_DATA_FUNC(data_1d_in, ctx, data, x, 1, 1)
#define fmpi_data_1d_in_new(ctx, data, x) \
FMPI_DATA_FUNC(data_1d_in_new, ctx, data, x, 1, 1)
#define fmpi_data_1d_out(ctx, data, x) \
FMPI_DATA_FUNC(data_1d_out, ctx, data, x, 1, 1)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
fmpi_data_2d() fmpi_data_2d()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
...@@ -92,8 +98,14 @@ typedef struct fmpi_data { ...@@ -92,8 +98,14 @@ typedef struct fmpi_data {
* TODO * TODO
* } * }
*/ */
#define fmpi_data_2d(ctx, data, x, y) \ #define fmpi_data_2d_in(ctx, data, x, y) \
FMPI_DATA_FUNC(data_2d, ctx, data, x, y, 0) FMPI_DATA_FUNC(data_2d_in, ctx, data, x, y, 1)
#define fmpi_data_2d_in_new(ctx, data, x, y) \
FMPI_DATA_FUNC(data_1d_in_new, ctx, data, x, y, 1)
#define fmpi_data_2d_out(ctx, data, x, y) \
FMPI_DATA_FUNC(data_2d_out, ctx, data, x, y, 1)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
fmpi_data_3d() fmpi_data_3d()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
...@@ -113,8 +125,14 @@ typedef struct fmpi_data { ...@@ -113,8 +125,14 @@ typedef struct fmpi_data {
* TODO * TODO
* } * }
*/ */
#define fmpi_data_3d(ctx, data, x, y, z) \ #define fmpi_data_3d_in(ctx, data, x, y, z) \
FMPI_DATA_FUNC(data_3d, ctx, data, x, y, z) FMPI_DATA_FUNC(data_3d_in, ctx, data, x, y, z)
#define fmpi_data_3d_in_new(ctx, data, x, y, z) \
FMPI_DATA_FUNC(data_3d_in_new, ctx, data, x, y, z)
#define fmpi_data_3d_out(ctx, data, x, y, z) \
FMPI_DATA_FUNC(data_3d_out, ctx, data, x, y, z)
/*============================================================================== /*==============================================================================
GUARD GUARD
==============================================================================*/ ==============================================================================*/
......
...@@ -42,7 +42,13 @@ struct fmpi_ctx; ...@@ -42,7 +42,13 @@ struct fmpi_ctx;
FMPI_GENERIC_FUNC(data, func, FMPI_DATA_TYPES)(ctx, data, x, y, z) FMPI_GENERIC_FUNC(data, func, FMPI_DATA_TYPES)(ctx, data, x, y, z)
#define FMPI_DATA_DECLARATION(D, T) \ #define FMPI_DATA_DECLARATION(D, T) \
struct fmpi_data fmpi_data_##D##d_##T( \ struct fmpi_data fmpi_data_##D##d_in_##T( \
const struct fmpi_ctx * ctx, T * data, size_t x, size_t y, size_t z \
);\
struct fmpi_data fmpi_data_##D##d_in_new_##T( \
const struct fmpi_ctx * ctx, T * data, size_t x, size_t y, size_t z \
);\
struct fmpi_data fmpi_data_##D##d_out_##T( \
const struct fmpi_ctx * ctx, T * data, size_t x, size_t y, size_t z \ const struct fmpi_ctx * ctx, T * data, size_t x, size_t y, size_t z \
) )
......
...@@ -26,42 +26,59 @@ ...@@ -26,42 +26,59 @@
// C Standard Library // C Standard Library
#include <assert.h> #include <assert.h>
#include <stddef.h> // NULL, size_t #include <stddef.h> // NULL, size_t
#include <stdio.h> // fprintf()
#include <stdlib.h> // malloc()
// Internal // Internal
#include "internal/fmpi_futhark.h" #include "internal/fmpi_futhark.h"
#include "internal/generic/fmpi_type.h" #include "internal/generic/fmpi_type.h"
/*==============================================================================
PRIVATE FUNCTION DECLARATION
==============================================================================*/
static struct fmpi_data fmpi_data_create(
void * data, enum fmpi_type type, size_t dims_cnt, size_t x, size_t y, size_t z
);
/*============================================================================== /*==============================================================================
PUBLIC FUNCTION DEFINITION PUBLIC FUNCTION DEFINITION
==============================================================================*/ ==============================================================================*/
#define FMPI_DATA_DEFINITION(D, T) \ #define FMPI_DATA_DEFINITION(D, T) \
struct fmpi_data fmpi_data_##D##d_##T( \ struct fmpi_data fmpi_data_##D##d_in_##T( \
const struct fmpi_ctx * const ctx, T * const data, const size_t x, const size_t y, const size_t z \ const struct fmpi_ctx * const ctx, T * const data, \
const size_t x, const size_t y, const size_t z \
){ \ ){ \
assert(ctx != NULL); \
assert(data != NULL); \ assert(data != NULL); \
return fmpi_data_create(data, FMPI_TYPE_##T, D, x, y, z); \ _Static_assert(D <= 3, ""); \
return (struct fmpi_data){ \
.type = FMPI_TYPE_##T, \
.dims_length = {x, y, z}, \
.dims_cnt = D, \
.start = data \
}; \
} \
struct fmpi_data fmpi_data_##D##d_in_new_##T( \
const struct fmpi_ctx * const ctx, T * const data, \
const size_t x, const size_t y, const size_t z \
){ \
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); \
return (struct fmpi_data){ \
.type = FMPI_TYPE_##T, \
.dims_length = {x, y, z}, \
.dims_cnt = D, \
.start = start \
}; \
} \
struct fmpi_data fmpi_data_##D##d_out_##T( \
const struct fmpi_ctx * const ctx, T * const data, \
const size_t x, const size_t y, const size_t z \
){ \
assert(ctx != NULL); \
assert(data != NULL); \
_Static_assert(D <= 3, ""); \
return (struct fmpi_data){ \
.type = FMPI_TYPE_##T, \
.dims_length = {x, y, z}, \
.dims_cnt = D, \
.start = data \
}; \
} }
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 1, FMPI_DATA_TYPES) FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 1, FMPI_DATA_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 2, FMPI_DATA_TYPES) FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 2, FMPI_DATA_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 3, FMPI_DATA_TYPES) FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 3, FMPI_DATA_TYPES)
/*==============================================================================
PRIVATE FUNCTION DEFINITION
==============================================================================*/
static struct fmpi_data fmpi_data_create(
void * const data, const enum fmpi_type type, const size_t dims_cnt,
const size_t x, const size_t y, const size_t z
){
assert(data != NULL);
assert(dims_cnt >= 0 && dims_cnt <= 3);
return (struct fmpi_data){
.type = type,
.dims_length = {x, y, z},
.dims_cnt = dims_cnt,
.start = data
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment