Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in smpi, mostly cosmetic stuff and indent
[simgrid.git] / src / smpi / include / smpi_request.hpp
1 /* Copyright (c) 2010-2019. 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   void* buf_;
17   /* in the case of non-contiguous memory the user address should be keep
18    * to unserialize the data inside the user memory*/
19   void* old_buf_;
20   /* this is especially for derived datatypes that we need to serialize/unserialize.
21    * It let us know how to unserialize at the end of the communication */
22   MPI_Datatype old_type_;
23   size_t size_;
24   int src_;
25   int dst_;
26   int tag_;
27   // to handle cases where we have an unknown sender
28   // We can't override src, tag, and size, because the request may be reused later
29   int real_src_;
30   int real_tag_;
31   int truncated_;
32   size_t real_size_;
33   MPI_Comm comm_;
34   smx_activity_t action_;
35   unsigned flags_;
36   int detached_;
37   MPI_Request detached_sender_;
38   int refcount_;
39   MPI_Op op_;
40   int cancelled_;
41
42 public:
43   Request() = default;
44   Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags);
45   MPI_Comm comm() { return comm_; }
46   size_t size() { return size_; }
47   size_t real_size() { return real_size_; }
48   int src() { return src_; }
49   int dst() { return dst_; }
50   int tag() { return tag_; }
51   int flags() { return flags_; }
52   int detached() { return detached_; }
53   MPI_Datatype type() { return old_type_; }
54   void print_request(const char* message);
55   void start();
56   void cancel();
57   void ref();
58   static void finish_wait(MPI_Request* request, MPI_Status* status);
59   static void unref(MPI_Request* request);
60   static void wait(MPI_Request* req, MPI_Status* status);
61   static MPI_Request send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
62   static MPI_Request isend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
63   static MPI_Request ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
64   static MPI_Request rma_send_init(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag,
65                                    MPI_Comm comm, MPI_Op op);
66   static MPI_Request recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
67   static MPI_Request rma_recv_init(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag,
68                                    MPI_Comm comm, MPI_Op op);
69   static MPI_Request irecv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
70   static MPI_Request isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
71   static MPI_Request issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
72   static MPI_Request irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
73
74   static void recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
75   static void send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
76   static void ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
77
78   static void sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf,
79                        int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
80
81   static void startall(int count, MPI_Request* requests);
82
83   static int test(MPI_Request* request, MPI_Status* status);
84   static int testsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]);
85   static int testany(int count, MPI_Request requests[], int* index, MPI_Status* status);
86   static int testall(int count, MPI_Request requests[], MPI_Status status[]);
87
88   static void probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
89   static void iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status);
90
91   static int waitany(int count, MPI_Request requests[], MPI_Status* status);
92   static int waitall(int count, MPI_Request requests[], MPI_Status status[]);
93   static int waitsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]);
94
95   static int match_send(void* a, void* b, kernel::activity::CommImpl* ignored);
96   static int match_recv(void* a, void* b, kernel::activity::CommImpl* ignored);
97
98   int add_f() override;
99   static void free_f(int id);
100   static Request* f2c(int);
101 };
102
103
104 }
105 }
106
107 #endif