File: scoll_base_frame.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: 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 (131 lines) | stat: -rw-r--r-- 3,519 bytes parent folder | download | duplicates (4)
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
/*
 * Copyright (c) 2013-2018 Mellanox Technologies, Inc.
 *                         All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include <stdio.h>

#include "oshmem_config.h"

#include "oshmem/constants.h"

#include "oshmem/mca/mca.h"
#include "opal/util/output.h"
#include "opal/mca/base/base.h"
#include "ompi/util/timings.h"

#include "oshmem/util/oshmem_util.h"
#include "oshmem/mca/scoll/scoll.h"
#include "oshmem/mca/scoll/base/base.h"

/*
 * The following file was created by configure.  It contains extern
 * statements and the definition of an array of pointers to each
 * component's public mca_base_component_t struct.
 */

#include "oshmem/mca/scoll/base/static-components.h"

/*
 * Global variables; most of which are loaded by back-ends of MCA
 * variables
 */
long* mca_scoll_sync_array = NULL;

/*
 * Ensure all function pointers are NULL'ed out to start with
 */
static void scoll_base_module_construct(mca_scoll_base_module_t *m)
{
    /* Collective function pointers */
    m->scoll_barrier = NULL;
    m->scoll_broadcast = NULL;
    m->scoll_collect = NULL;
    m->scoll_reduce = NULL;
    m->scoll_alltoall = NULL;
    m->scoll_module_enable = NULL;
}

OBJ_CLASS_INSTANCE(mca_scoll_base_module_t, opal_object_t,
                   scoll_base_module_construct, NULL);

int mca_scoll_enable(void)
{
    int ret = OSHMEM_SUCCESS;

    OPAL_TIMING_ENV_INIT(mca_scoll_enable);

    if (!mca_scoll_sync_array) {
        void* ptr = (void*) mca_scoll_sync_array;
        int i = 0;

        MCA_MEMHEAP_CALL(private_alloc((_SHMEM_BARRIER_SYNC_SIZE * sizeof(*mca_scoll_sync_array)), &ptr));
        mca_scoll_sync_array = ptr;

        for (i = 0; i < _SHMEM_BARRIER_SYNC_SIZE; i++) {
            mca_scoll_sync_array[i] = _SHMEM_SYNC_VALUE;
        }
    }

    OPAL_TIMING_ENV_NEXT(mca_scoll_enable, "memheap");

    /* Note: it is done to support FCA only and we need to consider possibility to
     * find a way w/o this ugly hack
     */
    if (OSHMEM_SUCCESS != (ret = mca_scoll_base_select(oshmem_group_all))) {
        return ret;
    }

    OPAL_TIMING_ENV_NEXT(mca_scoll_enable, "group_all");

    if (OSHMEM_SUCCESS != (ret = mca_scoll_base_select(oshmem_group_self))) {
        return ret;
    }

    OPAL_TIMING_ENV_NEXT(mca_scoll_enable, "group_self");

    return OSHMEM_SUCCESS;
}

static int mca_scoll_base_register(mca_base_register_flag_t flags)
{
    return OSHMEM_SUCCESS;
}

static int mca_scoll_base_close(void)
{
    /* This call should be done before memheap close */
    if (mca_scoll_sync_array) {
        void* ptr = (void*) mca_scoll_sync_array;

        MCA_MEMHEAP_CALL(private_free(ptr));
        mca_scoll_sync_array = NULL;
    }

    return mca_base_framework_components_close(&oshmem_scoll_base_framework, NULL);
}

static int mca_scoll_base_open(mca_base_open_flag_t flags)
{
    oshmem_framework_open_output(&oshmem_scoll_base_framework);

    /* Open up all available components */
    if (OPAL_SUCCESS !=
            mca_base_framework_components_open(&oshmem_scoll_base_framework, flags)) {
        return OSHMEM_ERROR;
    }
    return OSHMEM_SUCCESS;
}

MCA_BASE_FRAMEWORK_DECLARE(oshmem, scoll,
                           "OSHMEM SCOLL",
                           mca_scoll_base_register,
                           mca_scoll_base_open,
                           mca_scoll_base_close,
                           mca_scoll_base_static_components,
                           MCA_BASE_FRAMEWORK_FLAG_DEFAULT);