NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
parallel_perf.c File Reference

Benchmark four-rank collective nxCDF write and read throughput with disk-bound timing. More...

#include <mpi.h>
#include <netcdf.h>
#include <netcdf_par.h>
#include <nep.h>
#include "nxcdf/nxcdf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "perf_disk.h"

Data Structures

struct  row_t
 One benchmark row for one field/type/storage configuration. More...

Macros

#define ROWS   512
#define NX   1536
#define NREPS   10
#define TMP_FILE   "parallel_perf_tmp.nc"
#define ERRCODE   2
#define ERR(e)
#define NCONFIGS   2

Functions

static int run_config (MPI_Comm comm, int rank, int size, int deflate, const float *data, float *rbuf, row_t *row)
 Write and read the slab in one configuration NREPS times.
int main (int argc, char **argv)
 Main entry point.

Detailed Description

Benchmark four-rank collective nxCDF write and read throughput with disk-bound timing.

Each rank owns one contiguous slab of a two-dimensional NC_FLOAT variable and transfers it with nc_put_vara_float()/nc_get_vara_float() under the default (collective for filtered variables, independent otherwise) parallel access. Two storage configurations are timed: contiguous and chunked+shuffle+deflate level 1 (the deflate rows force NC_COLLECTIVE). Every read is checked bit-for-bit against the data written.

Write time covers nc_create_par() through nc_close() plus a rank-0 fsync() of the file (nep_perf_sync_file()), so data has reached the storage device; before each read rank 0 drops the file from the page cache (nep_perf_drop_cache(), untimed) and read time covers nc_open_par() through nc_close(). Each phase ends with an MPI_Allreduce so the reported number is the slowest rank's wall time (MPI_Wtime). NREPS (10) repetitions run per configuration and the minimum times are kept.

Output: CSV written to the path given on the command line, with columns:

ranks,storage,slab_rows,cols,uncompressed_bytes,file_bytes,write_s,read_s,write_MBps,read_MBps

Each row is also printed to stdout on rank 0.

Typical workflow:

mpiexec -n 4 ./parallel_perf parallel_results.csv
./record_parallel_machine.sh build parallel_machine.txt
Note
The program is intended for local performance profiling. It is registered as a ctest test only when NEP_ENABLE_BENCHMARKS=ON together with NEP_ENABLE_NXCDF_PARALLEL. Reference results are measured with -DCMAKE_BUILD_TYPE=RelWithDebInfo (-O2).
Author
Edward Hartnett, Intelligent Data Design, Inc.

Macro Definition Documentation

◆ ERR

#define ERR ( e)
Value:
{fprintf(stderr, "rank %d: %s\n", rank, nc_strerror(e)); \
MPI_Abort(MPI_COMM_WORLD, ERRCODE);}
#define ERRCODE
Definition bfloat16.c:84

◆ ERRCODE

#define ERRCODE   2

◆ NCONFIGS

#define NCONFIGS   2

Number of storage configurations: contiguous, deflate1.

◆ NREPS

#define NREPS   10

Repetitions per configuration; the minimum time is kept.

◆ NX

#define NX   1536

Columns in the variable.

◆ ROWS

#define ROWS   512

Slab rows written by each rank.

◆ TMP_FILE

#define TMP_FILE   "parallel_perf_tmp.nc"

Temporary NetCDF file created for each measurement.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Main entry point.

Fills each rank's slab with a rank-identifying pattern, runs the contiguous and deflate1 configurations and writes one CSV row per configuration on rank 0.

Parameters
argcArgument count; must be 2.
argvargv[1] is the output CSV path.
Returns
0 on success, 1 on verification failure, 2 on usage or NetCDF error.

◆ run_config()

int run_config ( MPI_Comm comm,
int rank,
int size,
int deflate,
const float * data,
float * rbuf,
row_t * row )
static

Write and read the slab in one configuration NREPS times.

For each repetition all ranks create TMP_FILE with nc_create_par(NC_NXCDF | NC_NETCDF4 | NC_CLOBBER) — NC_NETCDF4 is required because upstream nc_create_par() gates on it — define dims row = mpi_size*ROWS and col = NX and one NC_FLOAT variable, collectively write each rank's slab, close and fsync (timed), then drop the page cache (untimed) and collectively read the slab back (timed). The deflate1 configuration is chunked ROWSxNX with shuffle+deflate level 1, which forces collective access.

Parameters
commMPI communicator.
rankThis rank.
sizeNumber of ranks.
deflateNon-zero for shuffle+deflate level 1.
dataThis rank's slab (ROWS*NX floats).
rbufRead-back slab (ROWS*NX floats).
rowResult row to fill in.
Returns
0 on success, 1 on verification failure.