From bcc99d9328d2110c1603b13948aeb72e084e40ef Mon Sep 17 00:00:00 2001 From: James Laird Date: Fri, 1 Apr 2005 09:57:46 -0500 Subject: [svn-r10532] Purpose: Bug fix Description: Ported big.c "overlap" fix to 1.6 branch. Platforms tested: sleipnir, eirene, modi4 --- test/big.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/test/big.c b/test/big.c index c28e047..537f42e 100644 --- a/test/big.c +++ b/test/big.c @@ -29,6 +29,8 @@ const char *FILENAME[] = { #define WRT_SIZE 4*1024 #define FAMILY_SIZE 1024*1024*1024 +#define MAX_TRIES 100 + #if H5_SIZEOF_LONG_LONG >= 8 # define GB8LL ((unsigned long_long)8*1024*1024*1024) #else @@ -38,6 +40,7 @@ const char *FILENAME[] = { /* Protocols */ static void usage(void); +static hsize_t values_used[WRT_N]; /*------------------------------------------------------------------------- * Function: randll @@ -56,13 +59,36 @@ static void usage(void); *------------------------------------------------------------------------- */ static hsize_t -randll(hsize_t limit) +randll(hsize_t limit, int current_index) { - - hsize_t acc = rand (); - acc *= rand (); + hsize_t acc; + int overlap = 1; + int i; + int tries = 0; + + /* Generate up to MAX_TRIES random numbers until one of them */ + /* does not overlap with any previous writes */ + while(overlap != 0 && tries < MAX_TRIES) + { + acc = rand (); + acc *= rand (); + acc = acc % limit; + overlap = 0; + + for(i = 0; i < current_index; i++) + { + if((acc >= values_used[i]) && (acc < values_used[i]+WRT_SIZE)) + overlap = 1; + if((acc+WRT_SIZE >= values_used[i]) && (acc+WRT_SIZE < values_used[i +]+WRT_SIZE)) + overlap = 1; + } + tries++; + } - return acc % limit; + values_used[current_index]=acc; + + return acc; } @@ -240,7 +266,7 @@ writer (hid_t fapl, int wrt_n) hs_size[0] = WRT_SIZE; if ((mem_space = H5Screate_simple (1, hs_size, hs_size))<0) goto error; for (i=0; i