explicit set of verbosity level to default; refactor variables for MPI communicator size and rank to 'comm_size' and 'comm_rank'

This commit is contained in:
2013-10-31 15:30:43 +01:00
parent 468a5d6871
commit 950bcef057
7 changed files with 85 additions and 49 deletions
+13 -6
View File
@@ -9,19 +9,26 @@
#include "H5hut.h"
#define FNAME "example_setview.h5"
#define VERBOSITY H5_VERBOSE_DEFAULT
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_setview.h5"
int
main (
int argc, char* argv[]
){
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// initialize MPI & H5hut
int mpi_rank = 0;
int mpi_size = 1;
int comm_rank = 0;
int comm_size = 1;
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank (comm, &mpi_rank);
MPI_Comm_size (comm, &mpi_size);
MPI_Comm_rank (comm, &comm_rank);
MPI_Comm_size (comm, &comm_size);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
// open file and go to step#0
h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
+20 -14
View File
@@ -8,21 +8,27 @@
*/
#include "H5hut.h"
#include "examples.h"
#define FNAME "example_setview.h5"
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_setview.h5"
int
main (
int argc, char* argv[]
){
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// initialize MPI & H5hut
int mpi_rank = 0;
int mpi_size = 1;
int comm_rank = 0;
int comm_size = 1;
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank (comm, &mpi_rank);
MPI_Comm_size (comm, &mpi_size);
MPI_Comm_rank (comm, &comm_rank);
MPI_Comm_size (comm, &comm_size);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
// open file and go to step#0
h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
@@ -31,17 +37,17 @@ main (
// compute a "canonical" view: all cores get almost the same number of
// particles
h5_int64_t total_particles = H5PartGetNumParticles (file);
h5_int64_t nparticles = total_particles / mpi_size;
h5_int64_t remainder = total_particles % mpi_size;
h5_int64_t start = mpi_rank * nparticles;
h5_int64_t nparticles = total_particles / comm_size;
h5_int64_t remainder = total_particles % comm_size;
h5_int64_t start = comm_rank * nparticles;
// adjust number of local particles
if (mpi_rank < remainder)
if (comm_rank < remainder)
nparticles++;
// adjust start
if (mpi_rank < remainder)
start += mpi_rank;
if (comm_rank < remainder)
start += comm_rank;
else
start += remainder;
@@ -49,14 +55,14 @@ main (
// this forces the selection of zero particles!
h5_int64_t end = start + nparticles - 1;
printf ("[proc %d]: set view to [%lld..%lld]\n", mpi_rank, start, end);
printf ("[proc %d]: set view to [%lld..%lld]\n", comm_rank, start, end);
H5PartSetView (file, start, end);
h5_int32_t* data = calloc (nparticles, sizeof (*data));
H5PartReadDataInt32 (file, "data", data);
for (int i = 0; i < nparticles; i++) {
printf ("[proc %d]: global index = %lld; local index = %d, value = %d\n",
mpi_rank, start+i, i, data[i]);
comm_rank, start+i, i, data[i]);
}
H5CloseFile (file);
return MPI_Finalize ();
+11 -6
View File
@@ -8,20 +8,25 @@
*/
#include "H5hut.h"
#include "examples.h"
#define FNAME "example_particles.h5"
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_particles.h5"
int
main (
int argc, char* argv[]
){
H5AbortOnError ();
H5SetVerbosityLevel (VERBOSITY);
h5_int64_t verbosity = DEFAULT_VERBOSITY;
int myproc;
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm_rank (MPI_COMM_WORLD, &myproc);
MPI_Comm comm = MPI_COMM_WORLD;
int rank = 0;
MPI_Comm_rank (comm, &rank);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
+14 -11
View File
@@ -8,29 +8,32 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
#include <assert.h>
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_core_vfd"
#define DATASIZE 32
#define FNAME "example_core_vfd"
#define DATASIZE 32
int
main (
int argc, char* argv[]
){
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// initialize MPI & H5hut
int mpi_rank = 0;
int mpi_size = 1;
int comm_rank = 0;
int comm_size = 1;
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank (comm, &mpi_rank);
MPI_Comm_size (comm, &mpi_size);
MPI_Comm_rank (comm, &comm_rank);
MPI_Comm_size (comm, &comm_size);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
// open file and go to step#0
char fname[64];
sprintf (fname, "%s.%d.h5", FNAME, mpi_rank);
sprintf (fname, "%s.%d.h5", FNAME, comm_rank);
h5_prop_t prop = H5CreateFileProp ();
H5SetPropFileCoreVFD (prop);
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, prop);
@@ -42,7 +45,7 @@ main (
// create fake data
for (int i = 0; i < DATASIZE; i++) {
data[i] = i + mpi_rank * DATASIZE;
data[i] = i + comm_rank * DATASIZE;
}
// write the data
+8 -3
View File
@@ -10,21 +10,26 @@
#include <stdlib.h>
#include "H5hut.h"
#define FNAME "example_setnparticles.h5"
#define NUM_PARTICLES 3
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_setnparticles.h5"
#define NUM_PARTICLES 3
int
main (
int argc,
char* argv[]
){
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int rank = 0;
MPI_Comm_rank (comm, &rank);
H5AbortOnError ();
H5SetVerbosityLevel (-1);
H5SetVerbosityLevel (verbosity);
// create fake data
h5_int32_t data[NUM_PARTICLES];
+11 -7
View File
@@ -10,28 +10,32 @@
#include <stdlib.h>
#include "H5hut.h"
#define FNAME "example_setview.h5"
#define DATASIZE 32
#define ITERS 4
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_setview.h5"
#define DATASIZE 32
#define ITERS 4
int
main (
int argc, char** argv
) {
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int mpi_rank = 0;
MPI_Comm_rank (comm, &mpi_rank);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
// create fake data
h5_int64_t npoints = ITERS*DATASIZE;
h5_int32_t data[ITERS*DATASIZE];
for (int i = 0; i < npoints; i++) {
data[i] = i + mpi_rank*npoints;
data[i] = i + comm_rank*npoints;
}
// open file and create step #0
@@ -43,7 +47,7 @@ main (
H5PartSetNumParticles(file, npoints);
// write ITER consecutive blocks of size DATASIZE
h5_int64_t offset = mpi_rank * npoints;
h5_int64_t offset = comm_rank * npoints;
for (int i = 0; i < ITERS; i++) {
// set the "view" to select a subset of the dataset
H5PartSetView (
+8 -2
View File
@@ -9,20 +9,26 @@
#include "H5hut.h"
#define FNAME "example_strided.h5"
#define NPOINTS 99
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
#define FNAME "example_strided.h5"
#define NPOINTS 99
int
main (
int argc,
char** argv
) {
h5_int64_t verbosity = DEFAULT_VERBOSITY;
// MPI & H5hut init
MPI_Init (&argc, &argv);
int rank;
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank (comm, &rank);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
// create fake data
h5_float64_t particles[6*NPOINTS];