|
|
|
|
|
by kloch
1697 days ago
|
|
I did tests on Kahan summation recently on my macbook pro and -O3 defeated the algorithm while -O2 did not. Declaring the below variables as volatile restored error compensation with -O3. The relevant code is: kahan_y=g_sample_z - kahan_c;
kahan_t=g_sample_z_sum + kahan_y;
kahan_c=(kahan_t - g_sample_z_sum) - kahan_y;
g_sample_z_sum=kahan_t;
(this is in an inner loop where a new g_sample_z is calculated and then added to a running g_sample_z_sum with this snippet) |
|