Commit e2ca18c0 authored by Francois Tessier's avatar Francois Tessier

Rewrite the 1D-array example for an easier usage

parent fd3ff648
......@@ -6,50 +6,89 @@
#include <mpi.h>
#include "tapioca.hpp"
#include "utils.h"
#include "utils.hpp"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define BLUE "\x1b[34m"
#define RESET "\x1b[0m"
int64_t particles (int64_t max, int rank) {
int64_t n_part;
static int64_t n_elem = 250000; /* ~1MB */
static char output[4096] = {0};
static char subfiling[8] = {0};
static int nodesPerFile = 1;
static bool randomDist = false;
static char bin[32] = "1D-Array-MPIIO-R";
srand(time(NULL) + rank);
n_part = (rand () % max) + 10;
void parseArgs (int argc, char * argv[])
{
char flags[] = "hre:o:s:n:";
int opt = 0;
while ((opt = getopt (argc, argv, flags)) != -1) {
switch ( opt )
{
case('h'):
printUsage (bin);
break;
case('e'):
sscanf ( optarg, "%lld", &n_elem );
break;
case('r'):
randomDist = true;
break;
case('o'):
sprintf ( output, "%s", optarg );
break;
case('s'):
sprintf ( subfiling, "%s", optarg );
break;
case('n'):
sscanf ( optarg, "%d", &nodesPerFile);
break;
}
}
return n_part;
if ( n_elem <= 0 ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong number of elements. Reset to the default value (250000/rank). Random distribution disabled.\n");
n_elem = 250000;
randomDist = false;
}
if ( strcmp ( "FPN", subfiling ) &&
strcmp ( "FPION", subfiling ) &&
strcmp ( "SSF", subfiling ) &&
strcmp ( "NPF", subfiling ) ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong subfiling method. Reset to the default value (SSF: Single Shared File)\n");
sprintf ( subfiling, "SSF" );
}
}
int main (int argc, char * argv[])
{
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i, file_id;
int64_t num_particles;
int64_t sub_particles, tot_particles, particle_size, file_size, tot_size;
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i;
int64_t sub_elem, tot_elem, elem_size, file_size, tot_size;
int64_t scan_size = 0, offset, hdr = 0;
double start_time, end_time, tot_time, max_time;
double io_bw;
MPI_Comm sub_comm;
MPI_File file_handle;
MPI_Info info = MPI_INFO_NULL;
MPI_Status status;
char output[100];
int64_t chunkCount[1], chunkOffset[1];
int chunkSize[1];
char filename[256];
Tapioca tp;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &world_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &world_myrank);
#ifdef FPN
mycolor = tp.topology.ComputeNodeId ();
#elif FPION
mycolor = tp.topology.BridgeNodeId ();
#else
mycolor = 42;
#endif
parseArgs ( argc, argv );
if ( ! strcmp ( "FPN", subfiling ) ) mycolor = tp.topology.ComputeNodeId ();
if ( ! strcmp ( "FPION", subfiling ) ) mycolor = tp.topology.BridgeNodeId ();
if ( ! strcmp ( "NPF", subfiling ) ) mycolor = world_myrank / ( world_numtasks / nodesPerFile );
if ( ! strcmp ( "SSF", subfiling ) ) mycolor = 42;
mykey = world_myrank;
......@@ -57,65 +96,49 @@ int main (int argc, char * argv[])
MPI_Comm_size(sub_comm, &sub_numtasks);
MPI_Comm_rank(sub_comm, &sub_myrank);
if ( argv[2] != NULL )
num_particles = particles (atoi ( argv[1] ), world_myrank);
else
num_particles = atoi ( argv[1] );
#ifdef GPFS
snprintf (output, 100, "/projects/visualization/ftessier/debug/SimpleIO-%08d.dat", mycolor);
#elif SSD
snprintf (output, 100, "/scratch/SimpleIO-%08d.dat", mycolor);
#elif LUSTRE
snprintf (output, 100, "/lus/theta-fs0/projects/Performance/ftessier/HACC/SimpleIO-%08d.dat", mycolor);
#else
snprintf (output, 100, "./SimpleIO-%08d.dat", mycolor);
#endif
if ( randomDist )
n_elem = randElemFromFile ( n_elem, tp.topology.ComputeNodeId () );
snprintf (filename, 256, "/1D-ARRAY-%08d.dat", mycolor);
strcat (output, filename);
/*****************/
/* READ */
/*****************/
float *xx;
xx = new float[num_particles];
xx = new float[n_elem];
for (uint64_t i = 0; i< num_particles; i++)
for (uint64_t i = 0; i< n_elem; i++)
xx[i] = (float)i;
MPI_Allreduce(&num_particles, &sub_particles, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&num_particles, &tot_particles, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&n_elem, &sub_elem, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&n_elem, &tot_elem, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
particle_size = sizeof(float);
file_size = particle_size * sub_particles;
tot_size = particle_size * tot_particles;
elem_size = sizeof(float);
file_size = elem_size * sub_elem;
tot_size = elem_size * tot_elem;
MPI_Exscan (&num_particles, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Exscan (&n_elem, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
if (0 == sub_myrank) {
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] TAPIOCA Simple I/O\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] 1D-Array MPI-IO\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Read input file %s\n", mycolor, output);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld particles per rank\n", mycolor, num_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld particles)\n",
mycolor, (double)file_size/(1024*1024), sub_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld elem per rank\n", mycolor, n_elem);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld elem)\n",
mycolor, (double)file_size/(1024*1024), sub_elem);
}
float *xx_r;
xx_r = new float[num_particles];
xx_r = new float[n_elem];
// MPI_Info_create ( &info );
// MPI_Info_set ( info, "cb_nodes", getenv("TAPIOCA_NBAGGR") );
// MPI_Info_set ( info, "bg_nodes_pset", getenv("TAPIOCA_NBAGGR") );
start_time = MPI_Wtime();
MPI_File_open(sub_comm, output,
MPI_MODE_RDONLY, info, &file_handle);
MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handle);
//MPIIOInfo ( file_handle );
start_time = MPI_Wtime();
offset = scan_size * elem_size;
offset = scan_size * particle_size;
MPI_File_read_at_all (file_handle, offset, xx_r, num_particles, MPI_FLOAT, &status);
MPI_File_read_at_all (file_handle, offset, xx_r, n_elem, MPI_FLOAT, &status);
MPI_File_close (&file_handle);
......@@ -125,24 +148,26 @@ int main (int argc, char * argv[])
if (0 == world_myrank) {
io_bw = (double)tot_size / max_time / (1024 * 1024);
fprintf (stdout, BLUE "[TIMING]" RESET " Read I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
fprintf (stdout, BLUE "[TIMING]" RESET " Read MPI-IO I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
MPI_Barrier (MPI_COMM_WORLD);
/*****************/
/* VERIFICATION */
/*****************/
for (uint64_t i = 0; i< num_particles; i++) {
for (uint64_t i = 0; i< n_elem; i++) {
if (xx[i] != xx_r[i])
{
fprintf (stdout, RED "[ERROR]" RESET " Wrong value for particle %d\n", i);
MPI_Abort (MPI_COMM_WORLD, -1);
fprintf (stdout, RED "[ERROR]" RESET " Wrong value for particle %d\n", i);
MPI_Abort (MPI_COMM_WORLD, -1);
}
}
if (0 == sub_myrank)
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Content verified and consistent\n", mycolor);
/*****************/
/* FREE */
/*****************/
......
......@@ -6,50 +6,89 @@
#include <mpi.h>
#include "tapioca.hpp"
#include "utils.h"
#include "utils.hpp"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define BLUE "\x1b[34m"
#define RESET "\x1b[0m"
int64_t particles (int64_t max, int rank) {
int64_t n_part;
static int64_t n_elem = 250000; /* ~1MB */
static char output[4096] = {0};
static char subfiling[8] = {0};
static int nodesPerFile = 1;
static bool randomDist = false;
static char bin[32] = "1D-Array-MPIIO-W";
srand(time(NULL) + rank);
n_part = (rand () % max) + 10;
void parseArgs (int argc, char * argv[])
{
char flags[] = "hre:o:s:n:";
int opt = 0;
while ((opt = getopt (argc, argv, flags)) != -1) {
switch ( opt )
{
case('h'):
printUsage (bin);
break;
case('e'):
sscanf ( optarg, "%lld", &n_elem );
break;
case('r'):
randomDist = true;
break;
case('o'):
sprintf ( output, "%s", optarg );
break;
case('s'):
sprintf ( subfiling, "%s", optarg );
break;
case('n'):
sscanf ( optarg, "%d", &nodesPerFile);
break;
}
}
return n_part;
if ( n_elem <= 0 ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong number of elements. Reset to the default value (250000/rank). Random distribution disabled.\n");
n_elem = 250000;
randomDist = false;
}
if ( strcmp ( "FPN", subfiling ) &&
strcmp ( "FPION", subfiling ) &&
strcmp ( "SSF", subfiling ) &&
strcmp ( "NPF", subfiling ) ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong subfiling method. Reset to the default value (SSF: Single Shared File)\n");
sprintf ( subfiling, "SSF" );
}
}
int main (int argc, char * argv[])
{
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i, file_id;
int64_t num_particles;
int64_t sub_particles, tot_particles, particle_size, file_size, tot_size;
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i;
int64_t sub_elem, tot_elem, elem_size, file_size, tot_size;
int64_t scan_size = 0, offset, hdr = 0;
double start_time, end_time, tot_time, max_time;
double io_bw;
MPI_Comm sub_comm;
MPI_File file_handle;
MPI_Info info = MPI_INFO_NULL;
MPI_Status status;
char output[100];
int64_t chunkCount[1], chunkOffset[1];
int chunkSize[1];
char filename[256];
Tapioca tp;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &world_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &world_myrank);
#ifdef FPN
mycolor = tp.topology.ComputeNodeId ();
#elif FPION
mycolor = tp.topology.BridgeNodeId ();
#else
mycolor = 42;
#endif
parseArgs ( argc, argv );
if ( ! strcmp ( "FPN", subfiling ) ) mycolor = tp.topology.ComputeNodeId ();
if ( ! strcmp ( "FPION", subfiling ) ) mycolor = tp.topology.BridgeNodeId ();
if ( ! strcmp ( "NPF", subfiling ) ) mycolor = world_myrank / ( world_numtasks / nodesPerFile );
if ( ! strcmp ( "SSF", subfiling ) ) mycolor = 42;
mykey = world_myrank;
......@@ -57,37 +96,27 @@ int main (int argc, char * argv[])
MPI_Comm_size(sub_comm, &sub_numtasks);
MPI_Comm_rank(sub_comm, &sub_myrank);
if ( argv[2] != NULL )
num_particles = particles (atoi ( argv[1] ), world_myrank);
else
num_particles = atoi ( argv[1] );
#ifdef GPFS
snprintf (output, 100, "/projects/visualization/ftessier/debug/SimpleIO-%08d.dat", mycolor);
#elif SSD
snprintf (output, 100, "/scratch/SimpleIO-%08d.dat", mycolor);
#elif LUSTRE
snprintf (output, 100, "/lus/theta-fs0/projects/Performance/ftessier/HACC/SimpleIO-%08d.dat", mycolor);
#else
snprintf (output, 100, "./SimpleIO-%08d.dat", mycolor);
#endif
if ( randomDist )
n_elem = randElemFromFile ( n_elem, tp.topology.ComputeNodeId () );
snprintf (filename, 256, "/1D-ARRAY-%08d.dat", mycolor);
strcat (output, filename);
/*****************/
/* WRITE */
/*****************/
float *xx;
xx = new float[num_particles];
xx = new float[n_elem];
for (uint64_t i = 0; i< num_particles; i++)
for (uint64_t i = 0; i< n_elem; i++)
xx[i] = (float)i;
MPI_Allreduce(&num_particles, &sub_particles, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&num_particles, &tot_particles, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&n_elem, &sub_elem, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&n_elem, &tot_elem, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
particle_size = sizeof(float);
file_size = particle_size * sub_particles;
tot_size = particle_size * tot_particles;
elem_size = sizeof(float);
file_size = elem_size * sub_elem;
tot_size = elem_size * tot_elem;
if (sub_myrank == 0) {
MPI_File_open(MPI_COMM_SELF, output,
......@@ -96,30 +125,24 @@ int main (int argc, char * argv[])
MPI_File_close (&file_handle);
}
MPI_Exscan (&num_particles, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Exscan (&n_elem, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
if (0 == sub_myrank) {
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] TAPIOCA Simple I/O\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] 1D-Array MPI-IO\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Write output file %s\n", mycolor, output);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld particles per rank\n", mycolor, num_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld particles)\n",
mycolor, (double)file_size/(1024*1024), sub_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld elem per rank\n", mycolor, n_elem);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld elem)\n",
mycolor, (double)file_size/(1024*1024), sub_elem);
}
// MPI_Info_create ( &info );
// MPI_Info_set ( info, "cb_nodes", getenv("TAPIOCA_NBAGGR") );
// MPI_Info_set ( info, "bg_nodes_pset", getenv("TAPIOCA_NBAGGR") );
start_time = MPI_Wtime();
MPI_File_open(sub_comm, output,
MPI_MODE_WRONLY, info, &file_handle);
//MPIIOInfo ( file_handle );
start_time = MPI_Wtime();
MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handle);
offset = scan_size * particle_size;
offset = scan_size * elem_size;
MPI_File_write_at_all (file_handle, offset, xx, num_particles, MPI_FLOAT, &status);
MPI_File_write_at_all (file_handle, offset, xx, n_elem, MPI_FLOAT, &status);
MPI_File_close (&file_handle);
......@@ -129,7 +152,7 @@ int main (int argc, char * argv[])
if (0 == world_myrank) {
io_bw = (double)tot_size / max_time / (1024 * 1024);
fprintf (stdout, BLUE "[TIMING]" RESET " Write I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
fprintf (stdout, BLUE "[TIMING]" RESET " Write MPI-IO I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
......
......@@ -2,40 +2,81 @@
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <time.h>
#include <mpi.h>
#include "utils.h"
#include "tapioca.hpp"
#include "utils.hpp"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define BLUE "\x1b[34m"
#define RESET "\x1b[0m"
mem_t memAggr = DDR;
mem_t memTarg = HDD;
static int64_t n_elem = 250000; /* ~1MB */
static char output[4096] = {0};
static char subfiling[8] = {0};
static int nodesPerFile = 1;
static bool randomDist = false;
static char bin[32] = "1D-Array-Tapioca-R";
int64_t particles (int64_t max, int rank) {
int64_t n_part;
void parseArgs (int argc, char * argv[])
{
char flags[] = "hre:o:s:n:";
int opt = 0;
srand(time(NULL) + rank);
n_part = (rand () % max) + 10;
while ((opt = getopt (argc, argv, flags)) != -1) {
switch ( opt )
{
case('h'):
printUsage (bin);
break;
case('e'):
sscanf ( optarg, "%lld", &n_elem );
break;
case('r'):
randomDist = true;
break;
case('o'):
sprintf ( output, "%s", optarg );
break;
case('s'):
sprintf ( subfiling, "%s", optarg );
break;
case('n'):
sscanf ( optarg, "%d", &nodesPerFile);
break;
}
}
return n_part;
if ( n_elem <= 0 ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong number of elements. Reset to the default value (250000/rank). Random distribution disabled.\n");
n_elem = 250000;
randomDist = false;
}
if ( strcmp ( "FPN", subfiling ) &&
strcmp ( "FPION", subfiling ) &&
strcmp ( "SSF", subfiling ) &&
strcmp ( "NPF", subfiling ) ) {
printUsage (bin);
fprintf (stdout, RED "[WARNING]" RESET " Wrong subfiling method. Reset to the default value (SSF: Single Shared File)\n");
sprintf ( subfiling, "SSF" );
}
}
int main (int argc, char * argv[])
{
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i, file_id;
int64_t num_particles;
int64_t sub_particles, tot_particles, particle_size, file_size, tot_size;
int world_numtasks, world_myrank, mycolor, mykey, sub_numtasks, sub_myrank, i;
int64_t sub_elem, tot_elem, elem_size, file_size, tot_size;
int64_t scan_size = 0, offset, hdr = 0;
double start_time, end_time, tot_time, max_time;
double io_bw;
MPI_Comm sub_comm;
MPI_File file_handle;
MPI_Status status;
char output[100];
char filename[256];
Tapioca tp;
int64_t chunkCount[1], chunkOffset[1];
int chunkSize[1];
......@@ -44,86 +85,71 @@ int main (int argc, char * argv[])
MPI_Comm_size(MPI_COMM_WORLD, &world_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &world_myrank);
#ifdef FPN
mycolor = tp.topology.ComputeNodeId ();
#elif FPION
mycolor = tp.topology.BridgeNodeId ();
#else
mycolor = 42;
#endif
parseArgs ( argc, argv );
if ( ! strcmp ( "FPN", subfiling ) ) mycolor = tp.topology.ComputeNodeId ();
if ( ! strcmp ( "FPION", subfiling ) ) mycolor = tp.topology.BridgeNodeId ();
if ( ! strcmp ( "NPF", subfiling ) ) mycolor = world_myrank / ( world_numtasks / nodesPerFile );
if ( ! strcmp ( "SSF", subfiling ) ) mycolor = 42;
mykey = world_myrank;
//tp.topology.PrintNodesAdjencyList ();
MPI_Comm_split (MPI_COMM_WORLD, mycolor, mykey, &sub_comm);
MPI_Comm_size(sub_comm, &sub_numtasks);
MPI_Comm_rank(sub_comm, &sub_myrank);
if ( argv[2] != NULL )
num_particles = particles (atoi ( argv[1] ), world_myrank);
else
num_particles = atoi ( argv[1] );
#ifdef GPFS
snprintf (output, 100, "/projects/visualization/ftessier/debug/SimpleIO-%08d.dat", mycolor);
#elif SSD
snprintf (output, 100, "/scratch/SimpleIO-%08d.dat", mycolor);
#elif LUSTRE
snprintf (output, 100, "/lus/theta-fs0/projects/Performance/ftessier/HACC/SimpleIO-%08d.dat", mycolor);
#else
snprintf (output, 100, "./SimpleIO-%08d.dat", mycolor);
#endif
if ( randomDist )
n_elem = randElemFromFile ( n_elem, tp.topology.ComputeNodeId () );
snprintf (filename, 256, "/1D-ARRAY-%08d.dat", mycolor);
strcat (output, filename);
/*****************/
/* READ */
/*****************/
float *xx;
xx = new float[num_particles];
xx = new float[n_elem];
for (uint64_t i = 0; i< num_particles; i++)
for (uint64_t i = 0; i< n_elem; i++)
xx[i] = (float)i;
MPI_Allreduce(&num_particles, &sub_particles, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&num_particles, &tot_particles, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&n_elem, &sub_elem, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Allreduce(&n_elem, &tot_elem, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
particle_size = sizeof(float);
file_size = particle_size * sub_particles;
tot_size = particle_size * tot_particles;
elem_size = sizeof(float);
file_size = elem_size * sub_elem;
tot_size = elem_size * tot_elem;
MPI_Exscan (&num_particles, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
MPI_Exscan (&n_elem, &scan_size, 1, MPI_LONG_LONG, MPI_SUM, sub_comm);
if (0 == sub_myrank) {
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] TAPIOCA Simple I/O\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Read input file\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld particles per rank\n", mycolor, num_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld particles)\n",
mycolor, (double)file_size/(1024*1024), sub_particles);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] 1D-Array MPI-IO\n", mycolor);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Read input file %s\n", mycolor, output);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> %lld elem per rank\n", mycolor, n_elem);
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] --> File size: %.2f MB (%lld elem)\n",
mycolor, (double)file_size/(1024*1024), sub_elem);
}
float *xx_r;
xx_r = new float[num_particles];
xx_r = new float[n_elem];
/*****************/
/* INIT TAPIOCA */
/*****************/
chunkCount[0] = num_particles;
chunkCount[0] = n_elem;
chunkSize[0] = sizeof(float);
chunkOffset[0] = hdr + scan_size * particle_size;
chunkOffset[0] = hdr + scan_size * chunkSize[0];
tp.Init (chunkCount, chunkSize, chunkOffset, 1, hdr, sub_comm);
tp.setAggregationTier (2, memAggr, "/scratch/tmp-read");
tp.setTargetTier (memTarg, file_size, output);
tp.Init (chunkCount, chunkSize, chunkOffset, 1, hdr, output, sub_comm);
/*****************/
start_time = MPI_Wtime();
if (0 == sub_myrank)
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Read output file\n", mycolor);
offset = scan_size * particle_size;
offset = scan_size * elem_size;
tp.Read (offset, xx_r, num_particles, MPI_FLOAT, &status);
tp.Read (offset, xx_r, n_elem, MPI_FLOAT, &status);
tp.Finalize ();
end_time = MPI_Wtime();
tot_time = end_time - start_time;
......@@ -131,22 +157,20 @@ int main (int argc, char * argv[])
if (0 == world_myrank) {
io_bw = (double)tot_size / max_time / (1024 * 1024);
fprintf (stdout, BLUE "[TIMING]" RESET " Read I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
fprintf (stdout, BLUE "[TIMING]" RESET " Read TAPIOCA I/O bandwidth: %.2f MBps (%.2f MB in %.2f ms)\n",
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
MPI_Barrier (MPI_COMM_WORLD);
tp.Finalize ();
/*****************/
/* VERIFICATION */
/*****************/
for (uint64_t i = 0; i< num_particles; i++) {
for (uint64_t i = 0; i< n_elem; i++) {
if (xx[i] != xx_r[i])
{
fprintf (stdout, RED "[ERROR]" RESET " Wrong value for particle %d\n", i);
MPI_Abort (MPI_COMM_WORLD, -1);
fprintf (stdout, RED "[ERROR]" RESET " Wrong value for particle %d\n", i);
MPI_Abort (MPI_COMM_WORLD, -1);
}
}
......
......@@ -2,40 +2,81 @@
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <time.h>
#include <mpi.h>
#include "utils.h"
#include "tapioca.hpp"
#include "utils.hpp"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define BLUE "\x1b[34m"
#define RESET "\x1b[0m"
mem_t memAggr = DDR;
mem_t memTarg = HDD;
static int64_t n_elem = 250000; /* ~1MB */
static char output[4096] = {0};
static char subfiling[8] = {0};
static int nodesPerFile = 1;
static bool randomDist = false;
static char bin[32] = "1D-Array-Tapioca-W";
int64_t particles (int64_t max, int rank) {
int64_t n_part;