orte: fixup hostname max length usage
Also removes orte specific max hostname value. Signed-off-by: Karol Mroz <mroz.karol@gmail.com>
Этот коммит содержится в:
родитель
3322347da9
Коммит
5c11bdb251
@ -194,15 +194,14 @@ static int component_send(orte_rml_send_t *msg)
|
||||
static char* component_get_addr(void)
|
||||
{
|
||||
int len;
|
||||
char hn[MAXHOSTNAMELEN], *cptr;
|
||||
char hn[OPAL_MAXHOSTNAMELEN], *cptr;
|
||||
|
||||
/*
|
||||
* TODO: for aries want to plug in GNI addr here instead to
|
||||
* eventually be able to support connect/accept using aprun.
|
||||
*/
|
||||
|
||||
len = gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[len]='\0';
|
||||
len = gethostname(hn, sizeof(hn));
|
||||
|
||||
asprintf(&cptr, "gni://%s:%d", hn, getpid());
|
||||
|
||||
|
@ -230,7 +230,7 @@ int orte_daemon(int argc, char *argv[])
|
||||
char *rml_uri;
|
||||
int i;
|
||||
opal_buffer_t *buffer;
|
||||
char hostname[100];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
char *tmp_env_var = NULL;
|
||||
#endif
|
||||
@ -297,7 +297,7 @@ int orte_daemon(int argc, char *argv[])
|
||||
* away just in case we have a problem along the way
|
||||
*/
|
||||
if (orted_globals.debug) {
|
||||
gethostname(hostname, 100);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
fprintf(stderr, "Daemon was launched on %s - beginning to initialize\n", hostname);
|
||||
}
|
||||
|
||||
@ -725,12 +725,12 @@ int orte_daemon(int argc, char *argv[])
|
||||
if (orte_retain_aliases) {
|
||||
char **aliases=NULL;
|
||||
uint8_t naliases, ni;
|
||||
char hostname[ORTE_MAX_HOSTNAME_SIZE];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
/* if we stripped the prefix or removed the fqdn,
|
||||
* include full hostname as an alias
|
||||
*/
|
||||
gethostname(hostname, ORTE_MAX_HOSTNAME_SIZE);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
if (strlen(orte_process_info.nodename) < strlen(hostname)) {
|
||||
opal_argv_append_nosize(&aliases, hostname);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
#define _GNU_SOURCE
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -13,7 +15,7 @@ int main(int argc, char* argv[])
|
||||
int msg;
|
||||
MPI_Comm parent, children[NUM_CHILDREN];
|
||||
int rank, size, i;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
pid_t pid;
|
||||
char *child_argv[2] = { "", NULL };
|
||||
|
||||
@ -54,7 +56,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
/* Otherwise, we're the child */
|
||||
else {
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
if (argc == 1) {
|
||||
printf("ERROR: child did not receive exepcted argv!\n");
|
||||
i = -1;
|
||||
|
@ -5,6 +5,8 @@
|
||||
* The most basic of MPI applications
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "mpi.h"
|
||||
@ -12,13 +14,13 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rank, size;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
printf("%s: I am %d of %d. pid=%d\n", hostname, rank, size, getpid());
|
||||
|
||||
if (rank%3 == 0) {
|
||||
|
@ -6,6 +6,9 @@
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -15,7 +18,7 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rank, size;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
void *appnum;
|
||||
void *univ_size;
|
||||
char *appstr, *unistr;
|
||||
@ -40,7 +43,7 @@ int main(int argc, char* argv[])
|
||||
asprintf(&unistr, "%d", *(int*)univ_size);
|
||||
}
|
||||
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
printf("Hello, World, I am %d of %d on host %s from app number %s universe size %s universe envar %s\n",
|
||||
rank, size, hostname, appstr, unistr, (NULL == envar) ? "NULL" : envar);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -11,7 +13,7 @@ int main(int argc, char* argv[])
|
||||
int msg, rc, i;
|
||||
MPI_Comm parent, child;
|
||||
int rank, size;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
pid_t pid;
|
||||
MPI_Info info;
|
||||
char *keyval, *tmp;
|
||||
@ -63,7 +65,7 @@ int main(int argc, char* argv[])
|
||||
else {
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
pid = getpid();
|
||||
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
|
||||
if (0 == rank) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -9,7 +11,7 @@ int main(int argc, char* argv[])
|
||||
int msg, rc;
|
||||
MPI_Comm parent, child;
|
||||
int rank, size;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
pid_t pid;
|
||||
|
||||
pid = getpid();
|
||||
@ -41,7 +43,7 @@ int main(int argc, char* argv[])
|
||||
else {
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
pid = getpid();
|
||||
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
|
||||
if (0 == rank) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -44,7 +45,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char hostname[255] ;
|
||||
char hostname[OPAL_MAXHOSTNAMELEN] ;
|
||||
char buff[255] ;
|
||||
|
||||
int role ;
|
||||
@ -80,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* get the node name */
|
||||
{
|
||||
int retval = gethostname(hostname, 255) ;
|
||||
int retval = gethostname(hostname, sizeof(hostname));
|
||||
if(retval == -1)
|
||||
{
|
||||
fprintf(stderr, "gethostname failed: %s\n", strerror(errno)) ;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -9,7 +11,7 @@ int main(int argc, char* argv[])
|
||||
int msg;
|
||||
MPI_Comm parent, child;
|
||||
int rank, size;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
pid_t pid;
|
||||
int i;
|
||||
char *cmds[2];
|
||||
@ -48,7 +50,7 @@ int main(int argc, char* argv[])
|
||||
else {
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
pid = getpid();
|
||||
printf("Hello from the child %d of %d on host %s pid %ld: argv[1] = %s\n", rank, size, hostname, (long)pid, argv[1]);
|
||||
MPI_Recv(&msg, 1, MPI_INT, 0, 1, parent, MPI_STATUS_IGNORE);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -9,7 +11,7 @@ int main(int argc, char ** argv){
|
||||
|
||||
int i;
|
||||
int rank, size, child_rank;
|
||||
char nomehost[20];
|
||||
char nomehost[OPAL_MAXHOSTNAMELEN];
|
||||
MPI_Comm parent, intercomm1, intercomm2;
|
||||
int erro;
|
||||
int level, curr_level;
|
||||
@ -60,7 +62,7 @@ int main(int argc, char ** argv){
|
||||
|
||||
}
|
||||
|
||||
gethostname(nomehost, 20);
|
||||
gethostname(nomehost, sizeof(nomehost));
|
||||
printf("(%d) in %s\n", rank, nomehost);
|
||||
|
||||
MPI_Finalize();
|
||||
|
@ -6,6 +6,8 @@
|
||||
* abnormal program termination
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -21,14 +23,14 @@ int main(int argc, char* argv[])
|
||||
int i, rc;
|
||||
double pi;
|
||||
pid_t pid;
|
||||
char hostname[500];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
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();
|
||||
gethostname(hostname, 500);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
if (1 < argc) {
|
||||
rc = strtol(argv[1], NULL, 10);
|
||||
|
@ -6,6 +6,8 @@
|
||||
* abnormal program termination
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -21,14 +23,14 @@ int main(int argc, char* argv[])
|
||||
int i, rc;
|
||||
double pi;
|
||||
pid_t pid;
|
||||
char hostname[500];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
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();
|
||||
gethostname(hostname, 500);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
printf("orte_abort: Name %s Host: %s Pid %ld\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
||||
hostname, (long)pid);
|
||||
|
@ -5,6 +5,8 @@
|
||||
* The most basic of MPI applications
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -20,7 +22,7 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rc, i, restart=-1;
|
||||
char hostname[512], *rstrt;
|
||||
char hostname[OPAL_MAXHOSTNAMELEN], *rstrt;
|
||||
pid_t pid;
|
||||
|
||||
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
|
||||
@ -32,7 +34,7 @@ int main(int argc, char* argv[])
|
||||
restart = strtol(rstrt, NULL, 10);
|
||||
}
|
||||
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
pid = getpid();
|
||||
|
||||
printf("orte_nodename: Node %s Name %s Pid %ld Restarts: %d\n",
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* -*- C -*-
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -19,14 +21,14 @@ int main(int argc, char* argv[])
|
||||
int i, rc;
|
||||
double pi;
|
||||
pid_t pid;
|
||||
char hostname[500];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
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();
|
||||
gethostname(hostname, 500);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
if (1 < argc) {
|
||||
rc = strtol(argv[1], NULL, 10);
|
||||
|
@ -99,7 +99,7 @@ int orte_proc_info(void)
|
||||
|
||||
int idx, i;
|
||||
char *ptr;
|
||||
char hostname[ORTE_MAX_HOSTNAME_SIZE];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
char **prefixes;
|
||||
bool match;
|
||||
struct in_addr buf;
|
||||
@ -168,7 +168,7 @@ int orte_proc_info(void)
|
||||
orte_process_info.pid = getpid();
|
||||
|
||||
/* get the nodename */
|
||||
gethostname(hostname, ORTE_MAX_HOSTNAME_SIZE);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
/* add this to our list of aliases */
|
||||
opal_argv_append_nosize(&orte_process_info.aliases, hostname);
|
||||
|
||||
|
@ -45,8 +45,6 @@
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
#define ORTE_MAX_HOSTNAME_SIZE 512
|
||||
|
||||
typedef uint32_t orte_proc_type_t;
|
||||
#define ORTE_PROC_TYPE_NONE 0x0000
|
||||
#define ORTE_PROC_SINGLETON 0x0001
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user