1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2013 The Trustees of the University of Tennessee.
4  *                         All rights reserved.
5  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
6  *                         reserved.
7  * $COPYRIGHT$
8  *
9  * Additional copyrights may follow
10  *
11  * $HEADER$
12  */
13 
14 #include "ompi_config.h"
15 #include "ompi/mca/pml/base/pml_base_request.h"
16 #include "opal_stdint.h"
17 
18 #ifndef __INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__
19 #define __INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__
20 
21 BEGIN_C_DECLS
22 
23 /* Make sure -Wformat is happy... */
24 typedef uint64_t vprotocol_pessimist_clock_t;
25 #define PRIpclock PRIx64
26 
27 typedef enum {
28   VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING,
29   VPROTOCOL_PESSIMIST_EVENT_TYPE_DELIVERY
30 } vprotocol_pessimist_event_type_t;
31 
32 typedef struct vprotocol_pessimist_matching_event_t {
33   vprotocol_pessimist_clock_t reqid;      /* recv request post "clock" */
34   int src;                                /* matched src */
35 } vprotocol_pessimist_matching_event_t;
36 
37 typedef struct vprotocol_pessimist_delivery_event_t {
38   vprotocol_pessimist_clock_t probeid;    /* operation "clock" (for waits, tests, probes) */
39   vprotocol_pessimist_clock_t reqid;      /* delivered request (recv or send) -TODO: SUPPORT FOR WaitSome/TestSome- */
40 } vprotocol_pessimist_delivery_event_t;
41 
42 typedef union vprotocol_pessimist_mem_event_t {
43     vprotocol_pessimist_matching_event_t e_matching;
44     vprotocol_pessimist_delivery_event_t e_delivery;
45 } vprotocol_pessimist_mem_event_t;
46 
47 typedef struct mca_vprotocol_pessimist_event_t {
48   opal_free_list_item_t super;
49   vprotocol_pessimist_event_type_t type;
50   mca_pml_base_request_t *req;
51   vprotocol_pessimist_mem_event_t u_event;
52 } mca_vprotocol_pessimist_event_t;
53 
54 OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_vprotocol_pessimist_event_t);
55 
56 
57 #define VPESSIMIST_MATCHING_EVENT_NEW(event)                            \
58     do {                                                                \
59         opal_free_list_item_t *item;                                    \
60         item = opal_free_list_wait (&mca_vprotocol_pessimist.events_pool); \
61         event = (mca_vprotocol_pessimist_event_t *) item;               \
62         event->type = VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING;          \
63         event->u_event.e_matching.src = -1;                             \
64     } while(0)
65 
66 #define VPESSIMIST_DELIVERY_EVENT_NEW(event)                            \
67     do {                                                                \
68         opal_free_list_item_t *item;                                    \
69         item = opal_free_list_wait (&mca_vprotocol_pessimist.events_pool); \
70         event = (mca_vprotocol_pessimist_event_t *) item;               \
71         event->type = VPROTOCOL_PESSIMIST_EVENT_TYPE_DELIVERY;          \
72     } while(0)
73 
74 #define VPESSIMIST_EVENT_RETURN(event)                                  \
75     opal_free_list_return (&mca_vprotocol_pessimist.events_pool,        \
76                            (opal_free_list_item_t *) event)
77 
78 END_C_DECLS
79 
80 #endif /* INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__ */
81