File: osc_rdma_sync.h

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (158 lines) | stat: -rw-r--r-- 4,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#if !defined(OSC_RDMA_SYNC_H)
#define OSC_RDMA_SYNC_H

#include "osc_rdma_types.h"
#include "opal/class/opal_object.h"
#include "opal/threads/threads.h"

/**
 * @brief synchronization types
 */
enum ompi_osc_rdma_sync_type_t {
    /** default value */
    OMPI_OSC_RDMA_SYNC_TYPE_NONE,
    /** lock access epoch */
    OMPI_OSC_RDMA_SYNC_TYPE_LOCK,
    /** fence access epoch */
    OMPI_OSC_RDMA_SYNC_TYPE_FENCE,
    /* post-start-complete-wait access epoch */
    OMPI_OSC_RDMA_SYNC_TYPE_PSCW,
};
typedef enum ompi_osc_rdma_sync_type_t ompi_osc_rdma_sync_type_t;

struct ompi_osc_rdma_module_t;

/**
 * @brief synchronization object
 *
 * This structure holds information about an access epoch.
 */
struct ompi_osc_rdma_sync_t {
    opal_object_t super;

    /** osc rdma module */
    struct ompi_osc_rdma_module_t *module;

    /** synchronization type */
    ompi_osc_rdma_sync_type_t type;

    /** synchronization data */
    union {
        /** lock specific synchronization data */
        struct {
            /** lock target rank (-1 for all) */
            int target;

            /** lock type: MPI_LOCK_SHARED, MPI_LOCK_EXCLUSIVE */
            int16_t type;

            /** assert specified at lock acquire time. at this time Open MPI
             * only uses 5-bits for asserts. if this number goes over 16 this
             * will need to be changed to accomodate. */
            int16_t assert;
        } lock;

        /** post/start/complete/wait specific synchronization data */
        struct {
            /** group passed to ompi_osc_rdma_start */
            ompi_group_t *group;
        } pscw;
    } sync;

    /** array of peers for this sync */
    union {
        /** multiple peers (lock all, pscw, fence) */
	struct ompi_osc_rdma_peer_t **peers;
        /** single peer (targeted lock) */
	struct ompi_osc_rdma_peer_t *peer;
    } peer_list;

    /** number of peers */
    int num_peers;

    /** communication has started on this epoch */
    bool epoch_active;

    /** outstanding rdma operations on epoch */
    osc_rdma_counter_t outstanding_rdma;

    /** aggregated operations in this epoch */
    opal_list_t aggregations;

    /** lock to protect sync structure members */
    opal_mutex_t lock;
};
typedef struct ompi_osc_rdma_sync_t ompi_osc_rdma_sync_t;

OBJ_CLASS_DECLARATION(ompi_osc_rdma_sync_t);

/**
 * @brief allocate a new synchronization object
 *
 * @param[in] module   osc rdma module
 *
 * @returns NULL on failure
 * @returns a new synchronization object on success
 */
ompi_osc_rdma_sync_t *ompi_osc_rdma_sync_allocate (struct ompi_osc_rdma_module_t *module);

/**
 * @brief release a synchronization object
 *
 * @param[in] rdma_sync   synchronization object allocated by ompi_osc_rdma_sync_allocate()
 */
void ompi_osc_rdma_sync_return (ompi_osc_rdma_sync_t *rdma_sync);

/**
 * Check if the target is part of a PSCW access epoch
 *
 * @param[in] module   osc rdma module
 * @param[in] target   target rank
 * @param[out] peer    peer object
 *
 * @returns false if the window is not in a PSCW access epoch or the peer is not
 *          in the group passed to MPI_Win_start
 * @returns true otherwise
 *
 * This functions verifies the target is part of an active PSCW access epoch.
 */
bool ompi_osc_rdma_sync_pscw_peer (struct ompi_osc_rdma_module_t *module, int target, struct ompi_osc_rdma_peer_t **peer);

/**
 * @brief increment the outstanding rdma operation counter (atomic)
 *
 * @param[in] rdma_sync         osc rdma synchronization object
 */
static inline void ompi_osc_rdma_sync_rdma_inc (ompi_osc_rdma_sync_t *rdma_sync)
{
    ompi_osc_rdma_counter_add (&rdma_sync->outstanding_rdma, 1);

    OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_INFO, "inc: there are %ld outstanding rdma operations",
                     (unsigned long) rdma_sync->outstanding_rdma);
}

/**
 * @brief decrement the outstanding rdma operation counter (atomic)
 *
 * @param[in] rdma_sync         osc rdma synchronization object
 */
static inline void ompi_osc_rdma_sync_rdma_dec (ompi_osc_rdma_sync_t *rdma_sync)
{
    ompi_osc_rdma_counter_add (&rdma_sync->outstanding_rdma, -1);

    OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_INFO, "dec: there are %ld outstanding rdma operations",
                     (unsigned long) rdma_sync->outstanding_rdma);
}

#endif /* OSC_RDMA_SYNC_H */