d3a8b8cc64bcd08895d2f3ec74d96d8345e59b12
[alexxy/gromacs.git] / src / gromacs / gmxlib / thread_mpi / p2p.h
1 /*
2    This source code file is part of thread_mpi.
3    Written by Sander Pronk, Erik Lindahl, and possibly others.
4
5    Copyright (c) 2009, Sander Pronk, Erik Lindahl.
6    All rights reserved.
7
8    Redistribution and use in source and binary forms, with or without
9    modification, are permitted provided that the following conditions are met:
10    1) Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12    2) Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15    3) Neither the name of the copyright holders nor the
16    names of its contributors may be used to endorse or promote products
17    derived from this software without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY
20    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22    DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY
23    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30    If you want to redistribute modifications, please consider that
31    scientific software is very special. Version control is crucial -
32    bugs must be traceable. We will be happy to consider code for
33    inclusion in the official distribution, but derived work should not
34    be called official thread_mpi. Details are found in the README & COPYING
35    files.
36  */
37
38
39 /* request list: */
40 /* get a request from the thread's pre-allocated request list */
41 struct tmpi_req_ *tMPI_Get_req(struct req_list *rl);
42 /* return a request to the thread's pre-allocated request list */
43 void tMPI_Return_req(struct req_list *rl, struct tmpi_req_ *req);
44
45 /* initialize a request with sensible values */
46 void tMPI_Req_init(struct tmpi_req_ *rq, struct envelope *ev);
47
48 /* wait for incoming connections (and the completion of outgoing connections
49    if spin locks are disabled), and handle them. */
50 void tMPI_Wait_process_incoming(struct tmpi_thread *th);
51
52
53
54
55
56 /* check for the completion of a single request */
57 tmpi_bool tMPI_Test_single(struct tmpi_thread *cur,
58                            struct tmpi_req_   *rq);
59 /* check and wait for the completion of a single request */
60 void tMPI_Wait_single(struct tmpi_thread *cur, struct tmpi_req_ *rq);
61
62 /* check for the completion of a NULL-delimited doubly linked list of
63    requests */
64 tmpi_bool tMPI_Test_multi(struct tmpi_thread *cur, struct tmpi_req_ *rqs,
65                           tmpi_bool *any_done);
66
67
68
69 /* set a request status */
70 void tMPI_Set_status(struct tmpi_req_ *req, tMPI_Status *st);
71
72
73 /* post a send envelope */
74 struct envelope *tMPI_Post_send(struct tmpi_thread *cur,
75                                 tMPI_Comm comm,
76                                 struct tmpi_thread *dest,
77                                 void *send_buf, int send_count,
78                                 tMPI_Datatype datatype, int tag,
79                                 tmpi_bool nonblock);
80
81 /* post and match a receive envelope */
82 struct envelope* tMPI_Post_match_recv(struct tmpi_thread *cur,
83                                       tMPI_Comm comm,
84                                       struct tmpi_thread *src,
85                                       void *recv_buf, int recv_count,
86                                       tMPI_Datatype datatype,
87                                       int tag, tmpi_bool nonblock);