Skip to content

Commit 119b1c3

Browse files
authored
Merge pull request #7170 from jjhursey/jsm-schizo
Add detection for JSM direct launch
2 parents 9e17f02 + 4f1de51 commit 119b1c3

File tree

6 files changed

+261
-0
lines changed

6 files changed

+261
-0
lines changed

orte/mca/schizo/jsm/Makefile.am

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Copyright (c) 2016 Intel, Inc. All rights reserved.
3+
# Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
4+
# $COPYRIGHT$
5+
#
6+
# Additional copyrights may follow
7+
#
8+
# $HEADER$
9+
#
10+
11+
sources = \
12+
schizo_jsm_component.c \
13+
schizo_jsm.h \
14+
schizo_jsm.c
15+
16+
# Make the output library in this directory, and name it either
17+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
18+
# (for static builds).
19+
20+
if MCA_BUILD_orte_schizo_jsm_DSO
21+
component_noinst =
22+
component_install = mca_schizo_jsm.la
23+
else
24+
component_noinst = libmca_schizo_jsm.la
25+
component_install =
26+
endif
27+
28+
mcacomponentdir = $(ortelibdir)
29+
mcacomponent_LTLIBRARIES = $(component_install)
30+
mca_schizo_jsm_la_SOURCES = $(sources)
31+
mca_schizo_jsm_la_LDFLAGS = -module -avoid-version
32+
mca_schizo_jsm_la_LIBADD = $(top_builddir)/orte/lib@[email protected]
33+
34+
noinst_LTLIBRARIES = $(component_noinst)
35+
libmca_schizo_jsm_la_SOURCES = $(sources)
36+
libmca_schizo_jsm_la_LDFLAGS = -module -avoid-version
37+

orte/mca/schizo/jsm/configure.m4

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4+
# University Research and Technology
5+
# Corporation. All rights reserved.
6+
# Copyright (c) 2004-2005 The University of Tennessee and The University
7+
# of Tennessee Research Foundation. All rights
8+
# reserved.
9+
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10+
# University of Stuttgart. All rights reserved.
11+
# Copyright (c) 2004-2005 The Regents of the University of California.
12+
# All rights reserved.
13+
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2011-2013 Los Alamos National Security, LLC.
15+
# All rights reserved.
16+
# Copyright (c) 2016 Intel, Inc. All rights reserved
17+
# Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
18+
# $COPYRIGHT$
19+
#
20+
# Additional copyrights may follow
21+
#
22+
# $HEADER$
23+
#
24+
25+
# MCA_schizo_jsm_CONFIG([action-if-found], [action-if-not-found])
26+
# -----------------------------------------------------------
27+
AC_DEFUN([MCA_orte_schizo_jsm_CONFIG],[
28+
AC_CONFIG_FILES([orte/mca/schizo/jsm/Makefile])
29+
30+
# Nothing to do for now.
31+
])dnl

orte/mca/schizo/jsm/owner.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# owner/status file
3+
# owner: institution that is responsible for this package
4+
# status: e.g. active, maintenance, unmaintained
5+
#
6+
owner: IBM
7+
status: active

