cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

arkanet
Adept I

Re: Possible problem with atomic_cmpxchg?

Jump to solution

Nope

The problem still persists.

I'm trying to build a repro case, if it is possible.

0 Likes
arkanet
Adept I

Re: Re: Possible problem with atomic_cmpxchg?

Jump to solution

I've built a small repro case, based on my matrices (in MS Visual Studio 2008, Radeon HD 7970)

As you'll see, the code breaks at different values of variable j, despite it is expected to print "Success", the case which never happens. At least on my PC.

Thanks for helping me.

(Attachment has been edited)

0 Likes
himanshu_gautam
Grandmaster

Re: Possible problem with atomic_cmpxchg?

Jump to solution

It is a problem with the way you are comparing the results. Floats cannot be compared like ints, you need to give a error_threshold that would depend on how big the stored numbers are. Your code seems to be working fine.

Just try printf("iteration: %d Current Sum:%f, Older sum:%f\n", j, rSum, SrSum); and see how close the results actually are.

0 Likes
arkanet
Adept I

Re: Possible problem with atomic_cmpxchg?

Jump to solution

I do not think the comparison method is the problem. It MUST give the same results. but I've found a new issue. change the if to:

if (SrSum!=rSum) {

  printf("%d\t%f\n", j, SrSum-rSum);

  SrSum=rSum;

  //TerM("Error Found!");

  }

in my machine, different values of j are printed, and the value of (SrSum-rSum) is always -32.000000 or 32.000000 !

The difference value is very high, specially in iterative solutions it will make a good algorithm to a not working one.

0 Likes
himanshu_gautam
Grandmaster

Re: Possible problem with atomic_cmpxchg?

Jump to solution

Check the SrSum value it is a 9 digit number for me. compared to which 32 is negligible.

0 Likes
arkanet
Adept I

Re: Possible problem with atomic_cmpxchg?

Jump to solution

Yes, it is. I was comparing the (SrSum-rSum)/rSum with machine epsilon of float, and they are in the same magnitude. It's a numerical error, or for we petroleum engineers, a "Numerical Dispersion".


Thanks so much.

0 Likes