Assignment 7.1

Assignment 7.1

by Joshua Utley -
Number of replies: 1

Hi all, 

I was not able to access the example working code for pi in ptfs100h (I always get a permission denied error), so I made my own version of the code where x is not privatized in the kernel (see below). I ran this as described in the exercise and got results that were completely consistent across all experiments. Even worse, when I "correct" the code by adding private(x) onto the end of the omp pragma, the performance doesn't change. This was the case for the scalar and AVX optimized compiler options. Can anyone explain what I am missing? Also, just for clarity, this code still returns the correct value of pi up to a precision of about 10 digits. 

    double sum =0.0;
    double x =0.0; //race condition in this variable

        #pragma omp parallel for reduction (+:sum)
            for(int i=0; i<N; i++){
                x = (i + 0.5) * delta_x;
                sum += 4.0 * sqrt(1.0 - x * x);
            }


In reply to Joshua Utley

Re: Assignment 7.1

by Jan Laukemann -

Hi Joshua,

we just checked during the tutorial and both me and other students could access ~ptfs100h/GettingStarted/WeirdPi.c without any problem.

I can't think of any issues why

cp ~ptfs100h/GettingStarted/WeirdPi.c ~/

shouldn't work, please provide the command you used including the error.