I mistakenly published code for accelerating <SmallInteger> comparisonOp <Float> at http://code.google.com/p/cog/issues/detail?id=40 Apologizes, but it was obvious from reading the thread that the original issue was interesting, but that the issue discovered by Igor would not be fix... Nicolas 2011/5/3 Igor Stasenko <[hidden email]>: > > On 2 May 2011 18:19, stephane ducasse <[hidden email]> wrote: >> >> igor can you add bug entry to cog? > > sure > > http://code.google.com/p/cog/issues/detail?id=40 > > maybe someday someone could find a time and address it. > > > >> >> Stef >> > > -- > Best regards, > Igor Stasenko AKA sig. > |
In reply to this post by Nicolas Cellier
Wow.. that's cool. I had no time to get so deep into Cog JIT internals. And it is really interesting to hear your feedback about it (to Eliot as well, i assume) :) On 3 May 2011 22:05, Nicolas Cellier <[hidden email]> wrote: > > OK, easy, I had a reference to ClassReg instead of Arg0Reg (copy/paste > error from super). > My feeling is that it is very uncomfortable to program this part... > Since we mapped our local variables and arguments to an equivalent of > global variables (registers Arg0Reg etc), > then no compiler will tell us that this register is used before > assigned or never used or what... > Far, far away from Smalltalk safe lands... > > Here is a new try attached: > > [1 to: 2000000 do: [:i | > i < 2354.234. > i <= 2354.234. > i >= 2354.234. > i > 2354.234.]] timeToRun 71 > > A bit slower than SimpleCogit ? > > Nicolas > > 2011/5/3 Nicolas Cellier <[hidden email]>: >> OK, with SimpleCogit: >> [1 to: 2000000 do: [:i | >> i < 2354.234. >> i <= 2354.234. >> i >= 2354.234. >> i > 2354.234.]] timeToRun 69 >> >> vs 4.2.5 VM: >> [1 to: 2000000 do: [:i | >> i < 2354.234. >> i <= 2354.234. >> i >= 2354.234. >> i > 2354.234.]] timeToRun 299 >> >> StackToRegisterMappingCogit: >> crash... >> >> I don't get the x86 certification yet :( >> >> Nicolas >> >> >> 2011/5/3 Nicolas Cellier <[hidden email]>: >>> Apart another declaration bug (FP missing in function name...) there >>> is a killer : >>> >>> StackToRegisterMappingCogit inherits silently from >>> SimpleStackBasedCogit>>#genSmallIntegerComparison:orDoubleComparison: >>> though it does not share the stack structure. This is fatal... >>> >>> So an override StackToRegisterMappingCogit>>#genSmallIntegerComparison:orDoubleComparison: >>> is mandatory >>> >>> Bad, bad inheritance... >>> >>> Now compiling the VM again... >>> >>> Nicolas >>> >>> >>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>> Hem, some declaration were missing... and the argument for FP >>>> comparison is tricky indeed... >>>> Sorry for the noise, but this is a direct live >>>> >>>> Nicolas >>>> >>>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>>> And if genSmallIntegerComparison:orDoubleComparison: is correct, then >>>>> usage shall be quite straight forward >>>>> >>>>> Nicolas >>>>> >>>>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>>>> I always refused to learn x86 assembler, but by code imitation I can >>>>>> give my own try in attachment. >>>>>> Note that I did not use the trick to invert FP comparison operands >>>>>> since this does not seem necessary. >>>>>> >>>>>> Nicolas >>>>>> >>>>>> >>>>>> 2011/5/2 Eliot Miranda <[hidden email]>: >>>>>>> >>>>>>> Hi Henrik, >>>>>>> >>>>>>> Eliot (phone) >>>>>>> >>>>>>> On May 2, 2011, at 3:12 AM, Henrik Sperre Johansen <[hidden email]> wrote: >>>>>>> >>>>>>>> As per my comment on the recent Morphic performance graphs,(http://blog.openinworld.com/2011/03/morphic-flavour-performance/#comment-59) on a Cog VM these primitives fail with a Float parameter, which leads to a huge performance hit when comparing Ints to Floats by doing silly things in the fallback code. >>>>>>>> >>>>>>>> Cog: >>>>>>>> [1 to: 2000000 do: [:i | >>>>>>>> i < 2354.234. >>>>>>>> i <= 2354.234. >>>>>>>> i >= 2354.234. >>>>>>>> i > 2354.234.]] timeToRun 26594 >>>>>>>> >>>>>>>> Trunk: >>>>>>>> [1 to: 2000000 do: [:i | >>>>>>>> i < 2354.234. >>>>>>>> i <= 2354.234. >>>>>>>> i >= 2354.234. >>>>>>>> i > 2354.234.]] timeToRun 229 >>>>>>>> >>>>>>>> Should this be changed in the VM, >>>>>>> >>>>>>> I think so. When I first wrote the SmallInteger translated prims I hadn't yet written the JIT support for floats and so couldn't write int/float comparison. Now all the support is there and it should be straight-forward. Do you fancy trying to write this yourself? Would be a fun exercise. Let me know and I can hand-hold with using the simulator. >>>>>>> >>>>>>> >>>>>>> Best >>>>>>> Eliot (phone) >>>>>>> >>>>>>> >>>>>>>> or is the difference for pure int/int comparition large enough that we should instead change >>>>>>>> Float>>adaptToInteger: andCompare: >>>>>>>> to use the corresponding comparitions with Float as receiver, which does work? >>>>>>>> That's still slower than trunk in my image, but quite a bit better, above test takes about 1s. >>>>>>>> >>>>>>>> Cheers, >>>>>>>> Henry >>>>>>> >>>>>> >>>>> >>>> >>> >> > > -- Best regards, Igor Stasenko AKA sig. |
As always, engineers will give you negative feedback, especially when specialized in system control ;) So I want to rectify the impression I may have given and thank Eliot and Teleplace for this work. Locating and changing the code was possible relatively quickly (1h), even fixing my own bugs (1h30) thanks to immediate VM crash ;). IMO this was possible thanks to Smalltalk IDE, and I would not bet on such efficiency for modifying a C/C++ VM. I consider this exercize as a proof of concept. But maybe I'm biased by too many years of Smalltalk, some other folks should try and fix such little details to confirm. Nicolas 2011/5/4 Igor Stasenko <[hidden email]>: > > Wow.. that's cool. I had no time to get so deep into Cog JIT internals. > And it is really interesting to hear your feedback about it (to Eliot > as well, i assume) :) > > On 3 May 2011 22:05, Nicolas Cellier <[hidden email]> wrote: >> >> OK, easy, I had a reference to ClassReg instead of Arg0Reg (copy/paste >> error from super). >> My feeling is that it is very uncomfortable to program this part... >> Since we mapped our local variables and arguments to an equivalent of >> global variables (registers Arg0Reg etc), >> then no compiler will tell us that this register is used before >> assigned or never used or what... >> Far, far away from Smalltalk safe lands... >> >> Here is a new try attached: >> >> [1 to: 2000000 do: [:i | >> i < 2354.234. >> i <= 2354.234. >> i >= 2354.234. >> i > 2354.234.]] timeToRun 71 >> >> A bit slower than SimpleCogit ? >> >> Nicolas >> >> 2011/5/3 Nicolas Cellier <[hidden email]>: >>> OK, with SimpleCogit: >>> [1 to: 2000000 do: [:i | >>> i < 2354.234. >>> i <= 2354.234. >>> i >= 2354.234. >>> i > 2354.234.]] timeToRun 69 >>> >>> vs 4.2.5 VM: >>> [1 to: 2000000 do: [:i | >>> i < 2354.234. >>> i <= 2354.234. >>> i >= 2354.234. >>> i > 2354.234.]] timeToRun 299 >>> >>> StackToRegisterMappingCogit: >>> crash... >>> >>> I don't get the x86 certification yet :( >>> >>> Nicolas >>> >>> >>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>> Apart another declaration bug (FP missing in function name...) there >>>> is a killer : >>>> >>>> StackToRegisterMappingCogit inherits silently from >>>> SimpleStackBasedCogit>>#genSmallIntegerComparison:orDoubleComparison: >>>> though it does not share the stack structure. This is fatal... >>>> >>>> So an override StackToRegisterMappingCogit>>#genSmallIntegerComparison:orDoubleComparison: >>>> is mandatory >>>> >>>> Bad, bad inheritance... >>>> >>>> Now compiling the VM again... >>>> >>>> Nicolas >>>> >>>> >>>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>>> Hem, some declaration were missing... and the argument for FP >>>>> comparison is tricky indeed... >>>>> Sorry for the noise, but this is a direct live >>>>> >>>>> Nicolas >>>>> >>>>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>>>> And if genSmallIntegerComparison:orDoubleComparison: is correct, then >>>>>> usage shall be quite straight forward >>>>>> >>>>>> Nicolas >>>>>> >>>>>> 2011/5/3 Nicolas Cellier <[hidden email]>: >>>>>>> I always refused to learn x86 assembler, but by code imitation I can >>>>>>> give my own try in attachment. >>>>>>> Note that I did not use the trick to invert FP comparison operands >>>>>>> since this does not seem necessary. >>>>>>> >>>>>>> Nicolas >>>>>>> >>>>>>> >>>>>>> 2011/5/2 Eliot Miranda <[hidden email]>: >>>>>>>> >>>>>>>> Hi Henrik, >>>>>>>> >>>>>>>> Eliot (phone) >>>>>>>> >>>>>>>> On May 2, 2011, at 3:12 AM, Henrik Sperre Johansen <[hidden email]> wrote: >>>>>>>> >>>>>>>>> As per my comment on the recent Morphic performance graphs,(http://blog.openinworld.com/2011/03/morphic-flavour-performance/#comment-59) on a Cog VM these primitives fail with a Float parameter, which leads to a huge performance hit when comparing Ints to Floats by doing silly things in the fallback code. >>>>>>>>> >>>>>>>>> Cog: >>>>>>>>> [1 to: 2000000 do: [:i | >>>>>>>>> i < 2354.234. >>>>>>>>> i <= 2354.234. >>>>>>>>> i >= 2354.234. >>>>>>>>> i > 2354.234.]] timeToRun 26594 >>>>>>>>> >>>>>>>>> Trunk: >>>>>>>>> [1 to: 2000000 do: [:i | >>>>>>>>> i < 2354.234. >>>>>>>>> i <= 2354.234. >>>>>>>>> i >= 2354.234. >>>>>>>>> i > 2354.234.]] timeToRun 229 >>>>>>>>> >>>>>>>>> Should this be changed in the VM, >>>>>>>> >>>>>>>> I think so. When I first wrote the SmallInteger translated prims I hadn't yet written the JIT support for floats and so couldn't write int/float comparison. Now all the support is there and it should be straight-forward. Do you fancy trying to write this yourself? Would be a fun exercise. Let me know and I can hand-hold with using the simulator. >>>>>>>> >>>>>>>> >>>>>>>> Best >>>>>>>> Eliot (phone) >>>>>>>> >>>>>>>> >>>>>>>>> or is the difference for pure int/int comparition large enough that we should instead change >>>>>>>>> Float>>adaptToInteger: andCompare: >>>>>>>>> to use the corresponding comparitions with Float as receiver, which does work? >>>>>>>>> That's still slower than trunk in my image, but quite a bit better, above test takes about 1s. >>>>>>>>> >>>>>>>>> Cheers, >>>>>>>>> Henry >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >> > > > > -- > Best regards, > Igor Stasenko AKA sig. > |
On 4 May 2011 09:47, Nicolas Cellier <[hidden email]> wrote: > > As always, engineers will give you negative feedback, especially when > specialized in system control ;) > So I want to rectify the impression I may have given and thank Eliot > and Teleplace for this work. > Locating and changing the code was possible relatively quickly (1h), > even fixing my own bugs (1h30) thanks to immediate VM crash ;). > IMO this was possible thanks to Smalltalk IDE, and I would not bet on > such efficiency for modifying a C/C++ VM. > I consider this exercize as a proof of concept. > But maybe I'm biased by too many years of Smalltalk, some other folks > should try and fix such little details to confirm. > You're just confirmed my previous observations about coding VM in smalltalk (when i were hacking Hydra). Yes, it is quite special area, but it is still relatively easy to get in, play with it and get results, without spending weeks studying APIs and classes before you even attempt to solve something. This is why i love smalltalk: it allows you to do magics without too deep knowledge of everything. > Nicolas > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Nicolas Cellier
Nicolas, i placed your code at issue #41 http://code.google.com/p/cog/issues/detail?id=41 please check if i uploaded a correct version of code. The change is quite simple, and most probably should work :) But i didn't tested it yet. -- Best regards, Igor Stasenko AKA sig. |
Free forum by Nabble | Edit this page |