Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
re-start smpi from scratch to use SIMIX.
[simgrid.git] / src / smpi / src / smpi_mpi.c
1 #include <stdio.h>
2 #include <sys/time.h>
3 #include "smpi.h"
4
5 int MPI_Init(int *argc, char ***argv)
6 {
7         smpi_mpi_init();
8         smpi_bench_begin();
9         return MPI_SUCCESS;
10 }
11
12 int MPI_Finalize()
13 {
14         smpi_bench_end();
15         smpi_mpi_finalize();
16         return MPI_SUCCESS;
17 }
18
19 // right now this just exits the current node, should send abort signal to all
20 // hosts in the communicator;
21 int MPI_Abort(MPI_Comm comm, int errorcode)
22 {
23         smpi_exit(errorcode);
24 }
25
26 int MPI_Comm_size(MPI_Comm comm, int *size)
27 {
28         int retval = MPI_SUCCESS;
29
30         smpi_bench_end();
31
32         if (NULL == comm) {
33                 retval = MPI_ERR_COMM;
34         } else if (NULL == size) {
35                 retval = MPI_ERR_ARG;
36         } else {
37                 *size = comm->size;
38         }
39
40         smpi_bench_begin();
41
42         return retval;
43 }
44
45 int MPI_Comm_rank(MPI_Comm comm, int *rank)
46 {
47         int retval = MPI_SUCCESS;
48
49         smpi_bench_end();
50
51         if (NULL == comm) {
52                 retval = MPI_ERR_COMM;
53         } else if (NULL == rank) {
54                 retval = MPI_ERR_ARG;
55         } else {
56                 *rank = smpi_comm_rank(comm, SIMIX_host_self());
57         }
58
59         smpi_bench_begin();
60
61         return retval;
62 }
63
64 int MPI_Type_size(MPI_Datatype datatype, size_t *size)
65 {
66         int retval = MPI_SUCCESS;
67
68         smpi_bench_end();
69
70         if (NULL == datatype) {
71                 retval = MPI_ERR_TYPE;
72         } else if (NULL == size) {
73                 retval = MPI_ERR_ARG;
74         } else {
75                 *size = datatype->size;
76         }
77
78         smpi_bench_begin();
79
80         return retval;
81 }
82
83 int MPI_Barrier(MPI_Comm comm)
84 {
85         smpi_bench_end();
86         smpi_barrier(comm);
87         smpi_bench_begin();
88         return MPI_SUCCESS;
89 }