Discussion:
[Cs-dev] function tables power-of-2, etc
Matt Ingalls
2006-01-22 19:34:07 UTC
Permalink
is the power-of-2 function table size requirement gone for csound5?

if so, can you PLEASE remove it? the optimization it gives is far
less important than
the convenience of specifying your own size.

ideally, it would be better to have "deferred" size for most GEN
routines --
just give a '0' as the size for most GENS and let the routine
calculate the size.

multichannel tables expanded beyond loscil family would be nice as
well..

Thanks,
Matt;
________________________
matt ingalls
http://sonomatics.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-22 19:43:44 UTC
Permalink
Post by Matt Ingalls
is the power-of-2 function table size requirement gone for csound5?
No, it still exists for most opcodes.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-22 19:50:20 UTC
Permalink
Post by Matt Ingalls
ideally, it would be better to have "deferred" size for most GEN
routines --
just give a '0' as the size for most GENS and let the routine
calculate the size.
I do not entirely understand this. For example, what size would
a "deferred" GEN10 automatically use for a sine wave ? 100,
1000000, or what ?


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
matt
2006-01-23 19:22:53 UTC
Permalink
well i said "most" not "all" -- although a reasonable default size for
gen10 would not be that -- i see your other mail and looks like
that is already possible..
Post by Istvan Varga
Post by Matt Ingalls
ideally, it would be better to have "deferred" size for most GEN
routines --
just give a '0' as the size for most GENS and let the routine
calculate the size.
I do not entirely understand this. For example, what size would
a "deferred" GEN10 automatically use for a sine wave ? 100,
1000000, or what ?
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Csound-devel mailing list
https://lists.sourceforge.net/lists/listinfo/csound-devel
-m@
________________________
matt ingalls
http://sfsound.org/matt.html



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Victor NK-X-TODEL918ani
2006-01-22 20:05:41 UTC
Permalink
This would mean re-writing a load of opcodes. I think it's
OK
to have this kind of requirement. Even with so-called
'modern'
synthesis systems (such as supercollider), it exists
(AFAIK).

But of course, you can have opcodes that don't need such
thing. For these any size tables can be used.

