Commit bd43b858 authored by Francois Tessier's avatar Francois Tessier

Write a simple 1D-array example filled with one variable

parent a943b3b8
MPICXX = mpixlcxx
MPI_CFLAGS = -g -I$(HOME)/install_bgq/include/ -DBGQ -DDEBUG -DTIMING
MPI_LDFLAGS = -L$(HOME)/install_bgq/lib/ -ltapioca
all: main_tapioca
main_tapioca:main_tapioca.cpp
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
clean:
rm main_tapioca
MPICXX = mpixlcxx
MPI_CFLAGS = -g -I$(HOME)/install_bgq/include/ -DBGQ -DDEBUG -DTIMING
MPI_LDFLAGS = -L$(HOME)/install_bgq/lib/ -ltapioca
all: simple_io_tapioca simple_io_mpiio
simple_io_tapioca:simple_io_tapioca.cpp
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
simple_io_mpiio:simple_io_mpiio.cpp
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
clean:
rm simple_io_tapioca simple_io_mpiio
MPICXX = CC
MPI_CFLAGS = -g -I$(HOME)/install/include/ -DXC40 -DDEBUG -DTIMING
MPI_LDFLAGS = -L$(HOME)/install/lib/ -ltapioca -llustreapi -Wl,--whole-archive,-ldmapp,--no-whole-archive
all: simple_io_tapioca simple_io_mpiio
simple_io_tapioca:simple_io_tapioca.cpp
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
simple_io_mpiio:simple_io_mpiio.cpp
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
clean:
rm simple_io_tapioca simple_io_mpiio
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <mpi.h>
#include "tapioca.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;
srand(time(NULL) + rank);
n_part = (rand () % max) + 10;
return n_part;
}
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;
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];
Tapioca tp, tp2;
int64_t chunkCount[1], chunkOffset[1];
int chunkSize[1];
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &world_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &world_myrank);
//mycolor = tp.topology.BridgeNodeId ();
mycolor = 42;
mykey = world_myrank;
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 BGQ
snprintf (output, 100, "/projects/visualization/ftessier/debug/SimpleIO-%08d.dat", mycolor);
#elif XC40
snprintf (output, 100, "/lus/theta-fs0/projects/Performance/ftessier/HACC/SimpleIO-%08d.dat", mycolor);
#else
snprintf (output, 100, "./SimpleIO-%08d.dat", mycolor);
#endif
/*****************/
/* WRITE */
/*****************/
float *xx;
xx = new float[num_particles];
for (uint64_t i = 0; i< num_particles; 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);
particle_size = sizeof(float);
file_size = particle_size * sub_particles;
tot_size = particle_size * tot_particles;
if (sub_myrank == 0) {
MPI_File_open(MPI_COMM_SELF, output,
MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &file_handle);
MPI_File_set_size(file_handle, file_size);
MPI_File_close (&file_handle);
}
MPI_Exscan (&num_particles, &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] Write output 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);
}
/*****************/
/* INIT TAPIOCA */
/*****************/
chunkCount[0] = num_particles;
chunkSize[0] = sizeof(float);
chunkOffset[0] = hdr + scan_size * particle_size;
tp.WriteInitialize (output, chunkCount, chunkSize, chunkOffset, 1, hdr, ARRAY_OF_STRUCTURES, sub_comm);
/*****************/
MPI_Barrier (MPI_COMM_WORLD);
start_time = MPI_Wtime();
MPI_File_open(sub_comm, output,
MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handle);
offset = scan_size * particle_size;
tp.Write (file_handle, offset, xx, num_particles, MPI_FLOAT, &status);
MPI_File_close (&file_handle);
end_time = MPI_Wtime();
tot_time = end_time - start_time;
MPI_Reduce (&tot_time, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
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",
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
MPI_Barrier (MPI_COMM_WORLD);
/*****************/
/* READ */
/*****************/
float *xx_r;
xx_r = new float[num_particles];
/*****************/
/* INIT TAPIOCA */
/*****************/
tp2.ReadInitialize (output, chunkCount, chunkSize, chunkOffset, 1, hdr, ARRAY_OF_STRUCTURES, sub_comm);
/*****************/
start_time = MPI_Wtime();
MPI_File_open(sub_comm, output,
MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handle);
if (0 == sub_myrank)
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Read output file\n", mycolor);
offset = scan_size * particle_size;
tp2.Read (file_handle, offset, xx_r, num_particles, MPI_FLOAT, &status);
MPI_File_close (&file_handle);
end_time = MPI_Wtime();
tot_time = end_time - start_time;
MPI_Reduce (&tot_time, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
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);
}
/*****************/
/* VERIFICATION */
/*****************/
for (uint64_t i = 0; i< num_particles; 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);
}
}
if (0 == sub_myrank)
fprintf (stdout, GREEN "[INFO]" RESET " [%08d] Content verified and consistent\n", mycolor);
/*****************/
/* FREE */
/*****************/
delete [] xx;
delete [] xx_r;
MPI_Finalize ();
}
#!/bin/bash
NODES=4
PPN=2
NPROCS=$((NODES*PPN))
TARGET="/projects/visualization/ftessier/debug"
cd $HOME/TAPIOCA/examples/1D-Array
export TAPIOCA_DEVNULL=false
export TAPIOCA_COMMSPLIT=true
export TAPIOCA_STRATEGY=TOPOLOGY_AWARE
export TAPIOCA_NBAGGR=1
export TAPIOCA_BUFFERSIZE=1048576
export TAPIOCA_PIPELINING=true
function updateSettings()
{
printenv | egrep "TAPIOCA_"
SETTINGS="TAPIOCA_DEVNULL=$TAPIOCA_DEVNULL"
SETTINGS="$SETTINGS TAPIOCA_COMMSPLIT=$TAPIOCA_COMMSPLIT"
SETTINGS="$SETTINGS TAPIOCA_STRATEGY=$TAPIOCA_STRATEGY"
SETTINGS="$SETTINGS TAPIOCA_NBAGGR=$TAPIOCA_NBAGGR"
SETTINGS="$SETTINGS TAPIOCA_BUFFERSIZE=$TAPIOCA_BUFFERSIZE"
SETTINGS="$SETTINGS TAPIOCA_PIPELINING=$TAPIOCA_PIPELINING"
SETTINGS="$SETTINGS PAMID_VERBOSE=1"
SETTINGS="$SETTINGS PAMID_COLLECTIVES_MEMORY_OPTIMIZED=1"
SETTINGS="$SETTINGS PAMID_COLLECTIVES=1"
SETTINGS="$SETTINGS BG_SHAREDMEMSIZE=64"
SETTINGS="$SETTINGS BGLOCKLESSMPIO_F_TYPE=0x47504653"
SETTINGS="$SETTINGS GPFSMPIO_BALANCECONTIG=1"
SETTINGS="$SETTINGS GPFSMPIO_P2PCONTIG=1"
}
function outputFile ()
{
OUTPUT="$HOME/TAPIOCA/examples/1D-Array/$1"
OUTPUT="${OUTPUT}_${NODES}_${PPN}_${PARTICLES}_${TAPIOCA_NBAGGR}_${TAPIOCA_BUFFERSIZE}_BGQ"
}
PARTICLES=50000
rm $TARGET/*
updateSettings
outputFile "TAPIOCA"
runjob --block $COBALT_PARTNAME --envs $SETTINGS -p $PPN --np $NPROCS : ./main_tapioca $PARTICLES > $OUTPUT
Markdown is supported
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