
The opal_gethostname() function provides a more robust mechanism to retrieve the hostname than gethostname(), which can return results that are not null-terminated, and which can vary in its behavior from system to system. opal_gethostname() just returns the value in opal_process_info.nodename; this is populated in opal_init_gethostname() inside opal_init.c. -Changed all gethostname calls in opal subtree to opal_gethostname -Changed all gethostname calls in orte subtree to opal_gethostname -Changed all gethostname calls in ompi subdir to opal_gethostname -Changed all gethostname calls in oshmem subdir to opal_gethostname -Changed opal_if.c in test subdir to use opal_gethostname -Changed opal_init.c to include opal_init_gethostname. This function returns an int and directly sets opal_process_info.nodename per jsquyres' modifications. Relates to open-mpi#6801 Signed-off-by: Charles Shereda <cpshereda@lanl.gov>
61 строка
1.3 KiB
C
61 строка
1.3 KiB
C
/* -*- C -*-
|
|
*
|
|
* $HEADER$
|
|
*
|
|
* A program that just spins, with vpid 3 aborting - provides mechanism for testing
|
|
* abnormal program termination
|
|
*/
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "opal/runtime/opal.h"
|
|
|
|
#include "orte/runtime/runtime.h"
|
|
#include "orte/util/proc_info.h"
|
|
#include "orte/util/name_fns.h"
|
|
#include "orte/runtime/orte_globals.h"
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
|
|
int i, rc;
|
|
double pi;
|
|
pid_t pid;
|
|
const char *hostname;
|
|
|
|
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
|
|
fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc);
|
|
return rc;
|
|
}
|
|
pid = getpid();
|
|
hostname = opal_gethostname();
|
|
|
|
if (1 < argc) {
|
|
rc = strtol(argv[1], NULL, 10);
|
|
} else {
|
|
rc = 3;
|
|
}
|
|
|
|
printf("orte_abort: Name %s Host: %s Pid %ld\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
hostname, (long)pid);
|
|
fflush(stdout);
|
|
|
|
i = 0;
|
|
while (1) {
|
|
i++;
|
|
pi = i / 3.14159256;
|
|
if (i > 10000) i = 0;
|
|
if ((ORTE_PROC_MY_NAME->vpid == 3 ||
|
|
(orte_process_info.num_procs <= 3 && ORTE_PROC_MY_NAME->vpid == 0))
|
|
&& i == 9995) {
|
|
orte_errmgr.abort(rc, NULL);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|