Skip to content

Commit 7ee20e3

Browse files
hjelmnawlauria
authored andcommitted
opal: Add an opal framework for exposing shared-memory single-copy support
This commit introduces opal/mca/smsc which exposes support for shared-memory single copy mechanisms. The target is to support Linux CMA, XPMEM, and KNEM. This component will initially support btl/sm but will also be used to provide single copy for other components (coll/sm, osc/rdma). Signed-off-by: Nathan Hjelm <hjelmn@google.com> (cherry picked from commit d371f80)
1 parent 62f2e6f commit 7ee20e3

File tree

7 files changed

+492
-4
lines changed

7 files changed

+492
-4
lines changed

opal/mca/smsc/Makefile.am

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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-2005 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 Cisco Systems, Inc. All rights reserved.
13+
# Copyright (c) 2021 Google, LLC. All rights reserved.
14+
# $COPYRIGHT$
15+
#
16+
# Additional copyrights may follow
17+
#
18+
# $HEADER$
19+
#
20+
21+
# main library setup
22+
noinst_LTLIBRARIES = libmca_smsc.la
23+
libmca_smsc_la_SOURCES =
24+
25+
# local files
26+
headers = smsc.h
27+
libmca_smsc_la_SOURCES += $(headers)
28+
29+
# Conditionally install the header files
30+
if WANT_INSTALL_HEADERS
31+
opaldir = $(opalincludedir)/$(subdir)
32+
nobase_opal_HEADERS = $(headers)
33+
endif
34+
35+
include base/Makefile.am
36+
37+
distclean-local:
38+
rm -f base/static-components.h

opal/mca/smsc/base/Makefile.am

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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-2005 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) 2021 Google, LLC. All rights reserved.
13+
# $COPYRIGHT$
14+
#
15+
# Additional copyrights may follow
16+
#
17+
# $HEADER$
18+
#
19+
20+
AM_CPPFLAGS = ${smsc_@DIRECT_smsc@_CPPFLAGS}
21+
22+
headers += \
23+
base/base.h
24+
25+
libmca_smsc_la_SOURCES += \
26+
base/smsc_base_frame.c

opal/mca/smsc/base/base.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2021 Google, LLC. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
11+
#ifndef OPAL_MCA_SMSC_BASE_BASE_H
12+
#define OPAL_MCA_SMSC_BASE_BASE_H
13+
14+
#include "opal/mca/smsc/smsc.h"
15+
16+
extern mca_base_framework_t opal_smsc_base_framework;
17+
extern mca_smsc_component_t *selected_component;
18+
extern mca_smsc_module_t *selected_module;
19+
20+
int mca_smsc_base_select(void);
21+
void mca_smsc_base_register_default_params(mca_smsc_component_t *component, int default_priority);
22+
23+
#endif /* OPAL_MCA_SMSC_BASE_BASE_H */

