/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * Friday, Oct 3, 2004 * * Purpose: Tests performance of metadata */ #include "h5test.h" #ifdef H5_HAVE_PARALLEL #define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ #endif /*H5_HAVE_PARALLEL*/ /* File_Access_type bits */ #define FACC_DEFAULT 0x0 /* serial as default */ #define FACC_MPIO 0x1 /* MPIO */ /* Which test to run */ int RUN_TEST = 0x0; /* all tests as default */ int TEST_1 = 0x1; /* Test 1 */ int TEST_2 = 0x2; /* Test 2 */ int TEST_3 = 0x4; /* Test 3 */ const char *FILENAME[] = { "meta_perf_1", "meta_perf_2", "meta_perf_3", NULL }; /* Default values for performance. Can be changed through command line options */ int NUM_DSETS = 16; int NUM_ATTRS = 8; int BATCH_ATTRS = 2; hbool_t flush_dset = FALSE; hbool_t flush_attr = FALSE; int nerrors = 0; /* errors count */ hid_t fapl; /* Data space IDs */ hid_t space; hid_t small_space; /* Performance data */ typedef struct p_time { double total; double avg; double max; double min; double start; char func[32]; } p_time; /*Test file access type for parallel. MPIO as default */ int facc_type = FACC_DEFAULT; double retrieve_time(void); void perf(p_time *perf_t, double start_t, double end_t); void print_perf(p_time, p_time, p_time); /*------------------------------------------------------------------------- * Function: parse_options * Purpose: Parse command line options * * Programmer: Raymond Lu * Friday, Oct 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static int parse_options(int argc, char **argv) { int t; /* Use default values */ if(argc==1) return(0); while (--argc){ if (**(++argv) != '-'){ break; }else{ switch(*(*argv+1)){ case 'h': /* Help page */ return(1); case 'd': /* Number of datasets */ NUM_DSETS = atoi((*argv+1)+1); if (NUM_DSETS < 0){ nerrors++; return(1); } break; case 'a': /* Number of attributes per dataset */ NUM_ATTRS = atoi((*argv+1)+1); if (NUM_ATTRS < 0){ nerrors++; return(1); } break; case 'n': /* Number of attributes to be created in batch */ BATCH_ATTRS = atoi((*argv+1)+1); if (BATCH_ATTRS < 0){ nerrors++; return(1); } break; case 'm': /* Use the MPI-IO driver */ facc_type = FACC_MPIO; break; case 'f': /* Call H5Fflush for each dataset or attribute */ if(!strcmp("a", (*argv+2))) flush_attr = TRUE; else if(!strcmp("d", (*argv+2))) flush_dset = TRUE; else { nerrors++; return(1); } break; case 't': /* Which test to run */ t = atoi((*argv+1)+1); if (t < 1 || t > 3){ nerrors++; return(1); } if(t == 1) RUN_TEST |= TEST_1; else if(t == 2) RUN_TEST |= TEST_2; else RUN_TEST |= TEST_3; break; default: nerrors++; return(1); } } } /*while*/ /* Check valid values */ #ifndef H5_HAVE_PARALLEL if(facc_type == FACC_MPIO) { nerrors++; return(1); } #endif /*H5_HAVE_PARALLEL*/ if(NUM_ATTRS && !BATCH_ATTRS) NUM_ATTRS = 0; if(!NUM_ATTRS && BATCH_ATTRS) BATCH_ATTRS = 0; if(!NUM_DSETS) { nerrors++; return(1); } if(NUM_ATTRS && BATCH_ATTRS) { if(BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { nerrors++; return(1); } } return(0); } /*------------------------------------------------------------------------- * Function: usage * Purpose: Prints help page * * Programmer: Raymond Lu * Friday, Oct 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static void usage(void) { printf("Usage: perf_meta [-h] [-m] [-d]" "[-a]\n" "\t[-n] [-f