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/Field/field.c | 78 +++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'dis/Field/field.c') diff --git a/dis/Field/field.c b/dis/Field/field.c index 248f779..900d47b 100644 --- a/dis/Field/field.c +++ b/dis/Field/field.c @@ -86,55 +86,55 @@ int main(int argc, char **argv) { return (-1); randInit(seed); - for (l = 0; l < f; l++) { - field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE); - } - startTime = time(NULL); - START_LOOP + for_each_job { + for (l = 0; l < f; l++) { + field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE); + } - for (l = 0; l < n; l++) { - unsigned int index; + startTime = time(NULL); - token[l].subfields = 0; - token[l].stat[0].count = 0; - token[l].stat[0].sum = 0; - token[l].stat[0].min = MAX_TOKEN_VALUE; + for (l = 0; l < n; l++) { + unsigned int index; - index = 0; - while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)) { - unsigned char offset; - offset = 0; - while ((field[index + offset] == token[l].delimiter[offset]) && - (offset < token[l].length)) { - offset++; - } + token[l].subfields = 0; + token[l].stat[0].count = 0; + token[l].stat[0].sum = 0; + token[l].stat[0].min = MAX_TOKEN_VALUE; - if (offset == token[l].length) { - for (offset = 0; offset < token[l].length; offset++) { - field[index + offset] = (field[index + offset] + - field[(index + offset + mod_offset) % f]) % - (MAX_TOKEN_VALUE + 1); + index = 0; + while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)) { + unsigned char offset; + offset = 0; + while ((field[index + offset] == token[l].delimiter[offset]) && + (offset < token[l].length)) { + offset++; } - index += token[l].length - 1; - token[l].subfields++; - token[l].stat[token[l].subfields].count = 0; - token[l].stat[token[l].subfields].sum = 0; - token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE; - } - else { - token[l].stat[token[l].subfields].count++; - token[l].stat[token[l].subfields].sum += field[index]; - if (token[l].stat[token[l].subfields].min > field[index]) - token[l].stat[token[l].subfields].min = field[index]; + if (offset == token[l].length) { + for (offset = 0; offset < token[l].length; offset++) { + field[index + offset] = (field[index + offset] + + field[(index + offset + mod_offset) % f]) % + (MAX_TOKEN_VALUE + 1); + } + index += token[l].length - 1; + token[l].subfields++; + token[l].stat[token[l].subfields].count = 0; + token[l].stat[token[l].subfields].sum = 0; + token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE; + } + + else { + token[l].stat[token[l].subfields].count++; + token[l].stat[token[l].subfields].sum += field[index]; + if (token[l].stat[token[l].subfields].min > field[index]) + token[l].stat[token[l].subfields].min = field[index]; + } + index++; } - index++; + token[l].subfields++; } - token[l].subfields++; } - - STOP_LOOP endTime = time(NULL); volatile int sumAll = 0; -- cgit v1.2.2