## Rounding off problem(maybe..)

General OpenMP discussion

### Rounding off problem(maybe..)

Hi! everyone

I parallelized my Molecular dynamics program with openMP.

but its result is different from serial version.

At the beginning of result, it is exactly same as serial version's data.

But after some steps, little differences appeared (from the end of last digit of calculated number).

But they become lager and larger so the final data of my result is far away from serial one.

Although I scanned my code more than hundred time... but I couldn't find any mistakes.

Is it possible that serial and parallel results are different each other?

I think rounding off problem is the cause of the error but it is too big difference.

Han

### Re: Rounding off problem(maybe..)

ARE YOU using some error prorogation algorithm or some kind of numerical integration ? And what is the order of decimal digit is the initial and the final error ?

Thanks
NITTINARORA

### Re: Rounding off problem(maybe..)

Are you doing any reductions within parallel regions (either using reduction clauses or some sort of "roll your own" reductions)? I know that many people have used OpenMP to parallelize Molecular Dynamics programs in the past - so it is possible to do.
ejd

Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

### Re: Rounding off problem(maybe..)

NITTINARORA/

There is no numerical integration algorithm.

I used double precision so initial error starts from decimal digit 10^(-15).

And final result shows at 10^(1).

thanks

ejd/

I used reduction clause and also compared the values between the sum with reduction clause and shared clause.

program 1 - reduction (+:sum)
program 2 - shared (sum0, sum1, sum2) after than sum = sum0 +sum1 +sum2 (0,1 and 2 are thread numbers)

program 1 and 2 show the same result. But different from serial version. (When I use just 1 cpu, it's result is same as serial)

Interestingly, numerical result is different but tendency of particles motion is same.

thanks
Han

### Re: Rounding off problem(maybe..)

You already know what the problem is. If it gives the same result when you have OpenMP and run with 1 thread as it does serially, but different results when you run with multiple threads and you are using reduction, then (assuming everything else is correct) the reduction is causing the "problem". The question is, did your original code do anything to handle this type of round-off error? If not, then you could have seen the same problem with your current code if the order in which you handled the molecules were different.

I am afraid that I have no magic to fix this type of problem. You either have to devise a way to handle the order of magnitude difference problem that is causing the round-off in a way that works for parallel or not do the reduction work in parallel. You might be able to use an ordered section - but depending on your code that might not give you any better performance than running it serially. It is either one of these or live with the difference in results.

As a side note - depending on the OpenMP implementation, your result could be different for every run depending on how the implementation does the reduction. Some implementations (like Sun's) will give you the same result for reduction each time (when using a static schedule). The reason is that we use a tree algorithm for doing the reduction, so the same nodes are added in the same order each time.

Last bumped by Anonymous on Wed Aug 13, 2008 11:18 pm.
ejd

Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

### Who is online

Users browsing this forum: No registered users and 3 guests