From 626d03745ddd798af01106e7775eb9a17be97ae7 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Sat, 4 Dec 2004 19:49:35 +0000 Subject: [PATCH] * add BProc pcmclient code so that processes know who they are when started under BProc. Of course, we can't start processes under BProc just yet, but that's coming real soon now. This commit was SVN r3695. --- src/mca/pcmclient/bproc/Makefile.am | 47 +++++ src/mca/pcmclient/bproc/VERSION | 6 + src/mca/pcmclient/bproc/configure.params | 19 ++ src/mca/pcmclient/bproc/pcmclient_bproc.c | 60 ++++++ src/mca/pcmclient/bproc/pcmclient_bproc.h | 40 ++++ .../bproc/pcmclient_bproc_component.c | 183 ++++++++++++++++++ 6 files changed, 355 insertions(+) create mode 100644 src/mca/pcmclient/bproc/Makefile.am create mode 100644 src/mca/pcmclient/bproc/VERSION create mode 100644 src/mca/pcmclient/bproc/configure.params create mode 100644 src/mca/pcmclient/bproc/pcmclient_bproc.c create mode 100644 src/mca/pcmclient/bproc/pcmclient_bproc.h create mode 100644 src/mca/pcmclient/bproc/pcmclient_bproc_component.c diff --git a/src/mca/pcmclient/bproc/Makefile.am b/src/mca/pcmclient/bproc/Makefile.am new file mode 100644 index 0000000000..3017dd8914 --- /dev/null +++ b/src/mca/pcmclient/bproc/Makefile.am @@ -0,0 +1,47 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2004-2005 The Trustees of the University of Tennessee. +# All rights reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# Use the top-level Makefile.options + +include $(top_ompi_srcdir)/config/Makefile.options + +EXTRA_DIST = VERSION + +sources = \ + pcmclient_bproc.h \ + pcmclient_bproc.c \ + pcmclient_bproc_component.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if OMPI_BUILD_pcmclient_bproc_DSO +component_noinst = +component_install = mca_pcmclient_bproc.la +else +component_noinst = libmca_pcmclient_bproc.la +component_install = +endif + +mcacomponentdir = $(libdir)/openmpi +mcacomponent_LTLIBRARIES = $(component_install) +mca_pcmclient_bproc_la_SOURCES = $(sources) +mca_pcmclient_bproc_la_LIBADD = +mca_pcmclient_bproc_la_LDFLAGS = -module -avoid-version + +noinst_LTLIBRARIES = $(component_noinst) +libmca_pcmclient_bproc_la_SOURCES = $(sources) +libmca_pcmclient_bproc_la_LIBADD = +libmca_pcmclient_bproc_la_LDFLAGS = -module -avoid-version diff --git a/src/mca/pcmclient/bproc/VERSION b/src/mca/pcmclient/bproc/VERSION new file mode 100644 index 0000000000..dadc1f42ab --- /dev/null +++ b/src/mca/pcmclient/bproc/VERSION @@ -0,0 +1,6 @@ +major=1 +minor=0 +release=0 +alpha=0 +beta=0 +svn=1 diff --git a/src/mca/pcmclient/bproc/configure.params b/src/mca/pcmclient/bproc/configure.params new file mode 100644 index 0000000000..a16fce8c0b --- /dev/null +++ b/src/mca/pcmclient/bproc/configure.params @@ -0,0 +1,19 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2004-2005 The Trustees of the University of Tennessee. +# All rights reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# Specific to this module + +PARAM_INIT_FILE=pcmclient_bproc_component.c +PARAM_CONFIG_FILES="Makefile" diff --git a/src/mca/pcmclient/bproc/pcmclient_bproc.c b/src/mca/pcmclient/bproc/pcmclient_bproc.c new file mode 100644 index 0000000000..fe794ecdaa --- /dev/null +++ b/src/mca/pcmclient/bproc/pcmclient_bproc.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "mca/pcmclient/pcmclient.h" +#include "mca/pcmclient/bproc/pcmclient_bproc.h" +#include "include/types.h" +#include "include/constants.h" + +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +extern int mca_pcmclient_bproc_num_procs; +extern int mca_pcmclient_bproc_proc_index; +extern ompi_process_name_t *mca_pcmclient_bproc_procs; + +int +mca_pcmclient_bproc_init_cleanup(void) +{ + return OMPI_SUCCESS; +} + + +int +mca_pcmclient_bproc_get_peers(ompi_process_name_t **procs, + size_t *num_procs) +{ + if (NULL == mca_pcmclient_bproc_procs) return OMPI_ERROR; + + *num_procs = mca_pcmclient_bproc_num_procs; + *procs = mca_pcmclient_bproc_procs; + return OMPI_SUCCESS; +} + + +ompi_process_name_t* +mca_pcmclient_bproc_get_self(void) +{ + if (NULL == mca_pcmclient_bproc_procs) return NULL; + + return &mca_pcmclient_bproc_procs[mca_pcmclient_bproc_proc_index]; +} diff --git a/src/mca/pcmclient/bproc/pcmclient_bproc.h b/src/mca/pcmclient/bproc/pcmclient_bproc.h new file mode 100644 index 0000000000..ed50449019 --- /dev/null +++ b/src/mca/pcmclient/bproc/pcmclient_bproc.h @@ -0,0 +1,40 @@ +/* -*- C -*- + * + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ +#include "ompi_config.h" + +#include "mca/pcmclient/pcmclient.h" +#include "include/types.h" + +/* + * Module open / close + */ +int mca_pcmclient_bproc_open(void); +int mca_pcmclient_bproc_close(void); + +/* + * Startup / Shutdown + */ +struct mca_pcmclient_base_module_1_0_0_t* mca_pcmclient_bproc_init(int *priority, bool *allow_multi_user_threads, bool *have_hidden_threads); +int mca_pcmclient_bproc_finalize(void); + + +/* + * "Action" functions + */ +int mca_pcmclient_bproc_init_cleanup(void); +int mca_pcmclient_bproc_get_peers(ompi_process_name_t **peers, size_t *npeers); +ompi_process_name_t* mca_pcmclient_bproc_get_self(void); + diff --git a/src/mca/pcmclient/bproc/pcmclient_bproc_component.c b/src/mca/pcmclient/bproc/pcmclient_bproc_component.c new file mode 100644 index 0000000000..242ad7c1c0 --- /dev/null +++ b/src/mca/pcmclient/bproc/pcmclient_bproc_component.c @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "pcmclient-bproc-version.h" + +#include "include/constants.h" +#include "include/types.h" +#include "mca/mca.h" +#include "mca/pcmclient/pcmclient.h" +#include "mca/pcmclient/bproc/pcmclient_bproc.h" +#include "mca/ns/ns.h" +#include "mca/ns/base/base.h" +#include "mca/base/mca_base_param.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* + * Struct of function pointers and all that to let us be initialized + */ +mca_pcmclient_base_component_1_0_0_t mca_pcmclient_bproc_component = { + { + MCA_PCMCLIENT_BASE_VERSION_1_0_0, + + "bproc", /* MCA component name */ + MCA_pcmclient_bproc_MAJOR_VERSION, /* MCA component major version */ + MCA_pcmclient_bproc_MINOR_VERSION, /* MCA component minor version */ + MCA_pcmclient_bproc_RELEASE_VERSION, /* MCA component release version */ + mca_pcmclient_bproc_open, /* component open */ + mca_pcmclient_bproc_close /* component close */ + }, + { + false /* checkpoint / restart */ + }, + mca_pcmclient_bproc_init, /* component init */ + mca_pcmclient_bproc_finalize +}; + + +struct mca_pcmclient_base_module_1_0_0_t mca_pcmclient_bproc_1_0_0 = { + mca_pcmclient_bproc_init_cleanup, + mca_pcmclient_bproc_get_self, + mca_pcmclient_bproc_get_peers, +}; + + +/* + * component-global variables + */ +int mca_pcmclient_bproc_num_procs; +int mca_pcmclient_bproc_proc_index; +ompi_process_name_t *mca_pcmclient_bproc_procs = NULL; + + +/* + * local variables + */ + +static int param_base_proc_name; +static int param_num_procs; +static int param_proc_index; + +int +mca_pcmclient_bproc_open(void) +{ + param_base_proc_name = + mca_base_param_register_string("pcmclient", "bproc", + "base_name", NULL, NULL); + param_num_procs = + mca_base_param_register_int("pcmclient", "bproc", "num_procs", + NULL, -1); + param_proc_index = + mca_base_param_register_int("pcmclient", "bproc", + "proc_index", NULL, -1); + + + return OMPI_SUCCESS; +} + + +int +mca_pcmclient_bproc_close(void) +{ + return OMPI_SUCCESS; +} + + +struct mca_pcmclient_base_module_1_0_0_t * +mca_pcmclient_bproc_init(int *priority, + bool *allow_multiple_user_threads, + bool *have_hidden_threads) +{ + int i; + char *tmp; + ompi_process_name_t *base_name; + + *priority = 5; /* make sure we are above env / singleton */ + *allow_multiple_user_threads = true; + *have_hidden_threads = false; + + /* get our bproc rank first - no point in doing anything else if + * we aren't running under bproc. + * + * Not all versions of bproc support the BPROC_RANK feature of + * vexecmove. In these cases, we don't do vexecmoves, but + * instead do a linear startup setting the MCA param. Need to + * look both places. + */ + tmp = getenv("BPROC_RANK"); + if (NULL != tmp) { + mca_pcmclient_bproc_proc_index = atoi(tmp); + } else { + mca_base_param_lookup_int(param_proc_index, + &mca_pcmclient_bproc_proc_index); + } + if (mca_pcmclient_bproc_proc_index < 0) return NULL; + + /* get our number of procs */ + mca_base_param_lookup_int(param_num_procs, + &mca_pcmclient_bproc_num_procs); + if (mca_pcmclient_bproc_num_procs < 0) return NULL; + + /* get the base process name string */ + mca_base_param_lookup_string(param_base_proc_name, &tmp); + if (tmp == NULL) return NULL; + + base_name = + ompi_name_server.convert_string_to_process_name(tmp); + if (base_name == NULL) return NULL; + + /* create the list of names */ + mca_pcmclient_bproc_procs = + (ompi_process_name_t*) malloc(sizeof(ompi_process_name_t) * + mca_pcmclient_bproc_num_procs); + if (NULL == mca_pcmclient_bproc_procs) return NULL; + + for ( i = 0 ; i < mca_pcmclient_bproc_num_procs ; ++i) { + /* BWB - this needs to suck less - possibly by changing the + return type of get_peer_names */ + ompi_process_name_t *tmp_name; + + tmp_name = ompi_name_server.copy_process_name(base_name); + /* BWB - this will eventually be a function in the NS */ + tmp_name->vpid = ompi_name_server.get_vpid(base_name) + i; + mca_pcmclient_bproc_procs[i] = *tmp_name; + ompi_name_server.free_name(tmp_name); + } + + return &mca_pcmclient_bproc_1_0_0; +} + + +int +mca_pcmclient_bproc_finalize(void) +{ + if (NULL != mca_pcmclient_bproc_procs) { + free(mca_pcmclient_bproc_procs); + mca_pcmclient_bproc_procs = NULL; + } + mca_pcmclient_bproc_num_procs = 0; + mca_pcmclient_bproc_proc_index = -1; + + return OMPI_SUCCESS; +} + +