// PPLS Exercise 2 Starter File // // See the exercise sheet for details // // Note that NITEMS, NTHREADS and SHOWDATA should // be defined at compile time with -D options to gcc. // They are the array length to use, number of threads to use // and whether or not to printout array contents (which is // useful for debugging, but not a good idea for large arrays). #include #include #include // Print a helpful message followed by the contents of an array // Controlled by the value of SHOWDATA, which should be defined // at compile time. Useful for debugging. void showdata (char *message, int *data, int n) { int i; if (SHOWDATA) { printf (message); for (i=0; i10000000) || (NTHREADS>32)) { printf ("So much data or so many threads may not be a good idea! .... exiting\n"); exit(EXIT_FAILURE); } // Create two copies of some random data arr1 = (int *) malloc(NITEMS*sizeof(int)); arr2 = (int *) malloc(NITEMS*sizeof(int)); srand((int)time(NULL)); for (i=0; i