Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
welcome simgrid::smpi::Request
[simgrid.git] / src / smpi / smpi_request.hpp
1 /* Copyright (c) 2010, 2013-2015. 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 #ifndef SMPI_REQUEST_HPP_INCLUDED
8 #define SMPI_REQUEST_HPP_INCLUDED
9
10 #include "private.h"
11
12 namespace simgrid{
13 namespace smpi{
14
15 class Request {
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(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags);
43     MPI_Comm comm();
44     int src();
45     int dst();
46     int tag();
47     int flags();
48     void print_request(const char *message);
49     void start();
50
51     static void finish_wait(MPI_Request* request, MPI_Status * status);
52     static void unuse(MPI_Request* request);
53     static void wait(MPI_Request* req, MPI_Status * status);
54     static MPI_Request send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
55     static MPI_Request isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
56     static MPI_Request ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
57     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);
58     static MPI_Request recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
59     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);
60     static MPI_Request irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
61     static MPI_Request isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
62     static MPI_Request issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
63     static MPI_Request irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
64
65     static void recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status);
66     static void send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
67     static void ssend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
68
69     static void sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,int dst, int sendtag,
70                        void *recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag,
71                        MPI_Comm comm, MPI_Status * status);
72
73     static void startall(int count, MPI_Request * requests);
74
75     static int test(MPI_Request * request,MPI_Status * status);
76     static int testsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[]);
77     static int testany(int count, MPI_Request requests[], int *index, MPI_Status * status);
78     static int testall(int count, MPI_Request requests[], MPI_Status status[]);
79
80     static void probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
81     static void iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status);
82
83     static int waitany(int count, MPI_Request requests[], MPI_Status * status);
84     static int waitall(int count, MPI_Request requests[], MPI_Status status[]);
85     static int waitsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[]);
86
87     static int match_send(void* a, void* b,smx_activity_t ignored);
88     static int match_recv(void* a, void* b,smx_activity_t ignored);
89 };
90
91 }
92 }
93
94 #endif