Commit ed0da381 authored by Thomas Ponweiser's avatar Thomas Ponweiser
Browse files

broadcasting configuration

parent bc7e5a32
......@@ -92,7 +92,7 @@ void conf_init_from_args(conf_t *c, int argc, char* argv[])
}
if(optind > argc) {
fprintf(stderr, "Expected base name of input file (omitting '.wi' file extension)\n");
fprintf(stderr, "Expected base name of input file (omitting '%s' file extension)\n", FILE_EXT);
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
......
......@@ -47,7 +47,7 @@ typedef struct
#define CONF_T_N_INT_MEMBERS 6
#define CONF_T_FIRST_INT_MEMBER verbosity_level
#define CONF_T_N_LONG_MEMBERS 2
#define CONF_T_N_LONG_MEMBERS 1
#define CONF_T_FIRST_LONG_MEMBER n_generations_per_iteration
#define CONF_T_N_CHAR_MEMBERS FILE_BASENAME_SZ
......
......@@ -9,7 +9,6 @@
#include "world.h"
#include "simulation.h"
void broadcast_configuration(conf_t *c);
void read_input(const conf_t *c, world_t *world);
......@@ -20,11 +19,15 @@ void print_avg_timings(const conf_t *c, double total_time, double sim_time, doub
int main(int argc, char* argv[])
{
int rank, nprocs;
conf_t config;
world_t world;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
// We want the program to stop on I/O errors
// -> Change the default I/O error hander from MPI_ERRORS_RETURN to MPI_ERRORS_ARE_FATAL
// Notes:
......@@ -32,8 +35,12 @@ int main(int argc, char* argv[])
// * The default I/O error handler is associated to the null file handle, i.e. MPI_FILE_NULL.
MPI_File_set_errhandler(MPI_FILE_NULL, MPI_ERRORS_ARE_FATAL);
// Parse command line arguments
conf_init_from_args(&config, argc, argv);
// Parse command line arguments and broadcast configuration
if(rank == 0) {
conf_init_from_args(&config, argc, argv);
}
broadcast_configuration(&config);
if(info_enabled(&config)) conf_print(&config, stdout);
// Read input file
......@@ -48,6 +55,16 @@ int main(int argc, char* argv[])
return EXIT_SUCCESS;
}
void broadcast_configuration(conf_t *c) {
MPI_Datatype conf_type;
mpitype_conf_init(&conf_type);
MPI_Bcast(c, 1, conf_type, 0, MPI_COMM_WORLD);
mpitype_conf_free(&conf_type);
}
void read_input(const conf_t *c, world_t *world) {
int rank;
const int periods[2] = {0}; // non-periodic boundaries
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment