Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
placing instrumentation of network utilization on better place
[simgrid.git] / examples / smpi / ttest01.c
1 /* Copyright (c) 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "mpi.h"
8 #include <stdio.h>
9 #include "instr/instr.h"
10
11 #define DATATOSENT 100000000
12
13 int main(int argc, char *argv[])
14 {
15   MPI_Status status;
16   int rank, numprocs, tag = 0;
17   int *r = malloc(sizeof(int) * DATATOSENT);
18
19   MPI_Init(&argc,&argv);
20   MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
21   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22
23   TRACE_smpi_set_category ("A"); 
24   if (rank == 0){
25     MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
26   }else if (rank == 1){
27     MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
28   }else{ 
29     //do nothing
30   }
31   TRACE_smpi_set_category ("B"); 
32   if (rank == 0){
33     MPI_Recv(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &status);
34   }else if (rank == 1){
35     MPI_Send(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD);
36   }else{ 
37     //do nothing
38   }
39   TRACE_smpi_set_category ("C"); 
40   MPI_Barrier (MPI_COMM_WORLD);
41   MPI_Finalize();
42   return 0;
43 }