/* * Sample code for the DIS Transitive Stressmark * * 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 * 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. * * CHANGELOG: * Joshua Bakita, 05/30/2020: Fixed out-of-bounds randInt call */ #include "DISstressmarkRNG.h" #include "extra.h" #include #include #include #include #define MIN_VERTICES 8 #define MAX_VERTICES 16384 #define MIN_EDGES 0 #define MAX_EDGES 268435456 #define MIN_SEED -2147483647 #define MAX_SEED -1 #define NO_PATH 2147483647 #define MIN_EDGS 0 #define MAX_EDGE 255 /* * main() */ int main(int argc, char **argv) { unsigned int *din, *dout; unsigned int n; unsigned int m; unsigned int i, j, k; int seed; time_t startTime, stopTime; unsigned int sum; assert(fscanf(stdin, "%d %d %d", &n, &m, &seed) == 3); assert((n >= MIN_VERTICES) && (n <= MAX_VERTICES)); assert((m >= MIN_EDGES) && (m <= MAX_EDGES)); assert(m <= n * n); assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); if ((din = (unsigned int *)malloc(n * n * sizeof(unsigned int))) == NULL) return (-1); if ((dout = (unsigned int *)malloc(n * n * sizeof(unsigned int))) == NULL) return (-1); SET_UP randInit(seed); for_each_job { for (i = 0; i < n * n; i++) { *(din + i) = NO_PATH; *(dout + i) = NO_PATH; } for (k = 0; k < m; k++) { i = randInt(0, n - 1); j = randInt(0, n - 1); *(din + j * n + i) = randInt(MIN_EDGES, MAX_EDGES); } startTime = time(NULL); for (k = 0; k < n; k++) { unsigned int old; unsigned int new1; unsigned int *dtemp; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { old = *(din + j * n + i); new1 = *(din + j * n + k) + *(din + k * n + i); *(dout + j * n + i) = (new1 < old ? new1 : old); assert(*(dout + j * n + i) <= NO_PATH); assert(*(dout + j * n + i) <= *(din + j * n + i)); } } dtemp = dout; dout = din; din = dtemp; } } stopTime = time(NULL); volatile int _stop_optimizer = 0; for (j = 0; j < n; j++) { sum = 0; for (i = 0; i < n; i++) { if (*(din + j * n + i) != NO_PATH) sum += *(din + j * n + i); } _stop_optimizer += sum; //fprintf(stdout, "%u ", sum); } for (i = 0; i < n; i++) { sum = 0; for (j = 0; j < n; j++) { if (*(din + j * n + i) != NO_PATH) sum += *(din + j * n + i); } _stop_optimizer += sum; //fprintf(stdout, "%u ", sum); } fprintf(stderr, "time for transitive stressmark = %f seconds.\n", difftime(stopTime, startTime)); free(din); free(dout); WRITE_TO_FILE return (0); }