1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2010 Sandia National Laboratories. All rights reserved.
13 * $COPYRIGHT$
14 *
15 * Additional copyrights may follow
16 *
17 * $HEADER$
18 */
19
20 #ifndef OMPI_MTL_PORTALS_RECV_SHORT_H
21 #define OMPI_MTL_PORTALS_RECV_SHORT_H
22
23 #include "mtl_portals4_request.h"
24
25 struct ompi_mtl_portals4_recv_short_block_t {
26 opal_list_item_t base;
27 void *start;
28 ptl_handle_me_t me_h;
29 struct ompi_mtl_portals4_recv_short_request_t request;
30 bool release_on_free;
31 char status; /* see Note after */
32 };
33 /* Note: Even if portals4 may guarantee that PTL_EVENT_AUTO_UNLINK comes before
34 * PTL_EVENT_AUTO_FREE, we are not sure that this is the case in a
35 * multi-threaded environment : A thread catching the PTL_EVENT_AUTO_UNLINK
36 * may be preceded by another catching the PTL_EVENT_AUTO_FREE even if this
37 * event comes after. That is why we introduce the status field with the
38 * following STATUSES. */
39
40 #define BLOCK_STATUS_INACTIVE 0 /* The block has just been malloc'ed */
41 #define BLOCK_STATUS_WAITING_LINK 1 /* The PtlMEAppend has been called. Now wait for PTL_EVENT_LINK */
42 #define BLOCK_STATUS_ACTIVATED 2 /* PTL_EVENT_LINK has been received, the block is operational */
43 #define BLOCK_STATUS_WAITING_FREE 3 /* The PTL_EVENT_AUTO_UNLINK has been received, now wait for a PTL_EVENT_AUTO_FREE */
44 #define BLOCK_STATUS_WAITING_UNLINK 4 /* The PTL_EVENT_AUTO_FREE has been received, now wait for a PTL_EVENT_AUTO_UNLINK (rare) */
45
46 typedef struct ompi_mtl_portals4_recv_short_block_t ompi_mtl_portals4_recv_short_block_t;
47 OBJ_CLASS_DECLARATION(ompi_mtl_portals4_recv_short_block_t);
48
49 /* initialize and post short receive blocks */
50 extern int ompi_mtl_portals4_recv_short_init(void);
51
52 /* clean up all short receive blocks */
53 extern int ompi_mtl_portals4_recv_short_fini(void);
54
55 /* ensure that there's at least N short receive blocks linked */
56 extern int ompi_mtl_portals4_recv_short_link(int count);
57
58 #endif /* OMPI_MTL_PORTALS_RECV_SHORT_H */