#include #include "mpi.h" #include "delorean.h" #ifdef OPTION1 /**********************************************/ /* Demonstrate that _Generic() works properly */ /**********************************************/ void demo_1generic(void) { MPIX_Graph graph; void *buf = NULL; MPIX_Future future_buf = NULL; MPI_Aint size = 7; MPIX_Future future_size = NULL; printf("\n%s:\n", __func__); MPIX_Graph_create(MPI_COMM_WORLD, MPI_INFO_NULL, &graph); // Try both combinations of future & present parameters for MPIX_Graph_Alloc_mem MPIX_Graph_Alloc_mem(future_size, MPI_INFO_NULL, &future_buf, graph, NULL, NULL); MPIX_Graph_Alloc_mem(size, MPI_INFO_NULL, &future_buf, graph, NULL, NULL); // Try both combinations of future & present parameters for MPIX_Graph_Free_mem MPIX_Graph_Free_mem(future_buf, graph, NULL, NULL); MPIX_Graph_Free_mem(buf, graph, NULL, NULL); MPIX_Graph_free(&graph); } void demo_2generic(void) { MPIX_Graph graph; const void *buf = NULL; MPIX_Future future_buf = NULL; MPI_Count count = 7; MPIX_Future future_count = NULL; MPI_Datatype datatype = MPI_INT; int dest = 2; int tag = 0; MPI_Comm send_comm = MPI_COMM_WORLD; printf("\n%s:\n", __func__); MPIX_Graph_create(MPI_COMM_WORLD, MPI_INFO_NULL, &graph); // Try all 4 combinations of future & present parameters for MPIX_Graph_send MPIX_Graph_send(future_buf, future_count, datatype, dest, tag, send_comm, graph, NULL, NULL); MPIX_Graph_send(future_buf, count, datatype, dest, tag, send_comm, graph, NULL, NULL); MPIX_Graph_send(buf, future_count, datatype, dest, tag, send_comm, graph, NULL, NULL); MPIX_Graph_send(buf, count, datatype, dest, tag, send_comm, graph, NULL, NULL); MPIX_Graph_free(&graph); } void demo_3generic(void) { MPIX_Graph graph; void *dst = NULL; MPIX_Future future_dst = NULL; const void *src = NULL; MPIX_Future future_src = NULL; size_t size = 7; MPIX_Future future_size = NULL; printf("\n%s:\n", __func__); MPIX_Graph_create(MPI_COMM_WORLD, MPI_INFO_NULL, &graph); // Try all 8 combinations of future & present parameters for MPIX_Graph_Copy_mem MPIX_Graph_Copy_mem(future_dst, future_src, future_size, graph, NULL, NULL); MPIX_Graph_Copy_mem(future_dst, future_src, size, graph, NULL, NULL); MPIX_Graph_Copy_mem(future_dst, src, future_size, graph, NULL, NULL); MPIX_Graph_Copy_mem(dst, future_src, future_size, graph, NULL, NULL); MPIX_Graph_Copy_mem(future_dst, src, size, graph, NULL, NULL); MPIX_Graph_Copy_mem(dst, future_src, size, graph, NULL, NULL); MPIX_Graph_Copy_mem(dst, src, future_size, graph, NULL, NULL); MPIX_Graph_Copy_mem(dst, src, size, graph, NULL, NULL); // Also try all combinations of future & present parameters for MPIX_Graph_Set_mem MPIX_Graph_Set_mem(future_dst, 'c', future_size, graph, NULL, NULL); MPIX_Graph_Set_mem(future_dst, 'c', size, graph, NULL, NULL); MPIX_Graph_Set_mem(dst, 'c', future_size, graph, NULL, NULL); MPIX_Graph_Set_mem(dst, 'c', size, graph, NULL, NULL); MPIX_Graph_free(&graph); } void usecase_1(void) { MPIX_Graph graph; int bcast_val = 2; MPIX_AsyncOp bcast_op; MPIX_Graph sub_graph; int sendval = 7; int recvval = 0; MPI_Status status; printf("\n%s:\n", __func__); /* Create graph */ MPIX_Graph_create(MPI_COMM_WORLD, MPI_INFO_NULL, &graph); /* Bcast value */ MPIX_Graph_Bcast((void *)&bcast_val, (MPI_Count)1, MPI_INT, 0, MPI_COMM_WORLD, graph, &bcast_op, NULL); /* Loop over sendrecv to neighbors */ /* Create block for loop */ MPIX_Graph_create(MPI_COMM_WORLD, MPI_INFO_NULL, &sub_graph); MPIX_Graph_pause(sub_graph); MPIX_Graph_Sendrecv((const void *)&sendval, (MPI_Count)1, MPI_INT, 1 /*dst*/, 0 /*sendtag*/, (void *)&recvval, (MPI_Count)1, MPI_INT, 2 /*src*/, 0 /*recvtag*/, MPI_COMM_WORLD, &status, sub_graph, NULL, NULL); MPIX_Graph_free(&sub_graph); MPIX_Graph_free(&graph); } #endif /* OPTION1 */ int main() { /* Demonstrate that _Generic() works properly */ demo_1generic(); demo_2generic(); demo_3generic(); /* Use cases */ usecase_1(); return 0; }