1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SMPI_REQUEST_HPP_INCLUDED
7 #define SMPI_REQUEST_HPP_INCLUDED
10 #include "smpi_f2c.hpp"
15 class Request : public F2C {
17 /* in the case of non-contiguous memory the user address should be keep
18 * to unserialize the data inside the user memory*/
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_;
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
34 smx_activity_t action_;
37 MPI_Request detached_sender_;
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);
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);
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);
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);
81 static void startall(int count, MPI_Request* requests);
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[]);
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);
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[]);
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);
99 static void free_f(int id);
100 static Request* f2c(int);