Re: [PD] different float accuracy betw. Pd-0.52-1-msw-i386 and Pd-0.52-1-msw-amd64

2022-02-11 Thread Miller Puckette via Pd-list
Just to ad tothe confusion ... I'm running tests ("reality check") to see
of Pd runs musical pieces the same way on diffrent machines.  I found that
AMD64 Pd on linux and on MacOS (both 64-bit Intel CPUs) gave slightly
different results, off by less thatn a part in a million (10^-6 error).
But.. the MacOS test gave the identical same result as a Raspberry Pi, which
is in 32 bits and has an ARM processor.

I _think_ linux and MACOS are setting different rounding modes in the
processor, but haven't takent the time to try to figure it out.

cheers
Miller

On Fri, Feb 11, 2022 at 11:25:26PM +0100, Christof Ressi wrote:
> > However, what worries me is that if I run a Pd vanilla patch on
> > different Pd versions (i386 or amd64) with the same floating point
> > precision, I expect the same results.
> Generally, you can't really expect that. Even without -ffast-math, different
> CPU architectures or instruction sets will give slightly different results
> (unless you jump through various hoops).
> 
> Here's an interesting article by a game developer: 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__gafferongames.com_post_floating-5Fpoint-5Fdeterminism_&d=DwICAg&c=-35OiAkTchMrZOngvJPOeA&r=XprZV3Fxus2L1LCw80hE4Q&m=APlmOH6-SnFCR7Jvr5B5Sup5Bjb4le7rctP34Mrr9Y-4wQA2jiIang6E8-_797z3&s=uDkC4rfduQLn3ViZe_SQnSi3i6yQHuLVgwGP64klfN4&e=
> 
> Usually, these errors are very small, but with (suboptimal) recursive
> algorithms they can get amplified significantly. Your patch is a very
> striking demonstration of the problems with the direct 2 form of the biquad
> filter :-)
> 
> Christof
> 
> On 11.02.2022 23:11, mu...@iem.at wrote:
> > 
> > Zitat von Christof Ressi :
> > 
> > > That's only half the story. Generally, one shouldn't expect floating
> > > point computations to yield the exact same result with different
> > > compilers/machines. The rounding errors themselves are very small,
> > > but they can accumulate over long periods of time or get amplified
> > > by recursive algorithms.
> > > I've made an alternative implementation [biquad2~] that uses direct
> > > form 1. It shows significantly less noise than the [biquad~]
> > > examples. See attachments.
> > 
> > That's right what you wrote.
> > However, what worries me is that if I run a Pd vanilla patch on
> > different Pd versions (i386 or amd64) with the same floating point
> > precision, I expect the same results.
> > 
> > e.g. the test patch running on Pd-0.52-1-xxx-i386 produces -60dB low
> > frequency spikes, the identical patch running on Pd-0.52-1-xxx-amd64
> > produces -34dB high frequency bursts. And that's a realistic simple
> > situation, a microphone signal feeds a 3rd order high pass filter.
> > 
> > Thomas Musil
> > 
> > 
> > 
> > 
> > ___
> > Pd-list@lists.iem.at mailing list
> > UNSUBSCRIBE and account-management -> 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.puredata.info_listinfo_pd-2Dlist&d=DwICAg&c=-35OiAkTchMrZOngvJPOeA&r=XprZV3Fxus2L1LCw80hE4Q&m=APlmOH6-SnFCR7Jvr5B5Sup5Bjb4le7rctP34Mrr9Y-4wQA2jiIang6E8-_797z3&s=vRvKjb8aoxutgyCOdjzRXK3d2PruXTybxAlF26kcRO0&e=
> 
> 
> 
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.puredata.info_listinfo_pd-2Dlist&d=DwICAg&c=-35OiAkTchMrZOngvJPOeA&r=XprZV3Fxus2L1LCw80hE4Q&m=APlmOH6-SnFCR7Jvr5B5Sup5Bjb4le7rctP34Mrr9Y-4wQA2jiIang6E8-_797z3&s=vRvKjb8aoxutgyCOdjzRXK3d2PruXTybxAlF26kcRO0&e=



___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] different float accuracy betw. Pd-0.52-1-msw-i386 and Pd-0.52-1-msw-amd64

2022-02-11 Thread Christof Ressi
However, what worries me is that if I run a Pd vanilla patch on 
different Pd versions (i386 or amd64) with the same floating point 
precision, I expect the same results. 
Generally, you can't really expect that. Even without -ffast-math, 
different CPU architectures or instruction sets will give slightly 
different results (unless you jump through various hoops).


