static int receiver(int argc, char *argv[]) { msg_task_t task = NULL; MSG_task_receive(&task, BOX_NAME); MC_assert(strcmp(MSG_task_get_name(task), "X") == 0); MSG_task_destroy(task); MSG_task_receive(&task, BOX_NAME); MC_assert(strcmp(MSG_task_get_name(task), "Y") == 0); MSG_task_destroy(task); return 0; }
int server(int argc, char *argv[]) { msg_task_t task1 = NULL; msg_task_t task2 = NULL; long val1, val2; MSG_task_receive(&task1, "mymailbox"); val1 = (long) MSG_task_get_data(task1); MSG_task_destroy(task1); task1 = NULL; XBT_INFO("Received %lu", val1); MSG_task_receive(&task2, "mymailbox"); val2 = (long) MSG_task_get_data(task2); MSG_task_destroy(task2); task2 = NULL; XBT_INFO("Received %lu", val2); MC_assert(min(val1, val2) == 1); MSG_task_receive(&task1, "mymailbox"); val1 = (long) MSG_task_get_data(task1); MSG_task_destroy(task1); XBT_INFO("Received %lu", val1); MSG_task_receive(&task2, "mymailbox"); val2 = (long) MSG_task_get_data(task2); MSG_task_destroy(task2); XBT_INFO("Received %lu", val2); XBT_INFO("OK"); return 0; }
/** An (fake) application with a bug occuring for some random values */ static int app(int argc, char *argv[]) { int x = MC_random(0, 5); int y = MC_random(0, 5); if (MC_is_active()) { MC_assert(x !=3 || y !=4); } if (x ==3 && y ==4) { fprintf(stderr, "Error reached\n"); } return 0; }
int server(int argc, char *argv[]) { msg_task_t task1,task2; msg_comm_t comm1 = MSG_task_irecv(&task1, "mymailbox1"); msg_comm_t comm2 = MSG_task_irecv(&task2, "mymailbox2"); MSG_comm_wait(comm1, -1); MSG_comm_wait(comm2, -1); long val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s"); XBT_INFO("Received %lu", val1); MC_assert(val1 == 2); XBT_INFO("OK"); return 0; }
static int server(int argc, char *argv[]) { msg_task_t task = NULL; int count = 0; while (count < N) { if (task) { MSG_task_destroy(task); task = NULL; } MSG_task_receive(&task, "mymailbox"); count++; } MC_assert(xbt_str_parse_int(MSG_task_get_name(task), "Task names must be integers, not '%s'") == 3); XBT_INFO("OK"); return 0; }
int server(int argc, char *argv[]) { msg_task_t task = NULL; int count = 0; while (count < N) { if (task) { MSG_task_destroy(task); task = NULL; } MSG_task_receive(&task, "mymailbox"); count++; } MC_assert(atoi(MSG_task_get_name(task)) == 3); XBT_INFO("OK"); return 0; }
int server(int argc, char *argv[]) { msg_task_t task1; long val1; msg_comm_t comm1, comm2; comm1 = MSG_task_irecv(&task1, "mymailbox1"); comm2 = MSG_task_irecv(&task1, "mymailbox2"); MSG_comm_wait(comm1, -1); MSG_comm_wait(comm2, -1); val1 = (long) MSG_task_get_data(task1); XBT_INFO("Received %lu", val1); MC_assert(val1 == 2); XBT_INFO("OK"); return 0; }
int main(int argc, char **argv) { int recv_buff, err, size, rank, i; MPI_Status status; /* Initialize MPI */ err = MPI_Init(&argc, &argv); if (err != MPI_SUCCESS) { printf("MPI initialization failed!\n"); exit(1); } err = MPI_Comm_size(MPI_COMM_WORLD, &size); /* Get nr of tasks */ err = MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get id of this process */ if (size < 2) { printf("run this program with exactly 2 processes (-np 2)\n"); MPI_Finalize(); exit(0); } if (rank == 0) { printf("MPI_ISend / MPI_IRecv Test \n"); for(i=0; i < size - 1; i++){ MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); printf("Message received from %d\n", recv_buff); } printf("recv_buff = %d\n", recv_buff); #ifdef HAVE_MC MC_assert(recv_buff == size - 1); #endif }else{ MPI_Send(&rank, 1, MPI_INT, 0, 42, MPI_COMM_WORLD); printf("Sent %d to rank 0\n", rank); } MPI_Finalize(); return 0; }