Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / smpi / include / smpi_request.hpp
1 /* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SMPI_REQUEST_HPP_INCLUDED
7 #define SMPI_REQUEST_HPP_INCLUDED
8
9 #include "smpi/smpi.h"
10 #include "smpi_f2c.hpp"
11
12 namespace simgrid{
13 namespace smpi{
14
15 class Request : public F2C {
16   private :
17     void *buf_;
18     /* in the case of non-contiguous memory the user address should be keep
19      * to unserialize the data inside the user memory*/
20     void *old_buf_;
21     /* this let us know how to unserialize at the end of
22      * the communication*/
23     MPI_Datatype old_type_;
24     size_t size_;
25     int src_;
26     int dst_;
27     int tag_;
28     //to handle cases where we have an unknown sender
29     //We can't override src, tag, and size, because the request may be reused later
30     int real_src_;
31     int real_tag_;
32     int truncated_;
33     size_t real_size_;
34     MPI_Comm comm_;
35     smx_activity_t action_;
36     unsigned flags_;
37     int detached_;
38     MPI_Request detached_sender_;
39     int refcount_;
40     MPI_Op op_;
41   public:
42     Request()=default;
43     Request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags);
44     MPI_Comm comm();
45     size_t size();
46     size_t real_size();
47     int src();
48     int dst();
49     int tag();
50     int flags();
51     int detached();
52     void print_request(const char *message);
53     void start();
54
55     static void finish_wait(MPI_Request* request, MPI_Status * status);
56     static void unref(MPI_Request* request);
57     static void wait(MPI_Request* req, MPI_Status * status);
58     static MPI_Request send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
59     static MPI_Request isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
60     static MPI_Request ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
61     static MPI_Request rma_send_init(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm,MPI_Op op);
62     static MPI_Request recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
63     static MPI_Request rma_recv_init(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm,MPI_Op op);
64     static MPI_Request irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
65     static MPI_Request isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
66     static MPI_Request issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
67     static MPI_Request irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
68
69     static void recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status);
70     static void send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
71     static void ssend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
72
73     static void sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,int dst, int sendtag,
74                        void *recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag,
75                        MPI_Comm comm, MPI_Status * status);
76
77     static void startall(int count, MPI_Request * requests);
78
79     static int test(MPI_Request * request,MPI_Status * status);
80     static int testsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[]);
81     static int testany(int count, MPI_Request requests[], int *index, MPI_Status * status);
82     static int testall(int count, MPI_Request requests[], MPI_Status status[]);
83
84     static void probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
85     static void iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status);
86
87     static int waitany(int count, MPI_Request requests[], MPI_Status * status);
88     static int waitall(int count, MPI_Request requests[], MPI_Status status[]);
89     static int waitsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[]);
90
91     static int match_send(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored);
92     static int match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored);
93
94     int add_f();
95     static void free_f(int id);
96     static Request* f2c(int);
97
98 };
99
100
101 }
102 }
103
104 #endif