Here's an interesting article by a game developer: 
https://gafferongames.com/post/floating_point_determinism/


Usually, these errors are very small, but with (suboptimal) recursive 
algorithms they can get amplified significantly. Your patch is a very 
striking demonstration of the problems with the direct 2 form of the 
biquad filter :-)


Christof

On 11.02.2022 23:11, mu...@iem.at wrote:


Zitat von Christof Ressi :

That's only half the story. Generally, one shouldn't expect floating 
point computations to yield the exact same result with different 
compilers/machines. The rounding errors themselves are very small, 
but they can accumulate over long periods of time or get amplified by 
recursive algorithms.
I've made an alternative implementation [biquad2~] that uses direct 
form 1. It shows significantly less noise than the [biquad~] 
examples. See attachments.


That's right what you wrote.
However, what worries me is that if I run a Pd vanilla patch on 
different Pd versions (i386 or amd64) with the same floating point 
precision, I expect the same results.


e.g. the test patch running on Pd-0.52-1-xxx-i386 produces -60dB low 
frequency spikes, the identical patch running on Pd-0.52-1-xxx-amd64 
produces -34dB high frequency bursts. And that's a realistic simple 
situation, a microphone signal feeds a 3rd order high pass filter.


Thomas Musil




___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list




___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] different float accuracy betw. Pd-0.52-1-msw-i386 and Pd-0.52-1-msw-amd64

2022-02-11 Thread musil


Zitat von Christof Ressi :

That's only half the story. Generally, one shouldn't expect floating  
point computations to yield the exact same result with different  
compilers/machines. The rounding errors themselves are very small,  
but they can accumulate over long periods of time or get amplified  
by recursive algorithms.
I've made an alternative implementation [biquad2~] that uses direct  
form 1. It shows significantly less noise than the [biquad~]  
examples. See attachments.


That's right what you wrote.
However, what worries me is that if I run a Pd vanilla patch on  
different Pd versions (i386 or amd64) with the same floating point  
precision, I expect the same results.


e.g. the test patch running on Pd-0.52-1-xxx-i386 produces -60dB low  
frequency spikes, the identical patch running on Pd-0.52-1-xxx-amd64  
produces -34dB high frequency bursts. And that's a realistic simple  
situation, a microphone signal feeds a 3rd order high pass filter.


Thomas Musil



