Added missing err_macros.h to tst_nc4perf.c

This commit is contained in:
Ward Fisher 2016-10-25 11:58:24 -06:00
parent c9ca03deee
commit d8c04ead27

View File

@ -1,4 +1,4 @@
/*
/*
Copyright 2009, UCAR/Unidata
See COPYRIGHT file for copying and redistribution conditions.
@ -10,6 +10,7 @@ $Id: tst_nc4perf.c,v 1.4 2009/08/19 15:58:57 ed Exp $
*/
#include "nc_tests.h"
#include "err_macros.h"
#define FILENAME "tst_nc4perf.nc"
#define NDIMS1 2
@ -27,9 +28,9 @@ $Id: tst_nc4perf.c,v 1.4 2009/08/19 15:58:57 ed Exp $
/* This function creates a file with 10 2D variables, no unlimited
* dimension. */
int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
MPI_Info info, int mpi_size, int mpi_rank,
size_t *chunk_size)
int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
MPI_Info info, int mpi_size, int mpi_rank,
size_t *chunk_size)
{
double starttime, endtime, write_time = 0, bandwidth = 0;
int ncid;
@ -37,7 +38,7 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
size_t start[NDIMS1], count[NDIMS1];
float *data;
char file_name[NC_MAX_NAME + 1];
char var_name1[NUMVARS][NC_MAX_NAME + 1] = {"GWa", "JAd", "TJe", "JMa", "JMo",
char var_name1[NUMVARS][NC_MAX_NAME + 1] = {"GWa", "JAd", "TJe", "JMa", "JMo",
"JQA", "AJa", "MVB", "WHH", "JTy"};
int varid1[NUMVARS];
size_t nelems_in;
@ -61,7 +62,7 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
for (t = 0; t < NUM_TRIES; t++)
{
/* Create a netcdf-4 file, opened for parallel I/O. */
if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm,
if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm,
info, &ncid)) ERR;
/* Create two dimensions. */
@ -86,7 +87,7 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
count[1] = DIMSIZE1 / mpi_size;
/* start parallel netcdf4 */
for (i = 0; i < NUMVARS; i++)
for (i = 0; i < NUMVARS; i++)
if (nc_var_par_access(ncid, varid1[i], access_flag)) ERR;
starttime = MPI_Wtime();
@ -99,15 +100,15 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
if (nc_close(ncid)) ERR;
endtime = MPI_Wtime();
if (!mpi_rank)
if (!mpi_rank)
{
bandwidth += ((sizeof(float) * DIMSIZE1 * DIMSIZE2 * NUMVARS) /
bandwidth += ((sizeof(float) * DIMSIZE1 * DIMSIZE2 * NUMVARS) /
((endtime - starttime) * 1024 * 1024)) / NUM_TRIES;
write_time += (endtime - starttime) / NUM_TRIES;
}
}
free(data);
if (!mpi_rank)
if (!mpi_rank)
{
char chunk_string[NC_MAX_NAME + 1] = "";
@ -118,15 +119,15 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
strcat(chunk_string, "contiguous");
/* Print the results. */
printf("%d\t\t%s\t%s\t%d\t\t%dx%d\t\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
(facc_type == NC_MPIIO ? "MPI-IO " : "MPI-POSIX"),
(access_flag == NC_INDEPENDENT ? "independent" : "collective"),
(int)cache_size/MEGABYTE, DIMSIZE1, DIMSIZE2, chunk_string,
write_time, bandwidth, NUM_TRIES);
printf("%d\t\t%s\t%s\t%d\t\t%dx%d\t\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
(facc_type == NC_MPIIO ? "MPI-IO " : "MPI-POSIX"),
(access_flag == NC_INDEPENDENT ? "independent" : "collective"),
(int)cache_size/MEGABYTE, DIMSIZE1, DIMSIZE2, chunk_string,
write_time, bandwidth, NUM_TRIES);
}
/* Delete this file. */
remove(file_name);
remove(file_name);
return 0;
}
@ -134,14 +135,14 @@ int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
/* Both read and write will be tested */
/* Case 2: create four dimensional integer data,
one dimension is unlimited. */
int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
MPI_Info info, int mpi_size, int mpi_rank, size_t *chunk_size)
int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
MPI_Info info, int mpi_size, int mpi_rank, size_t *chunk_size)
{
int ncid, dimuids[NDIMS2], varid2[NUMVARS];
size_t ustart[NDIMS2], ucount[NDIMS2];
float *udata, *tempudata;
char file_name[NC_MAX_NAME + 1];
char var_name2[NUMVARS][NC_MAX_NAME + 1] = {"JKP", "ZTa", "MFi", "FPi", "JBu",
char var_name2[NUMVARS][NC_MAX_NAME + 1] = {"JKP", "ZTa", "MFi", "FPi", "JBu",
"ALi", "AJo", "USG", "RBH", "JAG"};
double starttime, endtime, write_time = 0, bandwidth = 0;
size_t nelems_in;
@ -162,7 +163,7 @@ int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
/* Get the file name. */
sprintf(file_name, "%s/%s", TEMP_LARGE, FILENAME);
/* Set the cache size. */
if (nc_get_chunk_cache(NULL, &nelems_in, &preemption_in)) ERR;
if (nc_set_chunk_cache(cache_size, nelems_in, preemption_in)) ERR;
@ -170,7 +171,7 @@ int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
for (t = 0; t < NUM_TRIES; t++)
{
/* Create a netcdf-4 file. */
if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm, info,
if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm, info,
&ncid)) ERR;
/* Create four dimensions. */
@ -185,7 +186,7 @@ int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
dimuids, &varid2[i])) ERR;
if (nc_enddef(ncid)) ERR;
/* Set up selection parameters */
ustart[0] = 0;
ustart[1] = 0;
@ -214,7 +215,7 @@ int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
if (!mpi_rank)
{
write_time += (endtime - starttime) / NUM_TRIES;
bandwidth += (sizeof(float) * TIMELEN * DIMSIZE1 * DIMSIZE2 * DIMSIZE3 * NUMVARS) /
bandwidth += (sizeof(float) * TIMELEN * DIMSIZE1 * DIMSIZE2 * DIMSIZE3 * NUMVARS) /
((endtime - starttime) * 1024 * 1024 * NUM_TRIES);
}
}
@ -225,21 +226,21 @@ int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm
/* What was our chunking? */
if (chunk_size[0])
sprintf(chunk_string, "%dx%dx%dx%d", (int)chunk_size[0], (int)chunk_size[1],
sprintf(chunk_string, "%dx%dx%dx%d", (int)chunk_size[0], (int)chunk_size[1],
(int)chunk_size[2], (int)chunk_size[3]);
else
strcat(chunk_string, "contiguous");
/* Print our results. */
printf("%d\t\t%s\t%s\t%d\t\t%dx%dx%dx%d\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
(facc_type == NC_MPIIO ? "MPI-IO " : "MPI-POSIX"),
(access_flag == NC_INDEPENDENT ? "independent" : "collective"),
(int)cache_size / MEGABYTE, TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1, chunk_string, write_time,
bandwidth, NUM_TRIES);
printf("%d\t\t%s\t%s\t%d\t\t%dx%dx%dx%d\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
(facc_type == NC_MPIIO ? "MPI-IO " : "MPI-POSIX"),
(access_flag == NC_INDEPENDENT ? "independent" : "collective"),
(int)cache_size / MEGABYTE, TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1, chunk_string, write_time,
bandwidth, NUM_TRIES);
}
/* Delete this file. */
remove(file_name);
remove(file_name);
return 0;
}
@ -262,11 +263,11 @@ int main(int argc, char **argv)
int mpi_size, mpi_rank;
int mpi_mode[NUM_MODES] = {NC_MPIIO, NC_MPIPOSIX};
int facc_type[NUM_FACC] = {NC_INDEPENDENT, NC_COLLECTIVE};
size_t chunk_size_2d[NUM_CHUNK_COMBOS_2D][NDIMS1] = {{0, 0},
size_t chunk_size_2d[NUM_CHUNK_COMBOS_2D][NDIMS1] = {{0, 0},
{DIMSIZE2, DIMSIZE1},
{DIMSIZE2/2 + 1, DIMSIZE1 / 2}};
size_t chunk_size_4d[NUM_CHUNK_COMBOS_4D][NDIMS2] = {{0, 0, 0, 0},
{1, DIMSIZE3, DIMSIZE2, DIMSIZE1},
size_t chunk_size_4d[NUM_CHUNK_COMBOS_4D][NDIMS2] = {{0, 0, 0, 0},
{1, DIMSIZE3, DIMSIZE2, DIMSIZE1},
{TIMELEN / 2, DIMSIZE3 / 2 + 1, DIMSIZE2 / 2 + 1, DIMSIZE1 / 2},
{TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1}};
size_t cache_size[NUM_CACHE_SIZES] = {MEGABYTE, 32 * MEGABYTE, 64 * MEGABYTE};
@ -280,7 +281,7 @@ int main(int argc, char **argv)
/* Check for invalid number of processors. */
if ((float)DIMSIZE1 / mpi_size != (int)(DIMSIZE1 / mpi_size))
{
printf("%d divided by number of processors must be a whole number!\n",
printf("%d divided by number of processors must be a whole number!\n",
DIMSIZE1);
return -1;
}
@ -296,17 +297,17 @@ int main(int argc, char **argv)
for (m = 0; m < NUM_MODES; m++)
for (f = 0; f < NUM_FACC; f++)
for (c = 0; c < NUM_CHUNK_COMBOS_2D; c++)
if (test_pio_2d(cache_size[i], mpi_mode[m], facc_type[f], comm,
if (test_pio_2d(cache_size[i], mpi_mode[m], facc_type[f], comm,
info, mpi_size, mpi_rank, chunk_size_2d[c])) ERR;
for (i = 0; i < NUM_CACHE_SIZES; i++)
for (m = 0; m < NUM_MODES; m++)
for (f = 0; f < NUM_FACC; f++)
for (c = 0; c < NUM_CHUNK_COMBOS_4D; c++)
if (test_pio_4d(cache_size[i], mpi_mode[m], facc_type[f], comm,
info, mpi_size, mpi_rank, chunk_size_4d[c])) ERR;
if (test_pio_4d(cache_size[i], mpi_mode[m], facc_type[f], comm,
info, mpi_size, mpi_rank, chunk_size_4d[c])) ERR;
if (!mpi_rank)
if (!mpi_rank)
SUMMARIZE_ERR;
MPI_Finalize();
@ -315,4 +316,3 @@ int main(int argc, char **argv)
return 0;
}