From 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Mon, 19 Oct 2020 01:30:29 -0400 Subject: Enable internal DIS job looping and port to new extra.h API Changes to DIS code: - field, pointer, transitive, and update's random initialization steps moved the main job loop (so that they run on fresh state each job). - Moved free() calls outside of the job loop in matrix - Removed loose clock() call in pointer Misc fixes: - Added input file for neighborhood - Log status before, rather than after, printing in gen_input.py --- dis/Pointer/pointer.c | 121 +++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 61 deletions(-) (limited to 'dis/Pointer') diff --git a/dis/Pointer/pointer.c b/dis/Pointer/pointer.c index 3f3eefb..d97f276 100644 --- a/dis/Pointer/pointer.c +++ b/dis/Pointer/pointer.c @@ -82,68 +82,67 @@ int main(int argc, char **argv) { return (-1); randInit(seed); - for (l = 0; l < f; l++) { - field[l] = randInt(0, f - w); - } - startTime = time(NULL); - clock(); - - START_LOOP - for (l = 0; l < n; l++) { - unsigned int index; - unsigned int minStop, maxStop; - unsigned int hops; - - hops = 0; - minStop = thread[l].minStop; - maxStop = thread[l].maxStop; - index = thread[l].initial; - while ((hops < maxhops) && (!((index >= 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; + for_each_job { + for (l = 0; l < f; l++) { + field[l] = randInt(0, f - w); + } + startTime = time(NULL); + + for (l = 0; l < n; l++) { + unsigned int index; + unsigned int minStop, maxStop; + unsigned int hops; + + hops = 0; + minStop = thread[l].minStop; + maxStop = thread[l].maxStop; + index = thread[l].initial; + while ((hops < maxhops) && (!((index >= 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++; - } /* 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 + 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 */ + } endTime = time(NULL); -- cgit v1.2.2