opal/mca/smsc/base/smsc_base_frame.c

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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-2005 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) 2021 Google, LLC. All rights reserved.
13+
* $COPYRIGHT$
14+
*
15+
* Additional copyrights may follow
16+
*
17+
* $HEADER$
18+
*/
19+
20+
#include "opal_config.h"
21+
#include <stdio.h>
22+
#include <string.h>
23+
24+
#include "opal/class/opal_list.h"
25+
#include "opal/mca/base/base.h"
26+
#include "opal/mca/mca.h"
27+
#include "opal/mca/smsc/base/base.h"
28+
#include "opal/mca/smsc/smsc.h"
29+
#include "opal/util/printf.h"
30+
31+
/*
32+
* The following file was created by configure. It contains extern
33+
* statements and the definition of an array of pointers to each
34+
* component's public mca_base_component_t struct.
35+
*/
36+
#include "opal/mca/smsc/base/static-components.h"
37+
38+
mca_smsc_component_t *selected_component = NULL;
39+
mca_smsc_module_t *mca_smsc = NULL;
40+
41+
/*
42+
* Global variables
43+
*/
44+
MCA_BASE_FRAMEWORK_DECLARE(opal, smsc, NULL, NULL, NULL, NULL, mca_smsc_base_static_components, 0);
45+
46+
static int mca_smsc_compare_components(opal_list_item_t **a, opal_list_item_t **b)
47+
{
48+
mca_smsc_component_t *componenta
49+
= (mca_smsc_component_t *) ((mca_base_component_list_item_t *) *a)->cli_component;
50+
mca_smsc_component_t *componentb
51+
= (mca_smsc_component_t *) ((mca_base_component_list_item_t *) *b)->cli_component;
52+
53+
return (componenta->priority > componentb->priority)
54+
? -1
55+
: ((componenta->priority < componentb->priority) ? 1 : 0);
56+
}
57+
58+
int mca_smsc_base_select(void)
59+
{
60+
mca_base_component_list_item_t *cli, *next;
61+
62+
OPAL_LIST_FOREACH_SAFE (cli, next, &opal_smsc_base_framework.framework_components,
63+
mca_base_component_list_item_t) {
64+
mca_smsc_component_t *component = (mca_smsc_component_t *) cli->cli_component;
65+
66+
opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, opal_smsc_base_framework.framework_output,
67+
"mca_smsc_base_select: checking component %s",
68+
component->smsc_version.mca_component_name);
69+
70+
int ret = component->query();
71+
if (OPAL_SUCCESS != ret) {
72+
opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT,
73+
opal_smsc_base_framework.framework_output,
74+
"mca_smsc_base_select: could not select component %s. query "
75+
"returned error code %d",
76+
component->smsc_version.mca_component_name, ret);
77+
opal_list_remove_item(&opal_smsc_base_framework.framework_components, &cli->super);
78+
OBJ_RELEASE(cli);
79+
mca_base_component_close(&component->smsc_version,
80+
opal_smsc_base_framework.framework_output);
81+
continue;
82+
}
83+
opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, opal_smsc_base_framework.framework_output,
84+
"mca_smsc_base_select: component %s priority=%d",
85+
component->smsc_version.mca_component_name, component->priority);
86+
}
87+
88+
opal_list_sort(&opal_smsc_base_framework.framework_components, mca_smsc_compare_components);
89+
90+
if (opal_list_get_size(&opal_smsc_base_framework.framework_components) > 0) {
91+
cli = (mca_base_component_list_item_t *) opal_list_get_first(
92+
&opal_smsc_base_framework.framework_components);
93+
94+
selected_component = (mca_smsc_component_t *) cli->cli_component;
95+
mca_smsc = selected_component->enable();
96+
97+
opal_output_verbose(
98+
MCA_BASE_VERBOSE_COMPONENT, opal_smsc_base_framework.framework_output,
99+
"mca_smsc_base_select: selected shared-memory single-copy component: %s",
100+
selected_component->smsc_version.mca_component_name);
101+
} else {
102+
opal_output_verbose(
103+
MCA_BASE_VERBOSE_COMPONENT, opal_smsc_base_framework.framework_output,
104+
"mca_smsc_base_select: no shared-memory single-copy component available for selection");
105+
}
106+
107+
return OPAL_SUCCESS;
108+
}
109+
110+
void mca_smsc_base_register_default_params(mca_smsc_component_t *component, int default_priority)
111+
{
112+
113+
char *tmp;
114+
(void) opal_asprintf(&tmp, "Priority of the %s component (default: %d)",
115+
component->smsc_version.mca_component_name, default_priority);
116+
component->priority = default_priority;
117+
(void) mca_base_component_var_register(&component->smsc_version, "priority", /*help_msg=*/tmp,
118+
MCA_BASE_VAR_TYPE_INT, /*enumerator=*/NULL, /*bind=*/0,
119+
MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3,
120+
MCA_BASE_VAR_SCOPE_ALL_EQ, &component->priority);
121+
free(tmp);
122+
}

opal/mca/smsc/configure.m4

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2013 Sandia National Laboratories. All rights reserved.
4+
# Copyright (c) 2021 Google, LLC. All rights reserved.
5+
#
6+
# $COPYRIGHT$
7+
#
8+
# Additional copyrights may follow
9+
#
10+
# $HEADER$
11+
#
12+
13+
AC_DEFUN([MCA_opal_smsc_CONFIG],[
14+
# configure all the components
15+
MCA_CONFIGURE_FRAMEWORK($1, $2, 1)
16+
17+
# this is a direct callable component, so set that up.
18+
MCA_SETUP_DIRECT_CALL($1, $2)
19+
])

0 commit comments

Comments
 (0)