Skip to content
Snippets Groups Projects
dispatch.h 2.49 KiB
Newer Older
#ifndef _DISPATCH_H_
#define _DISPATCH_H_

baptiste.coudray's avatar
baptiste.coudray committed
#include "../lattice_boltzmann/lbm.h"
#include "chunk_info.h"
baptiste.coudray's avatar
baptiste.coudray committed
//#include "envelope.h"
baptiste.coudray's avatar
baptiste.coudray committed
#define FUTHARK_I8  "  i8"
#define FUTHARK_U8  "  i8"
#define FUTHARK_I16 " i16"
#define FUTHARK_U16 " i16"
#define FUTHARK_I32 " i32"
#define FUTHARK_U32 " i32"
#define FUTHARK_I64 " i64"
#define FUTHARK_U64 " i64"
#define FUTHARK_F32 " f32"
#define FUTHARK_F64 " f64"
baptiste.coudray's avatar
baptiste.coudray committed
#define NB_SIDES 6
#define NB_CHUNKS 9

#define INDEX_SIDE_BACK 0
#define INDEX_SIDE_BOTTOM 1
#define INDEX_SIDE_FRONT 2
#define INDEX_SIDE_LEFT 3
#define INDEX_SIDE_RIGHT 4
#define INDEX_SIDE_TOP 5

#define INDEX_CHUNK_NORTH_WEST 0
#define INDEX_CHUNK_WEST 1
#define INDEX_CHUNK_SOUTH_WEST 2
#define INDEX_CHUNK_SOUTH 3
#define INDEX_CHUNK_SOUTH_EAST 4
#define INDEX_CHUNK_EAST 5
#define INDEX_CHUNK_NORTH_EAST 6
#define INDEX_CHUNK_NORTH 7
#define INDEX_CHUNK_SURFACE 8

struct dispatch_context;

baptiste.coudray's avatar
baptiste.coudray committed
typedef struct side_envelope {
    chunk_info_t chunks[NB_CHUNKS];
    chunk_info_t *north_west;
    chunk_info_t *north;
    chunk_info_t *north_east;
    chunk_info_t *east;
    chunk_info_t *south;
    chunk_info_t *south_east;
    chunk_info_t *west;
    chunk_info_t *south_west;
    chunk_info_t *surface;
} side_envelope_t;

typedef struct envelope {
baptiste.coudray's avatar
baptiste.coudray committed
    side_envelope_t sides[NB_SIDES];
    side_envelope_t *back;
    side_envelope_t *bottom;
    side_envelope_t *front;
    side_envelope_t *left;
    side_envelope_t *right;
    side_envelope_t *top;
baptiste.coudray's avatar
baptiste.coudray committed
extern void envelope_init_accessors(envelope_t *envelope);

baptiste.coudray's avatar
baptiste.coudray committed
extern struct dispatch_context *dispatch_context_new(const int *dimensions, MPI_Datatype datatype, int n_dimensions);

extern void dispatch_context_print(struct dispatch_context *dc);

extern envelope_t get_inner_envelope(struct dispatch_context *dc, struct futhark_context *fc, int thickness);

extern envelope_t get_outer_envelope(struct dispatch_context *dc, struct futhark_context *fc, int thickness);

extern void *
futhark_outer_envelope_new(struct dispatch_context *dc, struct futhark_context *fc, envelope_t *outer_envelope,
baptiste.coudray's avatar
baptiste.coudray committed
                           void *f(struct futhark_context *, const void *), char *futhark_type);
extern chunk_info_t get_chunk_info(struct dispatch_context *dc);

extern void *get_data(struct dispatch_context *dc);

extern void dispatch_context_free(struct dispatch_context *dc);

extern void
set_active_domain(struct dispatch_context *dc, struct futhark_context *fc, int *dimensions, int y, int x, int z);
extern void envelope_free(envelope_t *envelope);

#endif //_DISPATCH_H_