/* Project Delorean */ #ifndef delorean_H #define delorean_H #include "mpi.h" /********************************************/ /* Helper macros for future args processing */ /********************************************/ #define _G1(Param, Type1, Type2, Type1_Func, Type2_Func) \ _Generic((Param), \ Type1: Type1_Func, \ Type2: Type2_Func) #define _G2(ParamA, TypeA1, TypeA2, ParamB, TypeB1, TypeB2, \ TypeA1B1_Func, TypeA1B2_Func, TypeA2B1_Func, TypeA2B2_Func) \ _Generic( (ParamA), \ TypeA1: _G1(ParamB, TypeB1, TypeB2, TypeA1B1_Func, TypeA1B2_Func), \ TypeA2: _G1(ParamB, TypeB1, TypeB2, TypeA2B1_Func, TypeA2B2_Func) ) #define _G3(ParamA, TypeA1, TypeA2, ParamB, TypeB1, TypeB2, \ ParamC, TypeC1, TypeC2, \ TypeA1B1C1_Func, TypeA1B1C2_Func, TypeA1B2C1_Func, TypeA1B2C2_Func, \ TypeA2B1C1_Func, TypeA2B1C2_Func, TypeA2B2C1_Func, TypeA2B2C2_Func) \ _Generic( (ParamA), \ TypeA1: _G2(ParamB, TypeB1, TypeB2, ParamC, TypeC1, TypeC2, \ TypeA1B1C1_Func, TypeA1B1C2_Func, TypeA1B2C1_Func, TypeA1B2C2_Func), \ TypeA2: _G2(ParamB, TypeB1, TypeB2, ParamC, TypeC1, TypeC2, \ TypeA2B1C1_Func, TypeA2B1C2_Func, TypeA2B2C1_Func, TypeA2B2C2_Func) ) #define _G4(ParamA, TypeA1, TypeA2, ParamB, TypeB1, TypeB2, \ ParamC, TypeC1, TypeC2, ParamD, TypeD1, TypeD2, \ TypeA1B1C1D1_Func, TypeA1B1C1D2_Func, TypeA1B1C2D1_Func, TypeA1B1C2D2_Func, \ TypeA1B2C1D1_Func, TypeA1B2C1D2_Func, TypeA1B2C2D1_Func, TypeA1B2C2D2_Func, \ TypeA2B1C1D1_Func, TypeA2B1C1D2_Func, TypeA2B1C2D1_Func, TypeA2B1C2D2_Func, \ TypeA2B2C1D1_Func, TypeA2B2C1D2_Func, TypeA2B2C2D1_Func, TypeA2B2C2D2_Func) \ _Generic( (ParamA), \ TypeA1: _G3(ParamB, TypeB1, TypeB2, ParamC, TypeC1, TypeC2, \ ParamD, TypeD1, TypeD2, \ TypeA1B1C1D1_Func, TypeA1B1C1D2_Func, TypeA1B1C2D1_Func, TypeA1B1C2D2_Func, \ TypeA1B2C1D1_Func, TypeA1B2C2D2_Func, TypeA1B2C2D1_Func, TypeA1B2C2D2_Func), \ TypeA2: _G3(ParamB, TypeB1, TypeB2, ParamC, TypeC1, TypeC2, \ ParamD, TypeD1, TypeD2, \ TypeA2B1C1D1_Func, TypeA2B1C1D2_Func, TypeA2B1C2D1_Func, TypeA2B1C2D2_Func, \ TypeA2B2C1D1_Func, TypeA2B2C2D2_Func, TypeA2B2C2D1_Func, TypeA2B2C2D2_Func) ) /*********/ /* Types */ /*********/ /* Graph */ typedef struct { int id; // ID of graph int rc; // Refcount for graph } MPIX_Graph_struct; typedef MPIX_Graph_struct *MPIX_Graph; /* Async operation */ typedef struct { int id; // ID of operation int rc; // Refcount for operation } MPIX_AsyncOp_struct; typedef MPIX_AsyncOp_struct *MPIX_AsyncOp; /* "Future" */ typedef struct { int id; // ID of future int rc; // Refcount for future } MPIX_Future_struct; typedef MPIX_Future_struct *MPIX_Future; /***********************/ /* Function Prototypes */ /***********************/ /********************/ /* Graph management */ /********************/ int MPIX_Graph_create(MPI_Comm comm, MPI_Info info, MPIX_Graph *graph); int MPIX_Graph_dup(MPIX_Graph graph, MPI_Info info, MPIX_Graph *newgraph); int MPIX_Graph_free(MPIX_Graph *graph); /***********************/ /* Async Op Management */ /***********************/ int MPIX_Graph_join(MPIX_Graph graph, int count, MPIX_AsyncOp array_of_dep_ops[], MPIX_AsyncOp *op); int MPIX_Graph_wait(MPIX_Graph graph, MPIX_AsyncOp op, int ns, int *err_occured); /*************************/ /* Async User Operations */ /*************************/ //typedef void MPIX_Graph_User_function(void *invec, void *inoutvec, // MPI_Count *len, MPI_Datatype *datatype); //int MPIX_Graph_OpCreate(MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op, //MPIX_Graph_User_function(void *invec, void *inoutvec, // // MPIX_AsyncOp *op); /*************************/ /* Async Graph Execution */ /*************************/ int MPIX_Graph_pause(MPIX_Graph graph); #ifdef OPTION1 /************************************************************/ /* Async versions of existing MPI point-to-point operations */ /************************************************************/ /* MPI_Send: */ int MPIX_Graph_send_future_future(MPIX_Future fbuf, MPIX_Future fcount, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_send_future_count(MPIX_Future fbuf, MPI_Count count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_send_voidp_future(const void *buf, MPIX_Future fcount, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_send_voidp_count(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_send(buf, count, datatype, dest, tag, comm, graph, op, dep_op) \ _G2(buf, MPIX_Future, const void *, \ count, MPIX_Future, MPI_Count, \ MPIX_Graph_send_future_future, MPIX_Graph_send_future_count, \ MPIX_Graph_send_voidp_future, MPIX_Graph_send_voidp_count) \ (buf, count, datatype, dest, tag, comm, graph, op, dep_op) /* MPI_Recv: */ /* MPI_Sendrecv: (actually MPI_Sendrecv_c) */ int MPIX_Graph_Sendrecv_future_future_future_future(MPIX_Future fsendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_future_future_count(MPIX_Future fsendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_future_voidp_future(MPIX_Future fsendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_future_voidp_count(MPIX_Future fsendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_count_future_future(MPIX_Future fsendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_count_future_count(MPIX_Future fsendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_count_voidp_future(MPIX_Future fsendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_future_count_voidp_count(MPIX_Future fsendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_future_future_future(const void *sendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_future_future_count(const void *sendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_future_voidp_future(const void *sendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_future_voidp_count(const void *sendbuf, MPIX_Future fsendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_count_future_future(const void *sendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_count_future_count(const void *sendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, MPIX_Future frecvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_count_voidp_future(const void *sendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPIX_Future frecvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Sendrecv_voidp_count_voidp_count(const void *sendbuf, MPI_Count sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, MPI_Count recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, \ recvbuf, recvcount, recvtype, src, recvtag, comm, status, graph, op, dep_op) \ _G4(sendbuf, MPIX_Future, const void *, \ sendcount, MPIX_Future, MPI_Count, \ recvbuf, MPIX_Future, void *, \ recvcount, MPIX_Future, MPI_Count, \ MPIX_Graph_Sendrecv_future_future_future_future, MPIX_Graph_Sendrecv_future_future_future_count, \ MPIX_Graph_Sendrecv_future_future_voidp_future, MPIX_Graph_Sendrecv_future_future_voidp_count, \ MPIX_Graph_Sendrecv_future_count_future_future, MPIX_Graph_Sendrecv_future_count_future_count, \ MPIX_Graph_Sendrecv_future_count_voidp_future, MPIX_Graph_Sendrecv_future_count_voidp_count, \ MPIX_Graph_Sendrecv_voidp_future_future_future, MPIX_Graph_Sendrecv_voidp_future_future_count, \ MPIX_Graph_Sendrecv_voidp_future_voidp_future, MPIX_Graph_Sendrecv_voidp_future_voidp_count, \ MPIX_Graph_Sendrecv_voidp_count_future_future, MPIX_Graph_Sendrecv_voidp_count_future_count, \ MPIX_Graph_Sendrecv_voidp_count_voidp_future, MPIX_Graph_Sendrecv_voidp_count_voidp_count) \ (sendbuf, sendcount, sendtype, dst, sendtag, \ recvbuf, recvcount, recvtype, src, recvtag, comm, status, graph, op, dep_op) //int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, // int dest, int sendtag, void *recvbuf, int recvcount, // MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, // MPI_Status *status); /* ... */ /********************************************************/ /* Async versions of existing MPI collective operations */ /********************************************************/ /* MPI_Bcast (actually MPI_Bcast_c) */ int MPIX_Graph_Bcast_future_future(MPIX_Future fbuf, MPIX_Future fcount, MPI_Datatype datatype, int root, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Bcast_future_count(MPIX_Future fbuf, MPI_Count count, MPI_Datatype datatype, int root, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Bcast_voidp_future(void *buffer, MPIX_Future fcount, MPI_Datatype datatype, int root, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Bcast_voidp_count(void *buffer, MPI_Count count, MPI_Datatype datatype, int root, MPI_Comm comm, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Bcast(buf, count, datatype, root, comm, graph, op, dep_op) \ _G2(buf, MPIX_Future, void *, \ count, MPIX_Future, MPI_Count, \ MPIX_Graph_Bcast_future_future, MPIX_Graph_Bcast_future_count, \ MPIX_Graph_Bcast_voidp_future, MPIX_Graph_Bcast_voidp_count) \ (buf, count, datatype, root, comm, graph, op, dep_op) /* ... */ /***************************************************************/ /* Async versions of memory allocation and movement operations */ /***************************************************************/ /* MPI_Alloc_mem: */ int MPIX_Graph_Alloc_mem_future(MPIX_Future fsize, MPI_Info info, MPIX_Future *fbuf, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Alloc_mem_aint(MPI_Aint size, MPI_Info info, MPIX_Future *fbuf, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Alloc_mem(size, info, buf, graph, op, dep_op) \ _G1(size, MPIX_Future, MPI_Aint, MPIX_Graph_Alloc_mem_future, MPIX_Graph_Alloc_mem_aint) \ (size, info, buf, graph, op, dep_op) /* MPI_Free_mem: */ int MPIX_Graph_Free_mem_future(MPIX_Future fbuf, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Free_mem_voidp(void *buf, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Free_mem(buf, graph, op, dep_op) \ _G1(buf, MPIX_Future, void *, MPIX_Graph_Free_mem_future, MPIX_Graph_Free_mem_voidp) \ (buf, graph, op, dep_op) /* MPI_Copy_mem: */ int MPIX_Graph_Copy_mem_future_future_future(MPIX_Future fdst, MPIX_Future fsrc, MPIX_Future fsize, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_future_future_sizet(MPIX_Future fdst, MPIX_Future fsrc, size_t size, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_future_voidp_future(MPIX_Future fdst, const void *src, MPIX_Future fsize, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_voidp_future_future(void *dst, MPIX_Future fsrc, MPIX_Future fsize, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_future_voidp_sizet(MPIX_Future fdst, const void *src, size_t size, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_voidp_future_sizet(void *dst, MPIX_Future fsrc, size_t size, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_voidp_voidp_future(void *dst, const void *src, MPIX_Future fsize, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Copy_mem_voidp_voidp_sizet(void *dst, const void *src, size_t size, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Copy_mem(dst, src, size, graph, op, dep_op) \ _G3(dst, MPIX_Future, void *, src, MPIX_Future, const void *, \ size, MPIX_Future, size_t, \ MPIX_Graph_Copy_mem_future_future_future, MPIX_Graph_Copy_mem_future_future_sizet, \ MPIX_Graph_Copy_mem_future_voidp_future, MPIX_Graph_Copy_mem_future_voidp_sizet, \ MPIX_Graph_Copy_mem_voidp_future_future, MPIX_Graph_Copy_mem_voidp_future_sizet, \ MPIX_Graph_Copy_mem_voidp_voidp_future, MPIX_Graph_Copy_mem_voidp_voidp_sizet) \ (dst, src, size, graph, op, dep_op) /* MPI_Set_mem: */ int MPIX_Graph_Set_mem_future_future(MPIX_Future fbuf, int val, MPIX_Future flen, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Set_mem_future_sizet(MPIX_Future fbuf, int val, size_t len, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Set_mem_voidp_future(void *buf, int val, MPIX_Future flen, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); int MPIX_Graph_Set_mem_voidp_sizet(void *buf, int val, size_t len, MPIX_Graph graph, MPIX_AsyncOp *op, MPIX_AsyncOp dep_op); #define MPIX_Graph_Set_mem(buf, val, len, graph, op, dep_op) \ _G2(buf, MPIX_Future, void *, len, MPIX_Future, size_t, \ MPIX_Graph_Set_mem_future_future, MPIX_Graph_Set_mem_future_sizet, \ MPIX_Graph_Set_mem_voidp_future, MPIX_Graph_Set_mem_voidp_sizet) \ (buf, val, len, graph, op, dep_op) #endif /* OPTION1 */ #ifdef OPTION2 #endif /* OPTION2 */ #endif /* delorean_H */