Skip to content

Commit

Permalink
added another performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Mar 6, 2019
1 parent f87b5e6 commit 91b9b3b
Show file tree
Hide file tree
Showing 5 changed files with 496 additions and 79 deletions.
12 changes: 9 additions & 3 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
/* If this is an IO task write the data. */
if (ios->ioproc)
{
int rrcnt = 0; /* Number of subarray requests (pnetcdf only). */
void *bufptr;
size_t start[fndims];
size_t count[fndims];
int ndims = iodesc->ndims;
#ifdef _PNETCDF
int rrcnt = 0; /* Number of subarray requests (pnetcdf only). */
PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */
PIO_Offset *countlist[num_regions]; /* Array of count arrays for ncmpi_iput_varn(). */
#endif /* _PNETCDF */

/* Process each region of data to be written. */
for (int regioncnt = 0; regioncnt < num_regions; regioncnt++)
Expand Down Expand Up @@ -960,8 +962,12 @@ int recv_and_write_data(file_desc_t *file, const int *varids, const int *frame,
}
}

/* Call the netCDF functions to write the data. */
#ifdef LOGGING
for (int i = 1; i < fndims; i++)
LOG((3, "start[%d] %d count[%d] %d", i, start[i], i, count[i]));
#endif /* LOGGING */

/* Call the netCDF functions to write the data. */
if ((ierr = nc_put_vara(file->fh, varids[nv], start, count, bufptr)))
return check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__);

Expand Down Expand Up @@ -1015,7 +1021,7 @@ int write_darray_multi_serial(file_desc_t *file, int nvars, int fndims, const in
varids[0] <= PIO_MAX_VARS && iodesc, "invalid input", __FILE__, __LINE__);

LOG((1, "write_darray_multi_serial nvars = %d fndims = %d iodesc->ndims = %d "
"iodesc->mpitype = %d", nvars, iodesc->ndims, fndims, iodesc->mpitype));
"iodesc->mpitype = %d", nvars, fndims, iodesc->ndims, iodesc->mpitype));

/* Get the iosystem info. */
ios = file->iosystem;
Expand Down
3 changes: 2 additions & 1 deletion tests/cunit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_darray_multivar3 test_darray_1d test_darray_3d \
test_decomp_uneven test_decomps test_rearr test_darray_async_simple \
test_darray_async test_darray_async_many test_darray_2sync \
test_async_multicomp test_async_multi2 test_async_manyproc \
test_darray_fill test_decomp_frame test_perf1
test_darray_fill test_decomp_frame test_perf1 test_perf2

# Tests will run from a bash script.
TESTS = run_tests.sh
Expand Down Expand Up @@ -60,6 +60,7 @@ test_async_manyproc_SOURCES = test_async_manyproc.c test_common.c pio_tests.h
test_darray_fill_SOURCES = test_darray_fill.c test_common.c pio_tests.h
test_decomp_frame_SOURCES = test_decomp_frame.c test_common.c pio_tests.h
test_perf1_SOURCES = test_perf1.c test_common.c pio_tests.h
test_perf2_SOURCES = test_perf2.c test_common.c pio_tests.h

# Distribute the test script.
EXTRA_DIST = run_tests.sh
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PIO_TESTS='test_intercomm2 test_async_mpi test_spmd test_rearr test_async_simple
'test_darray_multivar test_darray_multivar2 test_darray_multivar3 test_darray_1d '\
'test_darray_3d test_decomp_uneven test_decomps test_darray_async_simple '\
'test_darray_async test_darray_async_many test_darray_2sync test_async_multicomp '\
'test_darray_fill test_perf1'
'test_darray_fill'

success1=true
success2=true
Expand Down
143 changes: 69 additions & 74 deletions tests/cunit/test_perf1.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define Z_DIM_LEN 4

/* The number of timesteps of data to write. */
#define NUM_TIMESTEPS 2
#define NUM_TIMESTEPS 1

/* The number of 4D vars. */
#define NUM_VARS 1
Expand Down Expand Up @@ -122,9 +122,8 @@ do_some_computation(long long int max_i)
}

/**
* Test the darray functionality. Create a netCDF file with 3
* dimensions and 1 PIO_INT variable, and use darray to write some
* data.
* Test the darray functionality. Create a netCDF file with 4
* dimensions and some variables, and use darray to write some data.
*
* @param iosysid the IO system ID.
* @param ioid the ID of the decomposition.
Expand Down Expand Up @@ -164,96 +163,92 @@ int test_perf1(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank,
test_data_double[f] = my_rank * 100000 + f + 0.5;
}

/* Add a couple of extra tests for the
* PIOc_write_darray_multi() function. */
/* Create the filename. */
sprintf(filename, "data_%s_iotype_%d_pio_type_%d_test_multi_%d.nc",
TEST_NAME, flavor[fmt], pio_type, test_multi);

