54b2cf747e
The commit has been tested for C/R and Cray operations, and on Odin (SLURM, rsh) and RoadRunner (TM). I tried to update all environments, but obviously could not test them. I know that Windows needs some work, and have highlighted what is know to be needed in the odls process component. This represents a lot of work by Brian, Tim P, Josh, and myself, with much advice from Jeff and others. For posterity, I have appended a copy of the email describing the work that was done: As we have repeatedly noted, the modex operation in MPI_Init is the single greatest consumer of time during startup. To-date, we have executed that operation as an ORTE stage gate that held the process until a startup message containing all required modex (and OOB contact info - see #3 below) info could be sent to it. Each process would send its data to the HNP's registry, which assembled and sent the message when all processes had reported in. In addition, ORTE had taken responsibility for monitoring process status as it progressed through a series of "stage gates". The process reported its status at each gate, and ORTE would then send a "release" message once all procs had reported in. The incoming changes revamp these procedures in three ways: 1. eliminating the ORTE stage gate system and cleanly delineating responsibility between the OMPI and ORTE layers for MPI init/finalize. The modex stage gate (STG1) has been replaced by a collective operation in the modex itself that performs an allgather on the required modex info. The allgather is implemented using the orte_grpcomm framework since the BTL's are not active at that point. At the moment, the grpcomm framework only has a "basic" component analogous to OMPI's "basic" coll framework - I would recommend that the MPI team create additional, more advanced components to improve performance of this step. The other stage gates have been replaced by orte_grpcomm barrier functions. We tried to use MPI barriers instead (since the BTL's are active at that point), but - as we discussed on the telecon - these are not currently true barriers so the job would hang when we fell through while messages were still in process. Note that the grpcomm barrier doesn't actually resolve that problem, but Brian has pointed out that we are unlikely to ever see it violated. Again, you might want to spend a little time on an advanced barrier algorithm as the one in "basic" is very simplistic. Summarizing this change: ORTE no longer tracks process state nor has direct responsibility for synchronizing jobs. This is now done via collective operations within the MPI layer, albeit using ORTE collective communication services. I -strongly- urge the MPI team to implement advanced collective algorithms to improve the performance of this critical procedure. 2. reducing the volume of data exchanged during modex. Data in the modex consisted of the process name, the name of the node where that process is located (expressed as a string), plus a string representation of all contact info. The nodename was required in order for the modex to determine if the process was local or not - in addition, some people like to have it to print pretty error messages when a connection failed. The size of this data has been reduced in three ways: (a) reducing the size of the process name itself. The process name consisted of two 32-bit fields for the jobid and vpid. This is far larger than any current system, or system likely to exist in the near future, can support. Accordingly, the default size of these fields has been reduced to 16-bits, which means you can have 32k procs in each of 32k jobs. Since the daemons must have a vpid, and we require one daemon/node, this also restricts the default configuration to 32k nodes. To support any future "mega-clusters", a configuration option --enable-jumbo-apps has been added. This option increases the jobid and vpid field sizes to 32-bits. Someday, if necessary, someone can add yet another option to increase them to 64-bits, I suppose. (b) replacing the string nodename with an integer nodeid. Since we have one daemon/node, the nodeid corresponds to the local daemon's vpid. This replaces an often lengthy string with only 2 (or at most 4) bytes, a substantial reduction. (c) when the mca param requesting that nodenames be sent to support pretty error messages, a second mca param is now used to request FQDN - otherwise, the domain name is stripped (by default) from the message to save space. If someone wants to combine those into a single param somehow (perhaps with an argument?), they are welcome to do so - I didn't want to alter what people are already using. While these may seem like small savings, they actually amount to a significant impact when aggregated across the entire modex operation. Since every proc must receive the modex data regardless of the collective used to send it, just reducing the size of the process name removes nearly 400MBytes of communication from a 32k proc job (admittedly, much of this comm may occur in parallel). So it does add up pretty quickly. 3. routing RML messages to reduce connections. The default messaging system remains point-to-point - i.e., each proc opens a socket to every proc it communicates with and sends its messages directly. A new option uses the orteds as routers - i.e., each proc only opens a single socket to its local orted. All messages are sent from the proc to the orted, which forwards the message to the orted on the node where the intended recipient proc is located - that orted then forwards the message to its local proc (the recipient). This greatly reduces the connection storm we have encountered during startup. It also has the benefit of removing the sharing of every proc's OOB contact with every other proc. The orted routing tables are populated during launch since every orted gets a map of where every proc is being placed. Each proc, therefore, only needs to know the contact info for its local daemon, which is passed in via the environment when the proc is fork/exec'd by the daemon. This alone removes ~50 bytes/process of communication that was in the current STG1 startup message - so for our 32k proc job, this saves us roughly 32k*50 = 1.6MBytes sent to 32k procs = 51GBytes of messaging. Note that you can use the new routing method by specifying -mca routed tree - if you so desire. This mode will become the default at some point in the future. There are a few minor additional changes in the commit that I'll just note in passing: * propagation of command line mca params to the orteds - fixes ticket #1073. See note there for details. * requiring of "finalize" prior to "exit" for MPI procs - fixes ticket #1144. See note there for details. * cleanup of some stale header files This commit was SVN r16364.
750 строки
22 KiB
C
750 строки
22 KiB
C
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
* University Research and Technology
|
|
* Corporation. All rights reserved.
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. All rights
|
|
* reserved.
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
* University of Stuttgart. All rights reserved.
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
* All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*
|
|
*/
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include <stdio.h>
|
|
#ifdef HAVE_PWD_H
|
|
#include <pwd.h>
|
|
#endif
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
#include <sys/param.h>
|
|
#endif /* HAVE_SYS_PARAM_H */
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
#include <sys/types.h>
|
|
#endif /* HAVE_SYS_TYPES_H */
|
|
#include <sys/stat.h>
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif /* HAVE_UNISTD_H */
|
|
#include <errno.h>
|
|
#ifdef HAVE_DIRENT_H
|
|
#include <dirent.h>
|
|
#endif /* HAVE_DIRENT_H */
|
|
|
|
#include "orte/orte_constants.h"
|
|
|
|
#include "orte/util/univ_info.h"
|
|
#include "orte/util/sys_info.h"
|
|
#include "orte/util/proc_info.h"
|
|
#include "opal/util/output.h"
|
|
#include "opal/util/os_path.h"
|
|
#include "opal/util/os_dirpath.h"
|
|
#include "opal/util/basename.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
#include "orte/runtime/runtime.h"
|
|
#include "orte/runtime/params.h"
|
|
|
|
#include "orte/util/session_dir.h"
|
|
|
|
/*******************************
|
|
* Local function Declarations
|
|
*******************************/
|
|
static int orte_create_dir(char *directory);
|
|
|
|
static bool orte_dir_check_file(const char *root, const char *path);
|
|
|
|
#ifdef __WINDOWS__
|
|
#define OMPI_DEFAULT_TMPDIR "C:\\TEMP"
|
|
#else
|
|
#define OMPI_DEFAULT_TMPDIR "/tmp"
|
|
#endif
|
|
|
|
#define OMPI_PRINTF_FIX_STRING(a) ((NULL == a) ? "(null)" : a)
|
|
|
|
/****************************
|
|
* Funcationality
|
|
****************************/
|
|
/*
|
|
* Check and create the directory requested
|
|
*/
|
|
static int orte_create_dir(char *directory)
|
|
{
|
|
mode_t my_mode = S_IRWXU; /* I'm looking for full rights */
|
|
int ret;
|
|
|
|
/* Sanity check before creating the directory with the proper mode,
|
|
* Make sure it doesn't exist already */
|
|
if( ORTE_ERR_NOT_FOUND != (ret = opal_os_dirpath_access(directory, my_mode)) ) {
|
|
/* Failure because opal_os_dirpath_access() indicated that either:
|
|
* - The directory exists and we can access it (no need to create it again),
|
|
* return OPAL_SUCCESS, or
|
|
* - don't have access rights, return OPAL_ERROR
|
|
*/
|
|
if (ORTE_SUCCESS != ret) {
|
|
ORTE_ERROR_LOG(ret);
|
|
}
|
|
return(ret);
|
|
}
|
|
|
|
/* Get here if the directory doesn't exist, so create it */
|
|
if (ORTE_SUCCESS != (ret = opal_os_dirpath_create(directory, my_mode))) {
|
|
ORTE_ERROR_LOG(ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Construct the fullpath to the session directory
|
|
*/
|
|
int
|
|
orte_session_dir_get_name(char **fulldirpath,
|
|
char **return_prefix, /* This will come back as the valid tmp dir */
|
|
char **return_frontend,
|
|
char *usr, char *hostid,
|
|
char *batchid, char *univ,
|
|
char *job, char *proc) {
|
|
char *hostname = NULL,
|
|
*batchname = NULL,
|
|
*sessions = NULL,
|
|
*user = NULL,
|
|
*universe = NULL,
|
|
*prefix = NULL,
|
|
*frontend = NULL;
|
|
bool prefix_provided = false;
|
|
int exit_status = ORTE_SUCCESS;
|
|
|
|
/* Ensure that system info is set */
|
|
orte_sys_info();
|
|
|
|
/*
|
|
* set the 'user' value
|
|
*/
|
|
if( NULL != usr) { /* User specified version */
|
|
user = strdup(usr);
|
|
}
|
|
else { /* check if it is set elsewhere */
|
|
if( NULL != orte_system_info.user)
|
|
user = strdup(orte_system_info.user);
|
|
else {
|
|
/* Couldn't find it, so fail */
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
exit_status = ORTE_ERR_BAD_PARAM;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* set the 'hostname'
|
|
*/
|
|
if( NULL != hostid) { /* User specified version */
|
|
hostname = strdup(hostid);
|
|
}
|
|
else { /* check if it is set elsewhere */
|
|
if( NULL != orte_system_info.nodename)
|
|
hostname = strdup(orte_system_info.nodename);
|
|
else {
|
|
/* Couldn't find it, so fail */
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
exit_status = ORTE_ERR_BAD_PARAM;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* set the 'batchid'
|
|
*/
|
|
if (NULL != batchid)
|
|
batchname = strdup(batchid);
|
|
else
|
|
batchname = strdup("0");
|
|
|
|
/*
|
|
* set the 'universe'
|
|
*/
|
|
if( NULL != univ) { /* User specified version */
|
|
universe = strdup(univ);
|
|
}
|
|
else { /* check if it is set elsewhere */
|
|
if( NULL != orte_universe_info.name) {
|
|
universe = strdup(orte_universe_info.name);
|
|
}
|
|
else {
|
|
;/* Couldn't find it, so continue with caution */
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Check: Can't give proc or job without universe
|
|
*/
|
|
if( NULL == universe &&
|
|
(NULL != proc ||
|
|
NULL != job) ) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
exit_status = ORTE_ERR_BAD_PARAM;
|
|
goto cleanup;
|
|
}
|
|
|
|
/*
|
|
* Check: Can't give a proc without a job and universe
|
|
*/
|
|
if( NULL == job &&
|
|
NULL != proc) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
exit_status = ORTE_ERR_BAD_PARAM;
|
|
goto cleanup;
|
|
}
|
|
|
|
/*
|
|
* get the front part of the session directory
|
|
* Will look something like:
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID
|
|
*/
|
|
if (NULL != orte_process_info.top_session_dir) {
|
|
frontend = strdup(orte_process_info.top_session_dir);
|
|
}
|
|
else { /* If not set then construct it */
|
|
if (0 > asprintf(&frontend, "openmpi-sessions-%s@%s_%s", user, hostname, batchname)) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Construct the session directory
|
|
*/
|
|
/* If we were given a 'proc' then we can construct it fully into:
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/UNIVERSE/JOBID/PROC
|
|
*/
|
|
if( NULL != proc) {
|
|
sessions = opal_os_path( false, frontend, universe, job, proc, NULL );
|
|
if( NULL == sessions ) {
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
exit_status = ORTE_ERROR;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
/* If we were given a 'job' then we can construct it partially into:
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/UNIVERSE/JOBID
|
|
*/
|
|
else if(NULL != job) {
|
|
sessions = opal_os_path( false, frontend, universe, job, NULL );
|
|
if( NULL == sessions ) {
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
exit_status = ORTE_ERROR;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
/* If we were given neither then we can construct it partially into:
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/UNIVERSE
|
|
*/
|
|
else if(NULL != universe) {
|
|
sessions = opal_os_path( false, frontend, universe, NULL );
|
|
if( NULL == sessions ) {
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
exit_status = ORTE_ERROR;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
/* If we were not given 'universe' then we can construct it into:
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID
|
|
*/
|
|
else {
|
|
if (0 > asprintf(&sessions, "%s",
|
|
frontend) ) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* If the user specified an invalid prefix, or no prefix at all
|
|
* we need to keep looking
|
|
*/
|
|
if( NULL != *fulldirpath) {
|
|
free(*fulldirpath);
|
|
*fulldirpath = NULL;
|
|
}
|
|
|
|
if( NULL != return_prefix && NULL != *return_prefix) { /* use the user specified one, if available */
|
|
prefix = strdup(*return_prefix);
|
|
prefix_provided = true;
|
|
}
|
|
/* Try to find a proper alternative prefix */
|
|
else if (NULL != orte_process_info.tmpdir_base) { /* stored value */
|
|
prefix = strdup(orte_process_info.tmpdir_base);
|
|
}
|
|
else if( NULL != getenv("OMPI_PREFIX_ENV") ) { /* OMPI Environment var */
|
|
prefix = strdup(getenv("OMPI_PREFIX_ENV"));
|
|
}
|
|
else if( NULL != getenv("TMPDIR") ) { /* General Environment var */
|
|
prefix = strdup(getenv("TMPDIR"));
|
|
}
|
|
else if( NULL != getenv("TMP") ) { /* Another general environment var */
|
|
prefix = strdup(getenv("TMP"));
|
|
}
|
|
else { /* ow. just use the default tmp directory */
|
|
prefix = strdup(OMPI_DEFAULT_TMPDIR);
|
|
}
|
|
|
|
/*
|
|
* Construct the absolute final path
|
|
*/
|
|
*fulldirpath = opal_os_path(false, prefix, sessions, NULL);
|
|
|
|
/*
|
|
* Return the frontend and prefix, if user requested we do so
|
|
*/
|
|
if (NULL != return_frontend) {
|
|
*return_frontend = strdup(frontend);
|
|
}
|
|
if (!prefix_provided && NULL != return_prefix) {
|
|
*return_prefix = strdup(prefix);
|
|
}
|
|
|
|
cleanup:
|
|
if(NULL != hostname)
|
|
free(hostname);
|
|
if(NULL != batchname)
|
|
free(batchname);
|
|
if(NULL != sessions)
|
|
free(sessions);
|
|
if(NULL != user)
|
|
free(user);
|
|
if(NULL != universe)
|
|
free(universe);
|
|
if (NULL != prefix) free(prefix);
|
|
if (NULL != frontend) free(frontend);
|
|
|
|
return exit_status;
|
|
}
|
|
|
|
/*
|
|
* Construct the session directory and create it if necessary
|
|
*/
|
|
int orte_session_dir(bool create,
|
|
char *prefix, char *usr, char *hostid,
|
|
char *batchid, char *univ, char *job, char *proc)
|
|
{
|
|
char *fulldirpath = NULL,
|
|
*frontend = NULL,
|
|
*sav = NULL;
|
|
int return_code = ORTE_SUCCESS, rtn;
|
|
/* This indicates if the prefix was set, and so if it fails then we
|
|
* should try with the default prefixes.*/
|
|
bool dbl_check_prefix = false;
|
|
|
|
if( NULL != prefix)
|
|
dbl_check_prefix = true;
|
|
|
|
try_again:
|
|
/*
|
|
* If the first attempt at the path creation failed, try with a null
|
|
* prefix. unless the original prefix was null, then we fail.
|
|
*/
|
|
if(!dbl_check_prefix && /* an indicator that we are trying a second time */
|
|
NULL != prefix) {
|
|
free(prefix);
|
|
prefix = NULL;
|
|
}
|
|
|
|
/*
|
|
* Get the session directory full name
|
|
* First try it with the specified prefix.
|
|
*/
|
|
if( ORTE_SUCCESS != ( rtn = orte_session_dir_get_name(&fulldirpath,
|
|
&prefix,
|
|
&frontend,
|
|
usr, hostid,
|
|
batchid, univ, job,
|
|
proc) ) ) {
|
|
return_code = rtn;
|
|
/*
|
|
* If the first attempt at the path creation failed, try with a null
|
|
* prefix. unless the original prefix was null, then we fail :(
|
|
*/
|
|
if(dbl_check_prefix) {
|
|
dbl_check_prefix = false;
|
|
goto try_again;
|
|
}
|
|
else {
|
|
ORTE_ERROR_LOG(return_code);
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Now that we have the full path, go ahead and create it if necessary
|
|
*/
|
|
if( create ) {
|
|
if( ORTE_SUCCESS != (rtn = orte_create_dir(fulldirpath) ) ) {
|
|
return_code = rtn;
|
|
|
|
if(dbl_check_prefix) {
|
|
dbl_check_prefix = false;
|
|
goto try_again;
|
|
}
|
|
else {
|
|
ORTE_ERROR_LOG(return_code);
|
|
goto cleanup;
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
* if we are not creating, then just verify that the path is OK
|
|
*/
|
|
else {
|
|
if( ORTE_SUCCESS != (rtn = opal_os_dirpath_access(fulldirpath, 0) )) {
|
|
/* It is not valid so we give up and return an error */
|
|
return_code = rtn;
|
|
|
|
if(dbl_check_prefix) {
|
|
dbl_check_prefix = false;
|
|
goto try_again;
|
|
}
|
|
else {
|
|
/* it is okay for the path not to be found - don't error
|
|
* log that case, but do error log others
|
|
*/
|
|
if (ORTE_ERR_NOT_FOUND != return_code) {
|
|
ORTE_ERROR_LOG(return_code);
|
|
}
|
|
goto cleanup;
|
|
}
|
|
}
|
|
}
|
|
|
|
return_code = ORTE_SUCCESS;
|
|
|
|
/*
|
|
* If we are creating the directory tree, the overwrite the
|
|
* global structure fields
|
|
*/
|
|
if (create) {
|
|
if (NULL != orte_process_info.tmpdir_base) {
|
|
free(orte_process_info.tmpdir_base);
|
|
orte_process_info.tmpdir_base = NULL;
|
|
}
|
|
if (NULL != orte_process_info.top_session_dir) {
|
|
free(orte_process_info.top_session_dir);
|
|
orte_process_info.top_session_dir = NULL;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Update some of the global structures if they are empty
|
|
*/
|
|
if (NULL == orte_process_info.tmpdir_base)
|
|
orte_process_info.tmpdir_base = strdup(prefix);
|
|
|
|
if (NULL == orte_process_info.top_session_dir)
|
|
orte_process_info.top_session_dir = strdup(frontend);
|
|
|
|
|
|
/*
|
|
* Set the process session directory
|
|
*/
|
|
if (NULL != proc) {
|
|
if (create) { /* overwrite if creating */
|
|
if (NULL != orte_process_info.proc_session_dir) {
|
|
free(orte_process_info.proc_session_dir);
|
|
orte_process_info.proc_session_dir = NULL;
|
|
}
|
|
}
|
|
if (NULL == orte_process_info.proc_session_dir) {
|
|
orte_process_info.proc_session_dir = strdup(fulldirpath);
|
|
}
|
|
|
|
/* Strip off last part of directory structure */
|
|
sav = opal_dirname(fulldirpath);
|
|
free(fulldirpath);
|
|
fulldirpath = sav;
|
|
sav = NULL;
|
|
}
|
|
|
|
/*
|
|
* Set the job session directory
|
|
*/
|
|
if (NULL != job) {
|
|
if (create) { /* overwrite if creating */
|
|
if (NULL != orte_process_info.job_session_dir) {
|
|
free(orte_process_info.job_session_dir);
|
|
orte_process_info.job_session_dir = NULL;
|
|
}
|
|
}
|
|
if (NULL == orte_process_info.job_session_dir) {
|
|
orte_process_info.job_session_dir = strdup(fulldirpath);
|
|
}
|
|
|
|
/* Strip off last part of directory structure */
|
|
sav = opal_dirname(fulldirpath);
|
|
free(fulldirpath);
|
|
fulldirpath = sav;
|
|
sav = NULL;
|
|
}
|
|
|
|
/*
|
|
* Set the universe session directory
|
|
*/
|
|
if (create) { /* overwrite if creating */
|
|
if (NULL != orte_process_info.universe_session_dir) {
|
|
free(orte_process_info.universe_session_dir);
|
|
orte_process_info.universe_session_dir = NULL;
|
|
}
|
|
}
|
|
if (NULL == orte_process_info.universe_session_dir) {
|
|
orte_process_info.universe_session_dir = strdup(fulldirpath);
|
|
}
|
|
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "procdir: %s",
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.proc_session_dir));
|
|
opal_output(0, "jobdir: %s",
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.job_session_dir));
|
|
opal_output(0, "unidir: %s",
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.universe_session_dir));
|
|
opal_output(0, "top: %s",
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.top_session_dir));
|
|
opal_output(0, "tmp: %s",
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));
|
|
}
|
|
|
|
cleanup:
|
|
if(NULL != fulldirpath)
|
|
free(fulldirpath);
|
|
if(NULL != frontend)
|
|
free(frontend);
|
|
if(NULL != sav)
|
|
free(sav);
|
|
|
|
return return_code;
|
|
}
|
|
|
|
/*
|
|
* A job has aborted - so force cleanup of the session directory
|
|
*/
|
|
int
|
|
orte_session_dir_cleanup(orte_jobid_t jobid)
|
|
{
|
|
int rc;
|
|
char *tmp;
|
|
char *job=NULL, *job_session_dir=NULL;
|
|
|
|
/* need to setup the top_session_dir with the prefix */
|
|
tmp = opal_os_path(false,
|
|
orte_process_info.tmpdir_base,
|
|
orte_process_info.top_session_dir, NULL);
|
|
|
|
if (ORTE_JOBID_WILDCARD != jobid) {
|
|
/* define the proc and job session directories for this process */
|
|
if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&job, jobid))) {
|
|
ORTE_ERROR_LOG(rc);
|
|
free(tmp);
|
|
return rc;
|
|
}
|
|
job_session_dir = opal_os_path( false, orte_process_info.universe_session_dir,
|
|
job, NULL );
|
|
if( NULL == job_session_dir ) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
free(tmp);
|
|
free(job);
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
}
|
|
|
|
opal_os_dirpath_destroy(job_session_dir,
|
|
true, orte_dir_check_file);
|
|
/* take out the universe session dir, but only if there
|
|
* are no remaining job session dirs around
|
|
*/
|
|
opal_os_dirpath_destroy(orte_process_info.universe_session_dir,
|
|
false, orte_dir_check_file);
|
|
} else {
|
|
/* if we want the session_dir removed for ALL jobids, then
|
|
* just recursively blow the whole universe session away
|
|
*/
|
|
opal_os_dirpath_destroy(orte_process_info.universe_session_dir,
|
|
true, orte_dir_check_file);
|
|
}
|
|
|
|
opal_os_dirpath_destroy(tmp,
|
|
false, orte_dir_check_file);
|
|
|
|
if (opal_os_dirpath_is_empty(job_session_dir)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
|
|
}
|
|
rmdir(job_session_dir);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
|
|
}
|
|
goto CLEANUP;
|
|
}
|
|
|
|
if (opal_os_dirpath_is_empty(orte_process_info.universe_session_dir)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found univ session dir empty - deleting");
|
|
}
|
|
rmdir(orte_process_info.universe_session_dir);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: univ session dir not empty - leaving");
|
|
}
|
|
goto CLEANUP;
|
|
}
|
|
|
|
if (opal_os_dirpath_is_empty(tmp)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
|
|
}
|
|
rmdir(tmp);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
|
|
}
|
|
}
|
|
|
|
CLEANUP:
|
|
free(tmp);
|
|
if (NULL != job) free(job);
|
|
if (NULL != job_session_dir) free(job_session_dir);
|
|
return ORTE_SUCCESS;
|
|
}
|
|
|
|
|
|
int
|
|
orte_session_dir_finalize(orte_process_name_t *proc)
|
|
{
|
|
int rc;
|
|
char *tmp;
|
|
char *job, *job_session_dir, *vpid, *proc_session_dir;
|
|
|
|
/* need to setup the top_session_dir with the prefix */
|
|
tmp = opal_os_path(false,
|
|
orte_process_info.tmpdir_base,
|
|
orte_process_info.top_session_dir, NULL);
|
|
|
|
/* define the proc and job session directories for this process */
|
|
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid_string(&job, proc))) {
|
|
ORTE_ERROR_LOG(rc);
|
|
free(tmp);
|
|
return rc;
|
|
}
|
|
if (ORTE_SUCCESS != (rc = orte_ns.get_vpid_string(&vpid, proc))) {
|
|
ORTE_ERROR_LOG(rc);
|
|
free(tmp);
|
|
free(job);
|
|
return rc;
|
|
}
|
|
job_session_dir = opal_os_path( false, orte_process_info.universe_session_dir,
|
|
job, NULL );
|
|
if( NULL == job_session_dir ) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
free(tmp);
|
|
free(job);
|
|
free(vpid);
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
}
|
|
proc_session_dir = opal_os_path( false, job_session_dir, vpid, NULL );
|
|
if( NULL == proc_session_dir ) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
free(tmp);
|
|
free(job);
|
|
free(vpid);
|
|
free(job_session_dir);
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
}
|
|
|
|
opal_os_dirpath_destroy(proc_session_dir,
|
|
false, orte_dir_check_file);
|
|
opal_os_dirpath_destroy(job_session_dir,
|
|
false, orte_dir_check_file);
|
|
opal_os_dirpath_destroy(orte_process_info.universe_session_dir,
|
|
false, orte_dir_check_file);
|
|
opal_os_dirpath_destroy(tmp,
|
|
false, orte_dir_check_file);
|
|
|
|
if (opal_os_dirpath_is_empty(proc_session_dir)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
|
|
}
|
|
rmdir(proc_session_dir);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
|
|
}
|
|
goto CLEANUP;
|
|
}
|
|
|
|
if (opal_os_dirpath_is_empty(job_session_dir)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
|
|
}
|
|
rmdir(job_session_dir);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
|
|
}
|
|
goto CLEANUP;
|
|
}
|
|
|
|
if (opal_os_dirpath_is_empty(orte_process_info.universe_session_dir)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found univ session dir empty - deleting");
|
|
}
|
|
rmdir(orte_process_info.universe_session_dir);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: univ session dir not empty - leaving");
|
|
}
|
|
goto CLEANUP;
|
|
}
|
|
|
|
if (opal_os_dirpath_is_empty(tmp)) {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
|
|
}
|
|
rmdir(tmp);
|
|
} else {
|
|
if (orte_debug_flag) {
|
|
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
|
|
}
|
|
}
|
|
|
|
CLEANUP:
|
|
free(tmp);
|
|
free(job);
|
|
free(vpid);
|
|
free(job_session_dir);
|
|
free(proc_session_dir);
|
|
return ORTE_SUCCESS;
|
|
}
|
|
|
|
static bool
|
|
orte_dir_check_file(const char *root, const char *path) {
|
|
|
|
/*
|
|
* Keep:
|
|
* - files starting with "output-"
|
|
* - universe contact (universe-setup.txt)
|
|
*/
|
|
if( (0 == strncmp(path, "output-", strlen("output-"))) ||
|
|
(0 == strcmp(path, "universe-setup.txt"))) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|