File: osc_portals4_active_target.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (196 lines) | stat: -rw-r--r-- 5,595 bytes parent folder | download | duplicates (2)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
 * Copyright (c) 2011      Sandia National Laboratories.  All rights reserved.
 * Copyright (c) 2017      The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "ompi_config.h"

#include "ompi/mca/osc/base/base.h"
#include "ompi/mca/osc/base/osc_base_obj_convert.h"
#include "ompi/mca/osc/osc.h"

#include "osc_portals4.h"


int
ompi_osc_portals4_fence(int mpi_assert, struct ompi_win_t *win)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;
    int comm_ret, ret;

    /* can't enter an active target epoch when in a passive target epoch */
    if (module->passive_target_access_epoch) {
        return OMPI_ERR_RMA_SYNC;
    }

    comm_ret = ompi_osc_portals4_complete_all(module);

    ret = module->comm->c_coll->coll_barrier(module->comm,
                                            module->comm->c_coll->coll_barrier_module);

    return (OMPI_SUCCESS == comm_ret) ? ret : comm_ret;
}


int
ompi_osc_portals4_start(struct ompi_group_t *group,
                        int mpi_assert,
                        struct ompi_win_t *win)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;

    /* can't enter an active target epoch when in a passive target epoch */
    if (module->passive_target_access_epoch) {
        return OMPI_ERR_RMA_SYNC;
    }

    if (0 == (mpi_assert & MPI_MODE_NOCHECK)) {
        int size;

        OBJ_RETAIN(group);
        module->start_group = group;
        size = ompi_group_size(module->start_group);

        while (module->state.post_count != size) opal_progress();
    } else {
        module->start_group = NULL;
    }

    return OMPI_SUCCESS;
}


int
ompi_osc_portals4_complete(struct ompi_win_t *win)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;
    int ret, i, size;

    ret = ompi_osc_portals4_complete_all(module);
    if (ret != OMPI_SUCCESS) return ret;

    if (NULL != module->start_group) {
        module->state.post_count = 0;
        PtlAtomicSync();

        size = ompi_group_size(module->start_group);
        for (i = 0 ; i < size ; ++i) {

            ret = PtlAtomic(module->md_h,
                            (ptl_size_t) &module->one,
                            sizeof(module->one),
                            PTL_ACK_REQ,
                            ompi_osc_portals4_get_peer_group(module->start_group, i),
                            module->pt_idx,
                            module->match_bits | OSC_PORTALS4_MB_CONTROL,
                            offsetof(ompi_osc_portals4_node_state_t, complete_count),
                            NULL,
                            0,
                            PTL_SUM,
                            PTL_INT32_T);
            if (ret != OMPI_SUCCESS) return ret;
            OPAL_THREAD_ADD_FETCH64(&module->opcount, 1);
        }

        ret = ompi_osc_portals4_complete_all(module);
        if (ret != OMPI_SUCCESS) return ret;

        OBJ_RELEASE(module->start_group);
        module->start_group = NULL;
    }

    return OMPI_SUCCESS;
}


int
ompi_osc_portals4_post(struct ompi_group_t *group,
                       int mpi_assert,
                       struct ompi_win_t *win)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;
    int ret, i, size;

    if (0 == (mpi_assert & MPI_MODE_NOCHECK)) {
        OBJ_RETAIN(group);
        module->post_group = group;

        module->state.complete_count = 0;
        PtlAtomicSync();

        size = ompi_group_size(module->post_group);
        for (i = 0 ; i < size ; ++i) {
            ret = PtlAtomic(module->md_h,
                            (ptl_size_t) &module->one,
                            sizeof(module->one),
                            PTL_ACK_REQ,
                            ompi_osc_portals4_get_peer_group(module->post_group, i),
                            module->pt_idx,
                            module->match_bits | OSC_PORTALS4_MB_CONTROL,
                            offsetof(ompi_osc_portals4_node_state_t, post_count),
                            NULL,
                            0,
                            PTL_SUM,
                            PTL_INT32_T);
            if (ret != OMPI_SUCCESS) return ret;
            OPAL_THREAD_ADD_FETCH64(&module->opcount, 1);
        }
    } else {
        module->post_group = NULL;
    }

    return OMPI_SUCCESS;
}


int
ompi_osc_portals4_wait(struct ompi_win_t *win)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;

    if (NULL != module->post_group) {
        int size = ompi_group_size(module->post_group);

        while (module->state.complete_count != size) opal_progress();

        OBJ_RELEASE(module->post_group);
        module->post_group = NULL;
    }

    return OMPI_SUCCESS;
}


int
ompi_osc_portals4_test(struct ompi_win_t *win,
                       int *flag)
{
    ompi_osc_portals4_module_t *module =
        (ompi_osc_portals4_module_t*) win->w_osc_module;

    if (NULL != module->post_group) {
        int size = ompi_group_size(module->post_group);

        if (module->state.complete_count == size) {
            OBJ_RELEASE(module->post_group);
            module->post_group = NULL;
            *flag = 1;
        }
    } else {
        *flag = 0;
    }

    return OMPI_SUCCESS;
}