/* Select the fill value and data. */
switch (pio_type)
{
/* Create the filename. */
sprintf(filename, "data_%s_iotype_%d_pio_type_%d_test_multi_%d.nc",
TEST_NAME, flavor[fmt], pio_type, test_multi);
case PIO_INT:
test_data = test_data_int;
break;
case PIO_FLOAT:
test_data = test_data_float;
break;
case PIO_DOUBLE:
test_data = test_data_double;
break;
default:
ERR(ERR_WRONG);
}

/* Select the fill value and data. */
switch (pio_type)
{
case PIO_INT:
test_data = test_data_int;
break;
case PIO_FLOAT:
test_data = test_data_float;
break;
case PIO_DOUBLE:
test_data = test_data_double;
break;
default:
ERR(ERR_WRONG);
}
/* Create the netCDF output file. */
{
if ((ret = PIOc_createfile(iosysid, &ncid, &flavor[fmt], filename, PIO_CLOBBER)))
ERR(ret);

/* Create the netCDF output file. */
/* Define netCDF dimensions. */
for (int d = 0; d < NDIM4; d++)
if ((ret = PIOc_def_dim(ncid, dim_name[d], (PIO_Offset)dim_len[d], &dimids[d])))
ERR(ret);

/* Define the variables. */
for (int v = 0; v < NUM_VARS; v++)
{
if ((ret = PIOc_createfile(iosysid, &ncid, &flavor[fmt], filename, PIO_CLOBBER)))
char var_name[NC_MAX_NAME + 1];
sprintf(var_name, "var_%d", v);
if ((ret = PIOc_def_var(ncid, var_name, pio_type, NDIM4, dimids, &varid[v])))
ERR(ret);
}

/* Define netCDF dimensions. */
for (int d = 0; d < NDIM4; d++)
if ((ret = PIOc_def_dim(ncid, dim_name[d], (PIO_Offset)dim_len[d], &dimids[d])))
ERR(ret);
/* End define mode. */
if ((ret = PIOc_enddef(ncid)))
ERR(ret);
}

/* Define the variables. */
for (int v = 0; v < NUM_VARS; v++)
{
char var_name[NC_MAX_NAME + 1];
sprintf(var_name, "var_%d", v);
if ((ret = PIOc_def_var(ncid, var_name, pio_type, NDIM4, dimids, &varid[v])))
ERR(ret);
}
/* Start the clock. */
gettimeofday(&starttime, NULL);

/* End define mode. */
if ((ret = PIOc_enddef(ncid)))
ERR(ret);
}
for (int t = 0; t < NUM_TIMESTEPS; t++)
{

/* Start the clock. */
gettimeofday(&starttime, NULL);
/* Do some fake computation. */
if ((ret = do_some_computation(100000)))
ERR(ret);

for (int t = 0; t < NUM_TIMESTEPS; t++)
/* Write a timestep of data in each var. */
for (int v = 0; v < NUM_VARS; v++)
{

/* Do some fake computation. */
if ((ret = do_some_computation(100000)))
/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid[v], t)))
ERR(ret);

/* Write a timestep of data in each var. */
for (int v = 0; v < NUM_VARS; v++)
int frame = 0;
int flushtodisk = test_multi - 1;
if (!test_multi)
{
/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid[v], t)))
/* Write the data. */
if ((ret = PIOc_write_darray(ncid, varid[v], ioid, arraylen, test_data, NULL)))
ERR(ret);

int frame = 0;
int flushtodisk = test_multi - 1;
if (!test_multi)
{
/* Write the data. */
if ((ret = PIOc_write_darray(ncid, varid[v], ioid, arraylen, test_data, NULL)))
ERR(ret);
}
}
}
}

/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);
/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);

/* Stop the clock. */
gettimeofday(&endtime, NULL);
/* Stop the clock. */
gettimeofday(&endtime, NULL);

/* Compute the time delta */
startt = (1000000 * starttime.tv_sec) + starttime.tv_usec;
endt = (1000000 * endtime.tv_sec) + endtime.tv_usec;
delta = (endt - startt)/NUM_TIMESTEPS;
if (!my_rank)
printf("%d\t%d\t%d\t%d\t%lld\n", rearranger, fmt, pio_type, test_multi,
delta);
} /* next test multi */
/* Compute the time delta */
startt = (1000000 * starttime.tv_sec) + starttime.tv_usec;
endt = (1000000 * endtime.tv_sec) + endtime.tv_usec;
delta = (endt - startt)/NUM_TIMESTEPS;
if (!my_rank)
printf("%d\t%d\t%d\t%d\t%lld\n", rearranger, fmt, pio_type, test_multi,
delta);

return PIO_NOERR;
}
Expand Down
Loading

0 comments on commit 91b9b3b

Please sign in to comment.