[Csnd] reference-manual appendix 32/64bit

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] reference-manual appendix 32/64bit

Robin Gareus
Hello Csounders,

I could not find a contact in the reference manual, so I hope this email
list is appropriate.

In a recent discussion about float-precision someone pointed me to

  https://csound.com/docs/manual/MiscCsound64.html

leading to a heated discussion. To make a long story short, the
information about float error propagation presented there is not correct.

The smallest possible value that is added/removed when rounding with a
23bit mantissa and 1 sign-bit, fixed exponent at 1.0 is 2^-23. Worst
case, each arithmetic float operation will add an error of 2^-23.

The noise added due to rounding errors after N worst-case operations is
20 * log10 (N * (2^-23)) dB.

It requires 8388 worst-case float operations to reach -60dBFS, not 10 as
the manual states in the appendix.

It would be great if you could correct this.

In reality with random, not-additive errors accumulating, millions of
float operation can be safely performed without introducing significant
noise above quantization level.
Suggesting that one should use 64bit double for audio-data when one
performs more than 10 float operations is not helpful.

Thanks,
robin

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] reference-manual appendix 32/64bit

Steven Yi
Hi Robin,

The manual is open source and is community monitored/developed. Writing messages to this list or filing issues on Github works and is appreciated. I looked at the manual page source:


and it looks like the source of the text is from 2008:


If I understand you correctly, the error is that the calculation of 10 is derived linearly rather than logarithmically? 

I haven't thought through the issue deeply, but I would have imagined 8388 worst-case operations happening not-infrequently with feedback and phase accumulators. I also don't know what millions of operations means here without context (i.e., if a million operations happens every buffer, it's a problem, but if it's over 20 seconds, then maybe not an issue). Could you perhaps elaborate on the last part?  

Regardless, that page definitely needs revision. Besides the error in calculation (which looks like it is repeated for the 64-bit case), last I remember, it was actually faster to run 64-bit processing on 64-bit CPUs rather than slower as the page mentions. 

Steven





On Tue, Mar 19, 2019 at 12:12 PM Robin Gareus <[hidden email]> wrote:
Hello Csounders,

I could not find a contact in the reference manual, so I hope this email
list is appropriate.

In a recent discussion about float-precision someone pointed me to

  https://csound.com/docs/manual/MiscCsound64.html

leading to a heated discussion. To make a long story short, the
information about float error propagation presented there is not correct.

The smallest possible value that is added/removed when rounding with a
23bit mantissa and 1 sign-bit, fixed exponent at 1.0 is 2^-23. Worst
case, each arithmetic float operation will add an error of 2^-23.

The noise added due to rounding errors after N worst-case operations is
20 * log10 (N * (2^-23)) dB.

It requires 8388 worst-case float operations to reach -60dBFS, not 10 as
the manual states in the appendix.

It would be great if you could correct this.

In reality with random, not-additive errors accumulating, millions of
float operation can be safely performed without introducing significant
noise above quantization level.
Suggesting that one should use 64bit double for audio-data when one
performs more than 10 float operations is not helpful.

Thanks,
robin

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] reference-manual appendix 32/64bit

Robin Gareus
On 3/20/19 12:39 PM, Steven Yi wrote:
> Hi Robin,
>
> The manual is open source and is community monitored/developed. Writing
> messages to this list or filing issues on Github works and is appreciated.
> I looked at the manual page source:
>
> https://github.com/csound/manual/blob/master/misc/csound64.xml

Thanks. I'll see if I can get in a pull-request for the parts that I'm
confident to change there.

My Csound is a bit rusty and I don't have a clue about Csound internals.
I do however know about CPU architectures and FPUs.

> If I understand you correctly, the error is that the calculation of 10 is
> derived linearly rather than logarithmically?

Yes, but note that the log() is only due to dB scale.

The manual wrongly suggests exponential propagation of the value (shift
error up by 1 bit for each operation).

While actual float error propagation per operation is linear in value.

You don't have to take it from me, either:
"The additive error is roughly equal to the round-off error from a
single operation, multiplied by the total number of operations"
[Smith, Steven W. "The scientist and engineer's guide to digital signal
processing." http://www.dspguide.com/ch4/4.htm ]

> I haven't thought through the issue deeply, but I would have imagined 8388
> worst-case operations happening not-infrequently with feedback and phase
> accumulators.

Now that you mention it, internal state or parameters can benefit from
higher precision; especially with cookbook DSP (biquads for example).

Accumulators obviously accumulate errors; then again if some DSP is
significantly affected by that, the DSP algorithm is not appropriate for
the task at hand and using 64bit instead of 32bit will just be wrong
differently.

> I also don't know what millions of operations means here
> without context (i.e., if a million operations happens every buffer, it's a
> problem, but if it's over 20 seconds, then maybe not an issue). Could you
> perhaps elaborate on the last part?

Since the manual refers to audible (signal/noise) it concerns
operations on the same audio-sample. From input to output, or from
synth-source to output. gain-stages, filters, etc.

> Regardless, that page definitely needs revision. Besides the error in
> calculation (which looks like it is repeated for the 64-bit case), last I
> remember, it was actually faster to run 64-bit processing on 64-bit CPUs
> rather than slower as the page mentions.

Indeed that is a bit misleading.

You can do up to two 32bit vectorized float operations concurrently on a
64bit machine. It can be up to twice as fast do 32bit processing on a
64bit CPU, compared to 64bit double on a 64bit machine. But that would
depend on csound opcodes being vectorized.

ciao,
robin

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here