LISTSERV mailing list manager LISTSERV 16.5

Help for CSOUND Archives


CSOUND Archives

CSOUND Archives


CSOUND@LISTSERV.HEANET.IE


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

CSOUND Home

CSOUND Home

CSOUND  August 2018

CSOUND August 2018

Subject:

Re: Csound is a compiler?

From:

Steven Yi <[log in to unmask]>

Reply-To:

A discussion list for users of Csound <[log in to unmask]>

Date:

Sun, 19 Aug 2018 22:52:31 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (145 lines)

Interesting, suppose it's time to profile to see if there's anything
that could be done to improve the speed. Seems like we should be able
to do better than 10-20x slower than native.
On Sun, Aug 19, 2018 at 3:01 PM Mauro Giubileo
<[log in to unmask]> wrote:
>
> I tried that too. Actually, from my experiments, the while-loop version is a little slower than the 'setksmps=1' one. This is the version with the while-loop:
>
> opcode mybiquad, a, akkkkkk
>     aXn, kb0, kb1, kb2, ka0, ka1, ka2 xin
>
>     kXn_1   init    0 ; x[n-1]
>     kXn_2   init    0 ; x[n-2]
>     kYn_1   init    0 ; y[n-1]
>     kYn_2   init    0 ; y[n-2]
>     kn      =       0
>
>     while (kn < ksmps) do
>         ; a0 * y(n) + a1 * y[n-1] + a2 * y[n-2] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2]
>         kXn     =   aXn[kn]
>         kYn     =   (kb0 * kXn + kb1 * kXn_1 + kb2 * kXn_2 - ka1 * kYn_1 - ka2 * kYn_2) / ka0
>         aYn[kn] =   kYn
>         ; let's prepare for next iteration:
>         kXn_2   =   kXn_1
>         kXn_1   =   kXn
>         kYn_2   =   kYn_1
>         kYn_1   =   kYn
>         kn      +=  1
>     od
>
>             xout    aYn
> endop
>
>
> Anyway they are both much slower than the native version.
>
> Regards,
> Mauro
>
>
>
>
> Il 2018-08-19 20:06 Steven Yi ha scritto:
>
> I haven't mesaured, but I would imagine '"setksmps 1" when doing DSP
> code in a UDO to have additional overhead compared to computing
> sample-by-sample in blocks.  Since you are implementing the
> sample-by-sample code yourself, you can do the block code using a
> while-loop, such as in:
>
> https://github.com/kunstmusik/libsyi/blob/master/zdf.udo#L63-L103
> https://github.com/kunstmusik/libsyi/blob/master/tdf2.udo
>
> The code using a loop ends up looking similar to what you'd write in C
> to fill up an asig variable.
>
>
> On Wed, Aug 15, 2018 at 5:33 PM Mauro Giubileo
> <[log in to unmask]> wrote:
>
>
> I think that in many cases the speed increase would be much more bigger than twice. For example, from my experiments, if I use a Csound implementation of the biquad opcode instead of the native one, the performance decreases dramatically... Tens and tens of times slower... Maybe it's my Csound implementation that is wrong, so here it is my biquad udo:
>
> opcode mybiquad, a, akkkkkk
>     aXn, kb0, kb1, kb2, ka0, ka1, ka2 xin
>             setksmps 1
>
>     kXn_1   init    0 ; x[n-1]
>     kXn_2   init    0 ; x[n-2]
>     kYn_1   init    0 ; y[n-1]
>     kYn_2   init    0 ; y[n-2]
>
>     ; a0*y(n) + a1*y[n-1] + a2*y[n-2] = b0*x[n] + b1*x[n-1] + b2*x[n-2]
>     aYn     =       (kb0*aXn + kb1*kXn_1 + kb2*kXn_2 - ka1*kYn_1 - ka2*kYn_2) / ka0
>
>     ; let's prepare for next iteration:
>     kXn_2   =       kXn_1
>     kXn_1   =       aXn[0]
>     kYn_2   =       kYn_1
>     kYn_1   =       aYn[0]
>
>             xout    aYn
> endop
>
>
>
> In my experience the above code is incredibly slower than the native biquad opcode (if the global ksmps=256 it's about 20 times slower!), so, either there is something that is horribly wrong in my implementation, or the Csound tree traversal is much slower than a true native execution (and, consequently, a Csound scripts would greatly benefit from a full compilation in a binary executable).
>
> Regards,
> Mauro
>
>
> Il 2018-08-15 19:43 Michael Gogins ha scritto:
>
> Based on a variety of experiments I've performed over the years, Csound is doing all but the last steps a real computer would do, yes. But in addition to compiling there is optimization and linking, including link time optimization. I think replacing the existing steps after csoundCompileTree with compilation to machine language using LLVM with LTO could double the speed of Csound. Maybe.
>
> On Wed, Aug 15, 2018, 12:55 Forrest Curo <[log in to unmask]> wrote:
>
>
> If each built-in 'opcode' is a chunk of optimized code, & the 'program' that gets interpreted by a csound instance is a string of these... probably we're not very far from something a compiler would produce; we just aren't saving it in that form because we're already running extremely close to what a compiled executable would do in practice, & getting it from a general-purpose piece of software.
> (?)
>
> Forrest
> San Diego
>
> On Wed, Aug 15, 2018 at 9:49 AM, Mauro Giubileo <[log in to unmask]> wrote:
>
>
> I think, in your case (waiting hours to produce a WAV file from a csd file) you used Csound as an "offline renderer", not as a "compiler". The output of a compiler should be an intermediate object code or an executable file... But a WAV file it is neither one nor the other. :-)
>
> Regards,
> Mauro
>
>
> Il 2018-08-15 17:09 Brian Redfern ha scritto:
>
> Now that csound can run in realtime even on phones it is more helpful to think of it as an interpreter but back in the late 90s running a Mac os9 machine with 24 Meg's of RAM it was a compiler you sometimes waited hours for a WAV file to be produced from your code. Csound mailing list [log in to unmask] 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 [log in to unmask] 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 [log in to unmask] 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 [log in to unmask] 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 [log in to unmask] 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
> [log in to unmask]
> 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 [log in to unmask] 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
[log in to unmask]
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

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015

ATOM RSS1 RSS2



LISTSERV.HEANET.IE

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager