#include <stdio.h>
#include <time.h>
#include <sys/types.h>

#define COUNT 1000000U // the default is 1 million, but use 1000000000U (1 billion count) for parallel version

extern double drand48();
static double GetRandDouble(void) { return drand48(); }

void PerformSum(void) {
    unsigned i, iters=COUNT;
    double realSum = 0.0;
    // create a separate variable (or array) that will contain threaded sums, and compare the result to realSum
    for(i=0; i<=iters; i++) { // parallelize across this loop
	double r = GetRandDouble();
	realSum += r;
    }
    printf("sum is %.16f\n", realSum);
}

int main(){
    PerformSum();
}
