| All good,
thanks for the explanation.
best
Oeyvind
2013/8/8 Steven Yi :
> I think your concern is well-placed. I think though that this will be
> a backwards compatible change. The logic of the proposed change goes:
>
> 1. Current behavior is to always run at i-time and k-time, whether it
> needs to run at k-time.
> 2. Running at k-time for i-time only opcodes does not really do
> anything. It just skips over all the i-time opcodes, but wastes some
> time.
> 3. Running at k-time for k-time opcodes prevents crashes/bugs.
> 4. If analysis occurs and i-time only opcodes found, only run i-branch
> at i-time. If k-time opcodes found, run at k-time as well.
>
> Result is that behavior is maintained. If all i-time opcodes, runs
> only at i-time, if k-time found, run at k-time as well. It's sort of
> an optimization if anything, but it'll also catch bugs in the same way
> that always running at i-time and k-time did.
>
> Here's another problem though. I was looking in the archives and found:
>
> http://csound.1045644.n5.nabble.com/if-then-else-bug-in-csound5-00-td1097353.html
>
> It's from when Csound 5.0 was being worked on. It's the issue that
> all opcodes may need initialization before running. I'm not sure what
> happens for k-rate branches if i-time skipping happens. (Perhaps it's
> time we start working on some developer documentation that specifies
> the behavior of the language...)
>
> On Thu, Aug 8, 2013 at 10:10 AM, Oeyvind Brandtsegg
> wrote:
>> Ok. Yes, I recognize the problem. The gotos are indeed and
>> "interesting" field full of happy opportunities to shoot oneself in
>> the foot.
>> I do appreciate you looking into it and trying to simplify. It just
>> looked as if changing it could be something that might change the
>> behaviour of old orchestras.
>> all best
>> Oeyvind
>>
>> 2013/8/8 Steven Yi :
>>> Hi Oeyvind,
>>>
>>> Nope, you got it exactly right. The intention is to change depending
>>> on what is inside the block. My rationale behind it is as follows:
>>>
>>> If's work by jumping over blocks of opcodes. However, with the case
>>> of something like:
>>>
>>>
>>> if (ival > 0) ithen
>>> krateval someOpcode ival, 0
>>> else
>>> krateval someOpcode ival, 1
>>> endif
>>>
>>> what happens is that you get something like this:
>>>
>>> #b0 lt ival, 0
>>> cingoto #b0, __synth_label0
>>> krateval someOpcode ival, 0
>>> igoto __synth_label1
>>> :__synth_label0
>>> krateval someOpcode ival, 1
>>> :__synth_label1
>>>
>>> Now, if the ival happens to be greater than zero, you'll get what
>>> seems like the right behavior. During init-time, the (ival > 0) is
>>> evaluated and stored into #b0. cingoto checks and decides not to
>>> jump, then the first someOpcode is initialized. Then the goto will
>>> jump past the rest of the opcodes to synth_label1, and the 2nd
>>> someOpcode is not initialized. At perf-time, everything *seems* to be
>>> fine. What happens is cingoto has no perf function, so it will pass
>>> through to the first branch *always*. The first branch is run and the
>>> rest is jumped over with the goto. However, all seems fine.
>>>
>>> Now, what happens if ival is <= 0? The cingoto will evaluate and
>>> because it is not true, jump to synth_label0. The 2nd someOpcode now
>>> is initialized, and the first is not.
>>>
>>> Now at perf time, we're in trouble. Because cingoto has no perf-time
>>> function, evaluation falls through and we will always go through the
>>> first branch of code. The first branch has not be initialized, and we
>>> get bad behavior. In the case of the attached test, we get a crash
>>> with a SEGFAULT.
>>>
>>>
>>> Now, my analysis is this: if you have an i-time boolean evaluation
>>> with an if-then, when you have opcodes that perform at k-rate, it can
>>> and will cause errors. Up until now, we seem to have gotten around
>>> those errors by just always running at k-rate. So if you wrote code
>>> with i-time boolean and k-rate opcodes, that was not going to cause
>>> issues. However, with i-time only evaluation, we have the
>>> possibilities for serious problems, as illustrated above and in the
>>> example CSD.
>>>
>>> Note, opcodes that take in k-var's and output k-var's may not
>>> necessarily be k-rate opcodes. For example, i(kval) is one, and
>>> chnexport.
>>>
>>> steven
>>>
>>>
>>> On Thu, Aug 8, 2013 at 8:47 AM, Oeyvind Brandtsegg
>>> wrote:
>>>> I'm not sure I understand 100% the implications of this, but are you
>>>> thinking of changing how the goto operates based on what is inside the
>>>> relevant (goto'ed) section? I would think it possible (intentionally)
>>>> that one create an igoto block that may have k-rate opcodes in it.
>>>> Sorry for the noise if I misunderstood the intention of the change.
>>>> best
>>>> Oeyvind
>>>>
>>>> 2013/8/8 Steven Yi :
>>>>> I just took a look. cigoto won't do it as it's looking for the
>>>>> positive case, while cngoto check for the negative case. We'd need to
>>>>> modify or add an opcode that runs just ingoto and no kngoto. I think
>>>>> ultimately we should do as mentioned and have the semantic analyzer
>>>>> choose the correct option depending on if the opcodes within the
>>>>> branch are i-time only or not. That will be some work though, due to
>>>>> nested if's.
>>>>>
>>>>> On Wed, Aug 7, 2013 at 2:40 PM, Victor Lazzarini
>>>>> wrote:
>>>>>> The relevant code seems to be in csound_orc_expressions.c:
>>>>>>
>>>>>> TREE * create_goto_token(CSOUND *csound, char * booleanVar,
>>>>>> TREE * gotoNode, int type)
>>>>>> {
>>>>>> /* TREE *ans = create_empty_token(csound); */
>>>>>> char* op = (char *)csound->Malloc(csound, 7); /* Unchecked */
>>>>>> TREE *opTree, *bVar;
>>>>>>
>>>>>> switch(gotoNode->type) {
>>>>>> case KGOTO_TOKEN:
>>>>>> sprintf(op, "ckgoto");
>>>>>> break;
>>>>>> case IGOTO_TOKEN:
>>>>>> sprintf(op, "cigoto");
>>>>>> break;
>>>>>> case ITHEN_TOKEN:
>>>>>> sprintf(op, "cngoto");
>>>>>> break;
>>>>>> case THEN_TOKEN:
>>>>>> case KTHEN_TOKEN:
>>>>>> sprintf(op, "cngoto");
>>>>>> break;
>>>>>> default:
>>>>>> if (type) sprintf(op, "ckgoto");
>>>>>> else sprintf(op, "cggoto");
>>>>>> }
>>>>>>
>>>>>>
>>>>>> you see that there is no difference between ITHEN, THEN or KTHEN.
>>>>>> The oentry for cngoto is:
>>>>>>
>>>>>> { "cngoto", S(CGOTO),0, 3, "", "Bl", ingoto, kngoto, NULL },
>>>>>>
>>>>>> with 3 as thread, which is OK for THEN. KTHEN, but not ITHEN.
>>>>>>
>>>>>> Should this be cigoto for ITHEN?
>>>>>>
>>>>>>
>>>>>> On 7 Aug 2013, at 12:48, Steven Yi wrote:
>>>>>>
>>>>>>> I think if it's emitting a kngoto, then the relevant i-time opcode
>>>>>>> would be cngoto. One thought I had was that maybe the semantic
>>>>>>> analyzer should check the rates of opcodes within the branch, and
>>>>>>> really determine which to use depending on if any of the opcodes are
>>>>>>> run at perf-time or not. That seems like it would solve a lot of
>>>>>>> Csound coding issues. Thoughts?
>>>>>>>
>>>>>>> On Wed, Aug 7, 2013 at 1:15 PM, Victor Lazzarini
>>>>>>> wrote:
>>>>>>>> As I mentioned yesterday, the if ... ithen statement is being parsed into the wrong opcode, kngoto. This is
>>>>>>>> a bug that has been there since the Csound 5. I am not quite sure which opcode it should use, is it
>>>>>>>> cigoto? Anyway, it should be a simple fix.
>>>>>>>>
>>>>>>>> Dr Victor Lazzarini
>>>>>>>> Senior Lecturer
>>>>>>>> Dept. of Music
>>>>>>>> NUI Maynooth Ireland
>>>>>>>> tel.: +353 1 708 3545
>>>>>>>> Victor dot Lazzarini AT nuim dot ie
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>>>>>>> It's a free troubleshooting tool designed for production.
>>>>>>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>>>>>>> Download for free and get started troubleshooting in minutes.
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>>>>>> It's a free troubleshooting tool designed for production.
>>>>>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>>>>>> Download for free and get started troubleshooting in minutes.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> Dr Victor Lazzarini
>>>>>> Senior Lecturer
>>>>>> Dept. of Music
>>>>>> NUI Maynooth Ireland
>>>>>> tel.: +353 1 708 3545
>>>>>> Victor dot Lazzarini AT nuim dot ie
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>>>>> It's a free troubleshooting tool designed for production.
>>>>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>>>>> Download for free and get started troubleshooting in minutes.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>>>> It's a free troubleshooting tool designed for production.
>>>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>>>> Download for free and get started troubleshooting in minutes.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Oeyvind Brandtsegg
>>>> Professor of Music Technology
>>>> NTNU
>>>> 7491 Trondheim
>>>> Norway
>>>> Cell: +47 92 203 205
>>>>
>>>> http://flyndresang.no/
>>>> http://www.partikkelaudio.com/
>>>> http://soundcloud.com/brandtsegg
>>>> http://soundcloud.com/t-emp
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>>> It's a free troubleshooting tool designed for production.
>>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>>> Download for free and get started troubleshooting in minutes.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>>> It's a free troubleshooting tool designed for production.
>>> Get down to code-level detail for bottlenecks, with <2% overhead.
>>> Download for free and get started troubleshooting in minutes.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> --
>>
>> Oeyvind Brandtsegg
>> Professor of Music Technology
>> NTNU
>> 7491 Trondheim
>> Norway
>> Cell: +47 92 203 205
>>
>> http://flyndresang.no/
>> http://www.partikkelaudio.com/
>> http://soundcloud.com/brandtsegg
>> http://soundcloud.com/t-emp
>>
>> ------------------------------------------------------------------------------
>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>> It's a free troubleshooting tool designed for production.
>> Get down to code-level detail for bottlenecks, with <2% overhead.
>> Download for free and get started troubleshooting in minutes.
>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205
http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |