Commit 64320559 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Prepared files and infrastructure for i/o using MPI but not parallel-hdf5.


Former-commit-id: 62740d07c6cc875f716f2285dd2ef7674fe97fa9
parent c11996bf
......@@ -677,11 +677,16 @@ int main ( int argc , char *argv[] ) {
/* Read particles and space information from (GADGET) IC */
tic = getticks();
#ifdef WITH_MPI
#if defined( WITH_MPI )
#if defined( HAVE_PARALLEL_HDF5 )
read_ic_parallel( ICfileName , dim , &parts , &N , &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL );
#else
read_ic( ICfileName , dim , &parts , &N , &periodic );
read_ic_serial( ICfileName , dim , &parts , &N , &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL );
#endif
#else
read_ic_single( ICfileName , dim , &parts , &N , &periodic );
#endif
if ( myrank == 0 )
message( "reading particle properties took %.3f ms." , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
......@@ -778,12 +783,17 @@ int main ( int argc , char *argv[] ) {
engine_redistribute ( &e );
#endif
message("Before write !");
/* Write the state of the system as it is before starting time integration. */
tic = getticks();
#ifdef WITH_MPI
#if defined( WITH_MPI )
#if defined( HAVE_PARALLEL_HDF5 )
write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#else
write_output(&e, &us);
write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#endif
#else
write_output_single(&e, &us);
#endif
message( "writing particle properties took %.3f ms." , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
......@@ -837,11 +847,17 @@ int main ( int argc , char *argv[] ) {
if ( j % 100 == 0 )
{
#ifdef WITH_MPI
write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#if defined( WITH_MPI )
#if defined( HAVE_PARALLEL_HDF5 )
write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#else
write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#endif
#else
write_output(&e, &us);
write_output_single(&e, &us);
#endif
}
/* Dump a line of agregate output. */
......@@ -858,20 +874,18 @@ int main ( int argc , char *argv[] ) {
/* for ( k = 0 ; k < 5 ; k++ )
printgParticle( s.gparts , pid[k] , N ); */
}
}
/* Print the values of the runner histogram. */
#ifdef HIST
printf( "main: runner histogram data:\n" );
for ( k = 0 ; k < runner_hist_N ; k++ )
printf( " %e %e %e\n" ,
runner_hist_a + k * (runner_hist_b - runner_hist_a) / runner_hist_N ,
runner_hist_a + (k + 1) * (runner_hist_b - runner_hist_a) / runner_hist_N ,
(double)runner_hist_bins[k] );
#endif
#ifdef HIST
printf( "main: runner histogram data:\n" );
for ( k = 0 ; k < runner_hist_N ; k++ )
printf( " %e %e %e\n" ,
runner_hist_a + k * (runner_hist_b - runner_hist_a) / runner_hist_N ,
runner_hist_a + (k + 1) * (runner_hist_b - runner_hist_a) / runner_hist_N ,
(double)runner_hist_bins[k] );
#endif
// write_output( &e );
/* Loop over the parts directly. */
// for ( k = 0 ; k < N ; k++ )
// printf( " %i %e %e\n" , s.parts[k].id , s.parts[k].count , s.parts[k].count_dh );
......@@ -904,16 +918,20 @@ int main ( int argc , char *argv[] ) {
#endif */
/* Write final output. */
#ifdef WITH_MPI
write_output_parallel( &e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL );
#if defined( WITH_MPI )
#if defined( HAVE_PARALLEL_HDF5 )
write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#else
write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
#endif
#else
write_output( &e , &us );
write_output_single(&e, &us);
#endif
#ifdef WITH_MPI
if ( MPI_Finalize() != MPI_SUCCESS )
error( "call to MPI_Finalize failed with error %i." , res );
#endif
if ( MPI_Finalize() != MPI_SUCCESS )
error( "call to MPI_Finalize failed with error %i." , res );
#endif
/* Say goodbye. */
message( "done." );
......@@ -921,4 +939,4 @@ int main ( int argc , char *argv[] ) {
/* All is calm, all is bright. */
return 0;
}
}
......@@ -35,12 +35,12 @@ endif
# List required headers
include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
common_io.h multipole.h
common_io.h single_io.h multipole.h
# Common source files
AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
serial_io.c timers.c debug.c scheduler.c proxy.c parallel_io.c \
units.c common_io.c multipole.c version.c
units.c common_io.c single_io.c multipole.c version.c
# Include files for distribution, not installation.
noinst_HEADERS = atomic.h cycle.h error.h inline.h kernel.h vector.h \
......
......@@ -21,7 +21,7 @@
/* Config parameters. */
#include "../config.h"
#if defined(HAVE_HDF5) && defined(WITH_MPI)
#if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5)
/* Tell hdf5 that we intend to use shared-memory parallel stuff. */
#define H5_HAVE_PARALLEL
......
......@@ -18,7 +18,7 @@
******************************************************************************/
#if defined(HAVE_HDF5) && defined(WITH_MPI)
#if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5)
void read_ic_parallel ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info);
......
......@@ -21,7 +21,7 @@
/* Config parameters. */
#include "../config.h"
#if defined(HAVE_HDF5) && !defined(WITH_MPI)
#if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5)
/* Some standard headers. */
......@@ -175,7 +175,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N, int dim
* Calls #error() if an error occurs.
*
*/
void read_ic ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic)
void read_ic_serial ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info)
{
hid_t h_file=0, h_grp=0;
double boxSize[3]={0.0,-1.0,-1.0}; /* GADGET has only cubic boxes (in cosmological mode) */
......@@ -390,7 +390,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, enu
* Calls #error() if an error occurs.
*
*/
void write_output (struct engine *e, struct UnitSystem* us)
void write_output_serial ( struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info )
{
hid_t h_file=0, h_grp=0;
......
......@@ -18,11 +18,11 @@
******************************************************************************/
#if defined(HAVE_HDF5) && !defined(WITH_MPI)
#if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5)
void read_ic ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic);
void read_ic_serial ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info);
void write_output ( struct engine* e, struct UnitSystem* us );
void write_output_serial ( struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info );
#endif
......@@ -38,6 +38,7 @@
#include "runner.h"
#include "engine.h"
#include "units.h"
#include "single_io.h"
#include "serial_io.h"
#include "parallel_io.h"
#include "debug.h"
......
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