From 1120161286ee5c855b630bccc9e0b37bb8a3ee65 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Sat, 17 Oct 2020 19:07:11 -0400 Subject: Fix DIS coding style by running them all through clang-format Also fixes a missing header in DISstressmarkRNG.h and the "all" make target. No functional changes. --- dis/Pointer/DISstressmarkRNG.h | 1 + dis/Pointer/pointer.c | 225 ++++++++++++++++++++--------------------- 2 files changed, 113 insertions(+), 113 deletions(-) (limited to 'dis/Pointer') diff --git a/dis/Pointer/DISstressmarkRNG.h b/dis/Pointer/DISstressmarkRNG.h index 4aa2620..6243606 100644 --- a/dis/Pointer/DISstressmarkRNG.h +++ b/dis/Pointer/DISstressmarkRNG.h @@ -1,3 +1,4 @@ +#include #include #define IA 16807 diff --git a/dis/Pointer/pointer.c b/dis/Pointer/pointer.c index 3fc7248..3f3eefb 100644 --- a/dis/Pointer/pointer.c +++ b/dis/Pointer/pointer.c @@ -1,26 +1,26 @@ /* * Sample code for the DIS Pointer Stressmark * - * This source code is the completely correct source code based on - * the example codes provided by Atlantic Aerospace Division, Titan + * This source code is the completely correct source code based on + * the example codes provided by Atlantic Aerospace Division, Titan * Systems Corporation, 2000. - * - * If you just compile and generate the executables from this source - * code, this code would be enough. However, if you wish to get a complete + * + * If you just compile and generate the executables from this source + * code, this code would be enough. However, if you wish to get a complete * understanding of this stressmark, it is strongly suggested that you * read the Benchmark Analysis and Specifications Document Version 1.0 * before going on since the detailed comments are given in this documents. * the comments are not repeated here. */ -#include -#include -#include -#include #include "DISstressmarkRNG.h" #include "extra.h" +#include +#include +#include +#include #define MIN_FIELD_SIZE 16 -#define MAX_FIELD_SIZE (16777216*4) // Modifed from original +#define MAX_FIELD_SIZE (16777216 * 4) // Modifed from original #define MIN_WINDOW_SIZE 1 #define MAX_WINDOW_SIZE 15 #define MIN_HOP_LIMIT 1 @@ -35,7 +35,7 @@ /* * main() */ -int main(int argc, char** argv){ +int main(int argc, char **argv) { unsigned int *field; unsigned long f; @@ -46,116 +46,115 @@ int main(int argc, char** argv){ clock_t startTime, endTime; - struct threadS{ + struct threadS { unsigned long initial; unsigned long minStop; unsigned long maxStop; unsigned long hops; - }*thread; + } * thread; unsigned int l; SET_UP - assert(fscanf(stdin, "%lu %u %lu %ld %u", - &f, &l, &maxhops, &seed, &n) == 5); - - assert ((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); - w = (unsigned int) l; - assert ((w >= MIN_WINDOW_SIZE) && (w <= MAX_WINDOW_SIZE)); - assert (w % 2 == 1); - assert (f > w); - assert ((maxhops >= MIN_HOP_LIMIT) && (maxhops <= MAX_HOP_LIMIT)); - assert ((seed >= MIN_SEED) && (seed <= MAX_SEED)); - - assert ((n >= MIN_THREADS) && (n <= MAX_THREADS)); - if ((thread = (struct threadS *)malloc(n*sizeof(struct threadS))) == NULL) - return (-1); - - for (l=0; l= 0) && (thread[l].initial < f)); - assert ((thread[l].minStop >= 0) && (thread[l].minStop < f)); - assert ((thread[l].maxStop >= 0) && (thread[l].maxStop < f)); - } - - if ((field = (unsigned int *)malloc(f*sizeof(int))) == NULL) - return (-1); - - randInit(seed); - for (l=0; l= minStop) && - (index < maxStop)))){ - - unsigned int ll, lll; - unsigned int max, min; - unsigned int partition; - unsigned int high; - - partition = field[index]; - max = MAX_FIELD_SIZE; - min = 0; - high = 0; - - for (ll=0; ll max) high++; - else if (x > min){ /* start else* */ - partition = x; - balance = 0; - for (lll=ll+1; lll partition) balance++; - }/* end for loop */ - - if (balance+high == w/2) break; - else if (balance+high > w/2){ - min = partition; - }/* end if */ - else { - max = partition; - high++; - }/* end else */ + assert(fscanf(stdin, "%lu %u %lu %ld %u", &f, &l, &maxhops, &seed, &n) == 5); + + assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); + w = (unsigned int)l; + assert((w >= MIN_WINDOW_SIZE) && (w <= MAX_WINDOW_SIZE)); + assert(w % 2 == 1); + assert(f > w); + assert((maxhops >= MIN_HOP_LIMIT) && (maxhops <= MAX_HOP_LIMIT)); + assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); + + assert((n >= MIN_THREADS) && (n <= MAX_THREADS)); + if ((thread = (struct threadS *)malloc(n * sizeof(struct threadS))) == NULL) + return (-1); + + for (l = 0; l < n; l++) { + assert(fscanf(stdin, "%lu %lu %lu", &(thread[l].initial), + &(thread[l].minStop), &(thread[l].maxStop)) == 3); + assert((thread[l].initial >= 0) && (thread[l].initial < f)); + assert((thread[l].minStop >= 0) && (thread[l].minStop < f)); + assert((thread[l].maxStop >= 0) && (thread[l].maxStop < f)); } - if (min == max) break; - } /* end else* */ - index = (partition+hops)%(f-w); - hops++; - }/* end loop ll */ - thread[l].hops = hops; -} /* end while */ -STOP_LOOP - - endTime = time(NULL); - - volatile int _stop_optimizer = thread[l].hops + l; - /*for (l=0; l= minStop) && (index < maxStop)))) { + + unsigned int ll, lll; + unsigned int max, min; + unsigned int partition; + unsigned int high; + + partition = field[index]; + max = MAX_FIELD_SIZE; + min = 0; + high = 0; + + for (ll = 0; ll < w; ll++) { + unsigned int balance; + unsigned int x; + x = field[index + ll]; + + if (x > max) + high++; + else if (x > min) { /* start else* */ + partition = x; + balance = 0; + for (lll = ll + 1; lll < w; lll++) { + if (field[index + lll] > partition) + balance++; + } /* end for loop */ + + if (balance + high == w / 2) + break; + else if (balance + high > w / 2) { + min = partition; + } /* end if */ + else { + max = partition; + high++; + } /* end else */ + } + if (min == max) + break; + } /* end else* */ + index = (partition + hops) % (f - w); + hops++; + } /* end loop ll */ + thread[l].hops = hops; + } /* end while */ + STOP_LOOP + + endTime = time(NULL); + + volatile int _stop_optimizer = thread[l].hops + l; + /*for (l=0; l