What I think would be useful is to allow any size tables to
be created (I don't think this is possible for all GENS)
with
any GEN.

Victor
Post by Matt Ingalls
is the power-of-2 function table size requirement gone for
csound5?
if so, can you PLEASE remove it? the optimization it
gives is far less important than
the convenience of specifying your own size.
ideally, it would be better to have "deferred" size for
most GEN routines --
just give a '0' as the size for most GENS and let the
routine calculate the size.
multichannel tables expanded beyond loscil family would be
nice as well..
Thanks,
Matt;
________________________
matt ingalls
http://sonomatics.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files for problems? Stop! Download the new
AJAX search engine that makes searching your log files as
easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
dat=121642
Post by Matt Ingalls
_______________________________________________
Csound-devel mailing list
https://lists.sourceforge.net/lists/listinfo/csound-devel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-22 20:18:24 UTC
Permalink
Post by Victor NK-X-TODEL918ani
What I think would be useful is to allow any size tables to
be created (I don't think this is possible for all GENS)
with any GEN.
You can do that by using a negative table size; a length
specified this way always includes the guard point (i.e.
a table size parameter of -1025 is equivalent to using
1025, but -1024 is not the same table size as 1024).
Note that some GEN routines may not support this, for
example those that use FFT.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
David Akbari
2006-01-22 21:19:39 UTC
Permalink
I can see where Matt's coming from ...

Personally I would like to see only the table opcode able to accept
table size of deferred length, as I can see the potential problems in
allowing such behavior on the FFT GEN routines, etc.

For example

<CsoundSynthesizer>
<CsInstruments>

sr = 48000
ksmps = 64
nchnls = 2

#define FILE # "/loops/dl_break0.aif" #

itmp ftgen 1, 0, 0, 1, $FILE., 0, 4, 0
;itmp ftgen 1, 0, 131072, 1, $FILE., 0, 4, 0

instr 1

itabsz filelen $FILE.

andx phasor (1 / itabsz)
andx = andx * (itabsz * sr)
a1 table andx, 1
a1 = a1 * 32767

outs a1, a1

endin

</CsInstruments>
<CsScore>
i1 0 10

e
</CsScore>

</CsoundSynthesizer>
Post by Victor NK-X-TODEL918ani
This would mean re-writing a load of opcodes. I think it's
OK
to have this kind of requirement. Even with so-called
'modern'
synthesis systems (such as supercollider), it exists
(AFAIK).
But of course, you can have opcodes that don't need such
thing. For these any size tables can be used.
What I think would be useful is to allow any size tables to
be created (I don't think this is possible for all GENS)
with
any GEN.
Victor
Post by Matt Ingalls
is the power-of-2 function table size requirement gone for
csound5?
if so, can you PLEASE remove it? the optimization it
gives is far less important than
the convenience of specifying your own size.
ideally, it would be better to have "deferred" size for
most GEN routines --
just give a '0' as the size for most GENS and let the
routine calculate the size.
multichannel tables expanded beyond loscil family would be
nice as well..
Thanks,
Matt;
________________________
matt ingalls
http://sonomatics.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Matt Ingalls
2006-01-23 19:20:40 UTC
Permalink
Post by Victor NK-X-TODEL918ani
This would mean re-writing a load of opcodes. I think it's
OK
is that really true? when i looked into this [ about 5 years ago! ]
all i found was some bit-wise operations on index increments for
oscillators and stuff -- it would be no big deal to replace the bit-wise
stuff with a modulo or if statement?
Post by Victor NK-X-TODEL918ani
What I think would be useful is to allow any size tables to
be created (I don't think this is possible for all GENS)
isn't that what i just said?

Matt;
________________________
matt ingalls
http://sonomatics.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-23 20:42:04 UTC
Permalink
Post by Matt Ingalls
is that really true? when i looked into this [ about 5 years ago! ]
all i found was some bit-wise operations on index increments for
oscillators and stuff -- it would be no big deal to replace the bit-wise
stuff with a modulo or if statement?
Simply replacing a & with a % is not enough, as the latter cannot
deal with negative numbers correctly, so you need an additional
if statement to fix that. Also, a % is much slower than a &.
An if statement is again not enough, as you need at least two to
wrap negative numbers, and more to deal with the possibility of
a very large index.
In any case, using the & operator is the simplest and fastest
way to wrap any integer value to a 0..N-1 range, as long as
N is an integer power of two.
Additionally, more changes are needed to clean up any tricky code
that assumes in some (often non-obvious) way a power of two or at
least even table size. There are many possibilities for introducing
bugs, something that is best avoided when a release is just about
to be made.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Matt Ingalls
2006-01-23 20:56:20 UTC
Permalink
Post by Istvan Varga
Post by Matt Ingalls
is that really true? when i looked into this [ about 5 years ago! ]
all i found was some bit-wise operations on index increments for
oscillators and stuff -- it would be no big deal to replace the bit-wise
stuff with a modulo or if statement?
Simply replacing a & with a % is not enough, as the latter cannot
as we say in california, "duh!"
Post by Istvan Varga
deal with negative numbers correctly, so you need an additional
if statement to fix that. Also, a % is much slower than a &.
how much? i seriously doubt it's worth the speed gain..
Post by Istvan Varga
An if statement is again not enough, as you need at least two to
wrap negative numbers, and more to deal with the possibility of
a very large index.
In any case, using the & operator is the simplest and fastest
way to wrap any integer value to a 0..N-1 range, as long as
N is an integer power of two.
but from the user-end it is really inconvenient, and then you have
wasted memory when using large tables.
Post by Istvan Varga
Additionally, more changes are needed to clean up any tricky code
that assumes in some (often non-obvious) way a power of two or at
least even table size. There are many possibilities for introducing
bugs, something that is best avoided when a release is just about
to be made.
well mark it up for the next version then..

IMO, the GENERAL case
should be opcodes that do not expect power-of-2, you can always create
some special optimized opcodes that require power-of-2!

Matt;
________________________
matt ingalls
http://sonomatics.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-23 21:50:04 UTC
Permalink
Post by Matt Ingalls
Post by Istvan Varga
Post by Matt Ingalls
is that really true? when i looked into this [ about 5 years ago! ]
all i found was some bit-wise operations on index increments for
oscillators and stuff -- it would be no big deal to replace the bit-wise
stuff with a modulo or if statement?
Simply replacing a & with a % is not enough, as the latter cannot
as we say in california, "duh!"
Post by Istvan Varga
deal with negative numbers correctly, so you need an additional
if statement to fix that. Also, a % is much slower than a &.
how much? i seriously doubt it's worth the speed gain..
With two buils that are identical except one uses & in the
oscil.kk opcode, while another uses %, trapped.csd renders
about 20% slower on my machine. Note that this is the result
of changing a single opcode; the CSD uses many other opcodes
as well, so the slowdown of oscil itself is more significant.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Istvan Varga
2006-01-23 22:40:24 UTC
Permalink
Post by Matt Ingalls
well mark it up for the next version then..
That sounds more reasonable. While I still do not really like
the idea of changing all opcodes, there are cases (mostly when
wrapping is not needed) where the power of two limitation can
be removed easily without any slowdown or major changes.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Richard Dobson
2006-01-23 23:08:47 UTC
Permalink
Post by Istvan Varga
Post by Matt Ingalls
well mark it up for the next version then..
That sounds more reasonable. While I still do not really like
the idea of changing all opcodes, there are cases (mostly when
wrapping is not needed) where the power of two limitation can
be removed easily without any slowdown or major changes.
The issue that would have to be addressed (and whcih I have always seen as the
main obstacle to the proposed changes) is indeed the definition of the guard
point, on which many opcodes rely. In the current scheme, the contents of the
opcode are indicated by the table size being either a pow_of_2 or pow_of_2+1,
relying on the special significance of the pow_of_2 value.

How does a user indicate the guard point when using a non power-of two size? As
soon as this is allowed, 1024 and 1025 cease to have their "special" meanings
(i.e. both indicate a 1024 table, with different guardpoint contents); one might
expect 1025 to mean literally a table size of 1025, PLUS a guard point - the
fgen score statement would seem to need to be revised to include an explicit
field to define it. Eliminating all use of guard points is surely not the end
goal of all this? That would slow down a lot of opcodes! To say nothing of
breaking existing scores.


Richard Dobson




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Victor NK-X-TODEL918ani
2006-01-24 10:14:06 UTC
Permalink
I don't think we should change anything. We can make the oscillators
that use floating-point maths free of the power-of-two requirement, as
well as any other opcode that really does not need that. As far as
guard-points are concerned, a possibility is to implement them in the
opcode and have an extra optional parameter to define them, when the
table is not power-of-two.

Victor
Post by Richard Dobson
Post by Istvan Varga