orte/mca/schizo/jsm/schizo_jsm.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4+
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*
11+
*/
12+
13+
#include "orte_config.h"
14+
#include "orte/types.h"
15+
#include "opal/types.h"
16+
17+
#ifdef HAVE_UNISTD_H
18+
#include <unistd.h>
19+
#endif
20+
#include <ctype.h>
21+
22+
#include "opal/util/argv.h"
23+
#include "opal/util/basename.h"
24+
#include "opal/util/opal_environ.h"
25+
26+
#include "orte/runtime/orte_globals.h"
27+
#include "orte/util/name_fns.h"
28+
#include "orte/mca/schizo/base/base.h"
29+
30+
#include "schizo_jsm.h"
31+
32+
static orte_schizo_launch_environ_t check_launch_environment(void);
33+
static void finalize(void);
34+
35+
orte_schizo_base_module_t orte_schizo_jsm_module = {
36+
.check_launch_environment = check_launch_environment,
37+
.finalize = finalize
38+
};
39+
40+
static char **pushed_envs = NULL;
41+
static char **pushed_vals = NULL;
42+
static orte_schizo_launch_environ_t myenv;
43+
static bool myenvdefined = false;
44+
45+
static orte_schizo_launch_environ_t check_launch_environment(void)
46+
{
47+
int i;
48+
49+
if (myenvdefined) {
50+
return myenv;
51+
}
52+
myenvdefined = true;
53+
54+
/* we were only selected because JSM was detected
55+
* and we are an app, so no need to further check
56+
* that here. Instead, see if we were direct launched
57+
* vs launched via mpirun ('native') */
58+
if (NULL != orte_process_info.my_daemon_uri) {
59+
/* Use PMI(x) for daemon interactions */
60+
myenv = ORTE_SCHIZO_NATIVE_LAUNCHED;
61+
opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
62+
opal_argv_append_nosize(&pushed_vals, "pmi");
63+
/* mark that we are native */
64+
opal_argv_append_nosize(&pushed_envs, "ORTE_SCHIZO_DETECTION");
65+
opal_argv_append_nosize(&pushed_vals, "NATIVE");
66+
}
67+
else {
68+
/* Use PMI(x) for daemon interactions */
69+
myenv = ORTE_SCHIZO_DIRECT_LAUNCHED;
70+
opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
71+
opal_argv_append_nosize(&pushed_vals, "pmi");
72+
/* mark that we are JSM */
73+
opal_argv_append_nosize(&pushed_envs, "ORTE_SCHIZO_DETECTION");
74+
opal_argv_append_nosize(&pushed_vals, "JSM");
75+
}
76+
77+
/* We don't support singleton launch by JSM.
78+
* If we did then the logic should be placed here.
79+
*/
80+
81+
opal_output_verbose(1, orte_schizo_base_framework.framework_output,
82+
"schizo:jsm DECLARED AS %s", orte_schizo_base_print_env(myenv));
83+
if (NULL != pushed_envs) {
84+
for (i=0; NULL != pushed_envs[i]; i++) {
85+
opal_setenv(pushed_envs[i], pushed_vals[i], true, &environ);
86+
}
87+
}
88+
89+
return myenv;
90+
}
91+
92+
93+
static void finalize(void)
94+
{
95+
int i;
96+
97+
if (NULL != pushed_envs) {
98+
for (i=0; NULL != pushed_envs[i]; i++) {
99+
opal_unsetenv(pushed_envs[i], &environ);
100+
}
101+
opal_argv_free(pushed_envs);
102+
opal_argv_free(pushed_vals);
103+
}
104+
}

orte/mca/schizo/jsm/schizo_jsm.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2016 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
11+
#ifndef _MCA_SCHIZO_JSM_H_
12+
#define _MCA_SCHIZO_JSM_H_
13+
14+
#include "orte_config.h"
15+
16+
#include "orte/types.h"
17+
18+
#include "opal/mca/base/base.h"
19+
#include "orte/mca/schizo/schizo.h"
20+
21+
22+
BEGIN_C_DECLS
23+
24+
ORTE_MODULE_DECLSPEC extern orte_schizo_base_component_t mca_schizo_jsm_component;
25+
extern orte_schizo_base_module_t orte_schizo_jsm_module;
26+
27+
END_C_DECLS
28+
29+
#endif /* MCA_SCHIZO_JSM_H_ */
30+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
4+
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
12+
#include "orte_config.h"
13+
#include "orte/types.h"
14+
#include "opal/types.h"
15+
16+
#include "opal/util/show_help.h"
17+
18+
#include "orte/mca/schizo/schizo.h"
19+
#include "schizo_jsm.h"
20+
21+
static int component_query(mca_base_module_t **module, int *priority);
22+
23+
/*
24+
* Struct of function pointers and all that to let us be initialized
25+
*/
26+
orte_schizo_base_component_t mca_schizo_jsm_component = {
27+
.base_version = {
28+
MCA_SCHIZO_BASE_VERSION_1_0_0,
29+
.mca_component_name = "jsm",
30+
MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
31+
ORTE_RELEASE_VERSION),
32+
.mca_query_component = component_query,
33+
},
34+
.base_data = {
35+
/* The component is checkpoint ready */
36+
MCA_BASE_METADATA_PARAM_CHECKPOINT
37+
},
38+
};
39+
40+
static int component_query(mca_base_module_t **module, int *priority)
41+
{
42+
/* disqualify ourselves if we are not under jsm */
43+
if (NULL == getenv("JSM_JSRUN_PORT")) {
44+
*priority = 0;
45+
*module = NULL;
46+
return OPAL_ERROR;
47+
}
48+
49+
*module = (mca_base_module_t*)&orte_schizo_jsm_module;
50+
*priority = 80;
51+
return ORTE_SUCCESS;
52+
}

0 commit comments

Comments
 (0)