#N canvas 83 63 1345 798 12;
#N canvas 0 50 801 679 hp_3.order_butterworth_@_20_Hz 0;
#X obj 83 52 inlet~;
#X obj 83 597 outlet~;
#X text 76 617 signal out;
#X text 74 33 signal in;
#X obj 83 500 biquad~ 1.99715 -0.997155 0.998575 -1.99715 0.998575
;
#X obj 83 561 biquad~ 0.997154 0 0.998577 -0.998577 0;
#X obj 336 51 inlet;
#X obj 525 38 loadbang;
#N canvas 0 50 654 536 freq_Q_transform 0;
#X obj 77 60 inlet;
#X text 79 42 freq;
#X obj 77 357 outlet;
#X obj 104 233 expr 4*atan(1)/$f1;
#X obj 104 209 samplerate~;
#X obj 77 252 * 1;
#X obj 77 277 clip 1e-020 1.57079;
#X obj 240 211 expr 2*atan(1);
#X obj 77 302 expr cos($f1)/sin($f1);
#X obj 240 233 - 1e-007;
#X text 147 336 l a;
#X text 251 254 pi/2;
#X text 120 252 *pi/SR;
#X text 12 3 fq-al : freq Q to l a transformer;
#X obj 510 57 inlet;
#X text 511 38 init;
#X obj 510 82 t b b;
#X obj 77 334 pack 0 1;
#X connect 0 0 5 0;
#X connect 3 0 5 1;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 8 0;
#X connect 7 0 9 0;
#X connect 8 0 17 0;
#X connect 9 0 6 2;
#X connect 14 0 16 0;
#X connect 16 0 4 0;
#X connect 16 1 7 0;
#X connect 17 0 2 0;
#X restore 124 168 pd freq_Q_transform;
#X text 267 168 l a;
#X obj 597 38 r pd-dsp-started;
#X obj 124 196 expr $f1*$f1+1 \; $f1*$f2;
#X text 103 229 l2;
#X text 234 232 al;
#X obj 136 241 expr $f1 \; $f2 \; 1/($f1+$f2);
#X text 99 283 l2;
#X text 185 283 al;
#X text 254 283 rcp;
#X obj 113 448 pack 0 0 0 0 0;
#X text 513 276 rcp;
#X obj 406 420 pack 0 0 0 0 0;
#X obj 427 249 expr $f1 \; 1/($f1+1);
#X text 397 276 l;
#N canvas 259 301 581 451 freq_transform 0;
#X obj 104 283 expr 4*atan(1)/$f1;
#X obj 104 209 samplerate~;
#X obj 77 302 * 1;
#X obj 77 60 inlet;
#X text 79 42 freq;
#X obj 77 327 clip 1e-020 1.57079;
#X obj 240 211 expr 2*atan(1);
#X obj 77 352 expr cos($f1)/sin($f1);
#X obj 240 283 - 1e-007;
#X text 131 389 l;
#X text 251 304 pi/2;
#X text 120 302 *pi/SR;
#X obj 77 388 outlet;
#X obj 164 131 t b b;
#X floatatom 125 242 5 0 0 0 - - -;
#X obj 164 62 inlet;
#X text 163 43 init;
#X connect 0 0 2 1;
#X connect 1 0 0 0;
#X connect 1 0 14 0;
#X connect 2 0 5 0;
#X connect 3 0 2 0;
#X connect 5 0 7 0;
#X connect 6 0 8 0;
#X connect 7 0 12 0;
#X connect 8 0 5 2;
#X connect 13 0 1 0;
#X connect 13 1 6 0;
#X connect 15 0 13 0;
#X restore 427 213 pd freq_transform;
#X text 553 211 l;
#X obj 525 68 t b b;
#X obj 113 299 expr 2*$f3*($f1-2) \; $f3*($f2-$f1) \; $f3*($f1-1) \;
-2*$f3*($f1-1) \; $f3*($f1-1);
#X obj 406 297 expr ($f1-1)*$f2 \; $f1*$f2 \; -$f1*$f2;
#X msg 720 38 bang;
#N canvas 169 171 504 523 stability 0;
#X obj 87 43 inlet;
#X obj 89 339 outlet;
#X msg 124 148 -1 2e-007;
#X obj 124 173 +;
#X obj 146 234 +;
#X msg 146 209 1 -2e-007;
#X obj 87 265 max -1;
#X obj 87 291 min 1, f 9;
#X obj 124 123 t b b, f 6;
#X obj 126 94 loadbang;
#X text 92 15 fb1;
#X text 92 370 fb1;
#X text 178 255 if(fb1 <= -0.999 9998) \; ..fb1 = -0.999 9998 \; else
if(fb1 >= 0.999 9998) \; ..fb1 = 0.999 9998 \;;
#X connect 0 0 6 0;
#X connect 2 0 3 0;
#X connect 3 0 6 1;
#X connect 4 0 7 1;
#X connect 5 0 4 0;
#X connect 6 0 7 0;
#X connect 7 0 1 0;
#X connect 8 0 2 0;
#X connect 8 1 5 0;
#X connect 9 0 8 0;
#X restore 383 357 pd stability check;
#X f 9;
#N canvas 169 171 1356 1002 stability 0;
#X obj 87 53 inlet;
#X obj 87 859 outlet;
#X obj 124 233 +;
#X obj 163 259 +;
#X obj 124 183 t b b, f 6;
#X obj 124 144 loadbang, f 4;
#X text 91 28 fb1;
#X text 90 887 fb1;
#X obj 407 53 inlet;
#X obj 307 859 outlet;
#X msg 444 208 -1 2e-007;
#X obj 444 233 +;
#X obj 483 294 +;
#X msg 483 269 1 -2e-007;
#X obj 407 325 max -1;
#X obj 407 351 min 1, f 11;
#X obj 444 183 t b b, f 6;
#X obj 444 143 loadbang, f 4;
#X text 411 28 fb2;
#X text 310 887 fb2;
#X msg 163 234 2 -4e-007;
#X msg 124 208 -2 4e-007;
#X obj 87 325 max -2;
#X obj 87 351 min 2, f 11;
#X obj 407 80 t f f, f 66;
#X obj 87 113 t f f, f 92;
#X obj 728 230 expr $f1*$f1 + 4*$f2;
#X obj 728 259 >= 0;
#X obj 87 445 route 0 1, f 63;
#X obj 87 391 pack 0 0 0, f 92;
#X obj 87 823 unpack 0 0, f 32;
#X obj 306