1
1
openmpi/src/util/universe_setup_file_io.c

177 строки
3.6 KiB
C
Исходник Обычный вид История

/*
*
* $HEADER$
*
* $Id: ompi_universe_setup_file I/O functions $
*
*/
#include "ompi_config.h"
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include "include/constants.h"
#include "util/output.h"
#include "runtime/runtime.h"
#include "util/universe_setup_file_io.h"
#define OMPI_UNIV_SETUP_FILE_MAX_LINE_LENGTH 1024
char *ompi_getline(FILE *fp);
int ompi_write_universe_setup_file(char *filename)
{
FILE *fp;
fp = fopen(filename, "w");
if (NULL == fp) {
return OMPI_ERROR;
}
if (NULL == ompi_universe_info.name) {
goto CLEANUP;
}
fprintf(fp, "%s\n", ompi_universe_info.name);
if (NULL == ompi_universe_info.host) {
goto CLEANUP;
}
fprintf(fp, "%s\n", ompi_universe_info.host);
if (NULL == ompi_universe_info.uid) {
goto CLEANUP;
}
fprintf(fp, "%s\n", ompi_universe_info.uid);
fprintf(fp, "%d\n", ompi_universe_info.pid);
if (ompi_universe_info.persistence) {
fprintf(fp, "persistent\n");
} else {
fprintf(fp, "non-persistent\n");
}
if (NULL == ompi_universe_info.scope) {
goto CLEANUP;
}
fprintf(fp, "%s\n", ompi_universe_info.scope);
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
if (ompi_universe_info.console) {
fprintf(fp, "console\n");
} else {
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
fprintf(fp, "silent\n");
}
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
if (NULL == ompi_universe_info.seed_contact_info) {
goto CLEANUP;
}
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
fprintf(fp, "%s\n", ompi_universe_info.seed_contact_info);
fclose(fp);
return OMPI_SUCCESS;
CLEANUP:
fclose(fp);
return OMPI_ERROR;
}
int ompi_read_universe_setup_file(char *filename)
{
char *input;
FILE *fp;
fp = fopen(filename, "r");
if (NULL == fp) { /* failed on first read - wait and try again */
sleep(1);
fp = fopen(filename, "r");
if (NULL == fp) { /* failed twice - give up */
return OMPI_ERR_NOT_FOUND;
}
}
ompi_universe_info.name = ompi_getline(fp);
if (NULL == ompi_universe_info.name) {
goto CLEANUP;
}
ompi_universe_info.host = ompi_getline(fp);
if (NULL == ompi_universe_info.host) {
goto CLEANUP;
}
ompi_universe_info.uid = ompi_getline(fp);
if (NULL == ompi_universe_info.uid) {
goto CLEANUP;
}
input = ompi_getline(fp);
if (NULL == input) {
goto CLEANUP;
}
ompi_universe_info.pid = (pid_t)atoi(input);
input = ompi_getline(fp);
if (NULL == input) {
goto CLEANUP;
}
if (0 == strncmp(input, "persistent", strlen("persistent"))) {
ompi_universe_info.persistence = true;
} else if (0 == strncmp(input, "non-persistent", strlen("non-persistent"))) {
ompi_universe_info.persistence = false;
} else {
free(input);
goto CLEANUP;
}
free(input);
ompi_universe_info.scope = ompi_getline(fp);
if (NULL == ompi_universe_info.scope) {
goto CLEANUP;
}
input = ompi_getline(fp);
if (NULL == input) {
goto CLEANUP;
}
if (0 == strncmp(input, "silent", strlen("silent"))) {
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
ompi_universe_info.console = false;
} else if (0 == strncmp(input, "console", strlen("console"))) {
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
ompi_universe_info.console = true;
} else {
free(input);
goto CLEANUP;
}
free(input);
Some of these didn't really change - I was just in/out of them for diagnostics while chasing a bug. Got caught by my good buddy Tim again :) on his parse_contact_info function, which requires that the space for the answer be allocated in advance. Sigh. Anyway, mpirun2 now works again. My apologies if you tried it in the last few hours and found it didn't. Also removed the mpirun3 directory since we are basically dragging mpirun2 along with us - no need to create a new version after all. Made a few changes to the universe info structure, eliminating the "webserver" and "socket" fields since we will do those contacts through the oob channel. Also changed the "silent_mode" field to "console" since silent mode is the default - the flag needs to tell you to turn the console on, not off. Parse environ function now gets the ns and gpr replica contact info and loads it in the proper places to hand it off to the respective components, thus allowing me to check connection to them as part of determining if the named universe already exists. Changed the local_universe_exists function accordingly and gave it a new name (since the replicas may not be local). This name will shortly be changed to "ompi_rte_join_universe" as I complete the logic for doing that function. Please let me know if you see any problems. I successfully ran some trivial multi-process functions in both mpirun2 and singleton modes, and ran the seed daemon as well, so I think it should all be okay. This commit was SVN r2611.
2004-09-11 16:56:52 +04:00
ompi_universe_info.seed_contact_info = ompi_getline(fp);
if (NULL == ompi_universe_info.seed_contact_info) {
goto CLEANUP;
}
fclose(fp);
return OMPI_SUCCESS;
CLEANUP:
fclose(fp);
return OMPI_ERROR;
}
char *ompi_getline(FILE *fp)
{
char *ret, *buff;
char input[OMPI_UNIV_SETUP_FILE_MAX_LINE_LENGTH];
ret = fgets(input, OMPI_UNIV_SETUP_FILE_MAX_LINE_LENGTH, fp);
if (NULL != ret) {
input[strlen(input)-1] = '\0'; /* remove newline */
buff = strdup(input);
return buff;
}
return NULL;
}