Hi Phil, I'll reply in detail later, but one thing is that as long as you can convince Factor that there's a fixnum on the stack, you can change fixnum+fast and to + with no loss of performance.
Certainly I don't want people to be coding inner loops in ASM and eventually the compiler should be able to generate equivalent code to the C inner loop for something like 'count' applied to a specialized int array. Slava On Mon, Sep 1, 2008 at 9:24 AM, Phil Dawes <[EMAIL PROTECTED]> wrote: > Incidentally, here is the best performing 'count-items' I could do in > factor, which was basically to modify 'each' to jump 4 bytes at a time. > This was ~70% faster than using the builtin factor 'count' and using '4 > fixnum*fast' each iteration to generate the addresses. It clocks in at > ~1400ms on the same setup as the asm test (see orig email). Any tricks > I'm missing? > > -Phil > > > : next+4 ( from to quot -- from' to quot ) > [ 4 fixnum+fast ] 2dip ; inline > > : (each-elem-int) ( from to quot: ( i -- ) -- ) > [ iterate-step next+4 (each-elem-int) ] > [ 3drop ] if-iterate? ; inline recursive > > : each-step-4 ( to quot -- ) > 0 -rot (each-elem-int) ; inline > > : each-uint ( alien size quot -- ) > [ alien-unsigned-4 ] prepose with each-step-4 ; inline > > : each-uint* ( mmap quot -- ) > [ [ address>> ] [ length>> ] bi ] dip each-uint ; inline > > : myreduce ( mmap identity quot -- result ) swapd each-uint* ; inline > > : mysigma ( mmap quot -- n ) [ + ] compose 0 swap myreduce ; inline > > : mycount ( mmap quot -- n ) [ 1 0 ? ] compose mysigma ; inline > > : count-items ( mmap item -- n ) [ = ] curry mycount ; inline > > : with-whole-mapped-file ( fname quot -- ) > [ dup file-info size>> ] dip with-mapped-file ; inline > > : test-count-items ( fname val -- count ) > [ count-items ] curry with-whole-mapped-file ; > > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
