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

Add `enum fmpi_task_type`

parent 0f14ff96
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ int main(int argc, char * argv[]) ...@@ -32,7 +32,7 @@ int main(int argc, char * argv[])
const size_t in_size = sizeof(in)/sizeof(T); const size_t in_size = sizeof(in)/sizeof(T);
T out = -1; T out = -1;
struct fmpi_task array_sum_task = FMPI_TASK_REGISTER( struct fmpi_task array_sum_task = FMPI_TASK_REGISTER(
ctx, array_sum, fmpi_no_stencil(), ctx, array_sum, FMPI_TASK_TYPE_SYNC, fmpi_no_stencil(),
fmpi_data_out(ctx, &out), fmpi_data_out(ctx, &out),
fmpi_data_1d_in(ctx, in, in_size) fmpi_data_1d_in(ctx, in, in_size)
); );
......
...@@ -83,6 +83,13 @@ typedef struct fmpi_task_args { ...@@ -83,6 +83,13 @@ typedef struct fmpi_task_args {
typedef int (* fmpi_task_func)( typedef int (* fmpi_task_func)(
const struct fmpi_ctx * ctx, const struct fmpi_task_args * args const struct fmpi_ctx * ctx, const struct fmpi_task_args * args
); );
/*------------------------------------------------------------------------------
fmpi_task_type
------------------------------------------------------------------------------*/
typedef enum fmpi_task_type {
FMPI_TASK_TYPE_SYNC,
FMPI_TASK_TYPE_ASYNC
} fmpi_task_type;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
fmpi_task fmpi_task
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
...@@ -92,6 +99,7 @@ typedef int (* fmpi_task_func)( ...@@ -92,6 +99,7 @@ typedef int (* fmpi_task_func)(
typedef struct fmpi_task { typedef struct fmpi_task {
fmpi_task_func func; //!< TODO fmpi_task_func func; //!< TODO
const char * name; //!< Name of the function. const char * name; //!< Name of the function.
enum fmpi_task_type type; //!< Sync/async
struct fmpi_task_args args; //!< TODO struct fmpi_task_args args; //!< TODO
struct fmpi_domain domains[FMPI_TASK_ARGS_MAX]; //!< TODO struct fmpi_domain domains[FMPI_TASK_ARGS_MAX]; //!< TODO
struct fmpi_stencil stencil; //!< TODO struct fmpi_stencil stencil; //!< TODO
...@@ -122,7 +130,8 @@ typedef struct fmpi_task { ...@@ -122,7 +130,8 @@ typedef struct fmpi_task {
*/ */
struct fmpi_task fmpi_task_register( struct fmpi_task fmpi_task_register(
struct fmpi_ctx * ctx, fmpi_task_func func, const char * name, struct fmpi_ctx * ctx, fmpi_task_func func, const char * name,
struct fmpi_stencil stencil, const struct fmpi_task_args * args enum fmpi_task_type type, struct fmpi_stencil stencil,
const struct fmpi_task_args * args
); );
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
fmpi_task_run_sync() fmpi_task_run_sync()
...@@ -174,8 +183,8 @@ int fmpi_task_run_async(const struct fmpi_ctx * ctx, const struct fmpi_task * ta ...@@ -174,8 +183,8 @@ int fmpi_task_run_async(const struct fmpi_ctx * ctx, const struct fmpi_task * ta
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
FMPI_TASK_REGISTER() FMPI_TASK_REGISTER()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#define FMPI_TASK_REGISTER(ctx, func, stencil, ...) \ #define FMPI_TASK_REGISTER(ctx, func, type, stencil, ...) \
FMPI_TASK_REGISTER_IMPL(ctx, func, stencil, __VA_ARGS__) FMPI_TASK_REGISTER_IMPL(ctx, func, type, stencil, __VA_ARGS__)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
FMPI_TASK_FUTHARK() FMPI_TASK_FUTHARK()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
......
...@@ -73,18 +73,18 @@ _Pragma("GCC diagnostic warning \"-Wincompatible-pointer-types\"")\ ...@@ -73,18 +73,18 @@ _Pragma("GCC diagnostic warning \"-Wincompatible-pointer-types\"")\
return futhark_entry_##FUNC(ctx, out, FMPI_PRIV_TASK_ARGS_##N(args_in)); \ return futhark_entry_##FUNC(ctx, out, FMPI_PRIV_TASK_ARGS_##N(args_in)); \
} }
#define FMPI_TASK_REGISTER_IMPL(ctx, FUNC, stencil, ...) \ #define FMPI_TASK_REGISTER_IMPL(ctx, FUNC, type, stencil, ...) \
FMPI_PRIV_TASK_CONCAT(FMPI_PRIV_TASK_REGISTER_, CPL_ARG_COUNT(__VA_ARGS__)) \ FMPI_PRIV_TASK_CONCAT(FMPI_PRIV_TASK_REGISTER_, CPL_ARG_COUNT(__VA_ARGS__)) \
(FUNC, ctx, stencil ,__VA_ARGS__) (FUNC, ctx, type, stencil ,__VA_ARGS__)
#define FMPI_PRIV_TASK_REGISTER_1(FUNC, ctx, stencil, arg_out) \ #define FMPI_PRIV_TASK_REGISTER_1(FUNC, ctx, type, stencil, arg_out) \
fmpi_task_register((ctx), FUNC##_0, #FUNC, (stencil), &(struct fmpi_task_args){ \ fmpi_task_register((ctx), FUNC##_0, #FUNC, (type), (stencil), &(struct fmpi_task_args){ \
.out = (arg_out), \ .out = (arg_out), \
.cnt = 0 \ .cnt = 0 \
}) })
#define FMPI_PRIV_TASK_REGISTER_N(N, FUNC, ctx, stencil, arg_out, ...) \ #define FMPI_PRIV_TASK_REGISTER_N(N, FUNC, ctx, type, stencil, arg_out, ...) \
fmpi_task_register((ctx), FUNC##_##N, #FUNC, (stencil), &(struct fmpi_task_args){ \ fmpi_task_register((ctx), FUNC##_##N, #FUNC, (type), (stencil), &(struct fmpi_task_args){ \
.in = {__VA_ARGS__}, \ .in = {__VA_ARGS__}, \
.out = (arg_out), \ .out = (arg_out), \
.cnt = N \ .cnt = N \
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> // NULL, size_t #include <stddef.h> // NULL, size_t
#include <stdio.h>
// Internal // Internal
#include "fmpi_domain.h" #include "fmpi_domain.h"
#include "fmpi_stencil.h" #include "fmpi_stencil.h"
...@@ -41,7 +42,8 @@ ...@@ -41,7 +42,8 @@
fmpi_task_register() fmpi_task_register()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
struct fmpi_task fmpi_task_register( struct fmpi_task fmpi_task_register(
struct fmpi_ctx * const ctx, const fmpi_task_func func, const char * const name, struct fmpi_ctx * const ctx, const fmpi_task_func func,
const char * const name, const enum fmpi_task_type type,
const struct fmpi_stencil stencil, const struct fmpi_task_args * const args const struct fmpi_stencil stencil, const struct fmpi_task_args * const args
){ ){
assert(ctx != NULL); assert(ctx != NULL);
...@@ -51,6 +53,7 @@ struct fmpi_task fmpi_task_register( ...@@ -51,6 +53,7 @@ struct fmpi_task fmpi_task_register(
struct fmpi_task task = { struct fmpi_task task = {
.func = func, .func = func,
.name = name, .name = name,
.type = type,
.args = *args, .args = *args,
.stencil = stencil .stencil = stencil
}; };
...@@ -71,7 +74,9 @@ struct fmpi_task fmpi_task_register( ...@@ -71,7 +74,9 @@ struct fmpi_task fmpi_task_register(
task.args.in[i].start = start; task.args.in[i].start = start;
} }
ctx->tasks[ctx->task_cnt++] = task; ctx->tasks[ctx->task_cnt++] = task;
if(task.type == FMPI_TASK_TYPE_SYNC) {
fmpi_futhark_sync(ctx->fut); fmpi_futhark_sync(ctx->fut);
}
return task; return task;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment