Re: [Factor-talk] How would I solve this better in Factor?
Björn's can be sped up by not using assoc-map! and replacing ``refine-index`` with this: :: refine-index ( max-i index prev-index -- ) index keys [ [ prev-index at ] [ index set-at ] bi ] each index [ nip max-i >= ] assoc-filter! drop ; That takes it from 2.0 seconds to 1.3 seconds on my laptop. On Thu, Mar 17, 2016 at 11:11 AM, Alexander Ilin wrote: > Hello! > > I've finally finished my solution: > http://paste.factorcode.org/paste?id=3852 > > I took a different approach. Instead of manipulating the source input > string I create a hash table of all character positions, then remove and > add items to it as I go until it's empty. Output is collected as a > side-effect of that process in a global variable. This approach combines > sub-par performance with difficult-to-read code. > > On my machine the solve2 word runs in 28.5 seconds, compared to > Sankaranarayan's 2.6 seconds, and Bjoern's 3.28 seconds. (Jon's solution > never completes: Factor terminates without an error message after about 20 > minutes of work.) > > I think the approach is interesting, but the performance seems to suffer > due to the many searches, sorts and hash table manipulations. Apparently, > working directly over the one input string is faster. > > After initially implementing a solution with 6 global variables, I > managed to reduce the number to 1 by moving stuff around and using locals. > This was fun, and quite easy, although this one time I got the order of > arguments wrong and had a hard time finding the cause. Apparently, it's not > so easy to simulate code runs when locals are used: you can't just populate > stack in the Listener and paste pieces of code into it. > > Overall, this was a useful excersise in learning Factor. Thank you, > Sankaranarayan! > > ---=--- > Александр > > > -- > Transform Data into Opportunity. > Accelerate data analysis in your applications with > Intel Data Analytics Acceleration Library. > Click to learn more. > http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] bit-arrays docs
>From the docs: http://docs.factorcode.org/content/article-bit-arrays.html "Bit arrays play a special role in the C library interface; they can be used to pass binary data back and forth between Factor and C. See Passing pointers to C functions." Is this still true ? If so, then there should be a mention of bit-arrays in addition to byte-arrays in the linked article http://docs.factorcode.org/content/article-c-pointers.html ? Jon -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Inlining - when?
The inline feature is mainly used for providing type propagation in Factor, either because you want the word to know the type of its arguments or because one of its arguments is a quotation and that requires inlining. That can improve performance in many cases. There are a lot of drawbacks too, including that compiled code size gets larger because instead of one word that is compiled with calls to "jump into" other words, you would get massive gigantic words that contain all the logic in any word they call if you inlined everything. This can cause loss of speed sometimes. These thoughts from C++ generally apply to Factor: https://isocpp.org/wiki/faq/inline-functions On Fri, Mar 18, 2016 at 12:50 AM, Alexander Ilin wrote: > Hello! > > Is there a reason to NOT mark everything with "inline"? > > ---=--- > Александр > > > -- > Transform Data into Opportunity. > Accelerate data analysis in your applications with > Intel Data Analytics Acceleration Library. > Click to learn more. > http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] ./build.sh
With the move, everyone with a checkout older than 2016-03-15 (5dd6435511af) will have: $ ./build-support/factor.sh update [ ... snip ... git pul that removes the build-support.sh script ] build-support/_update.sh: line 3: /home/jon/factor/build-support/factor.sh: No such file or directory $ # now use ./build.sh I guess it's ok, it's the only way to get rid of the build-support folder entirely, but I'm just leaving a trace that this is normal on this list. Jon On Tue, Mar 15, 2016 at 11:28 AM, John Benediktsson wrote: > Hi, > > I just moved the files in build-support up a level and renamed them, so now > instead of: > > $ ./build-support/factor.sh update > > You can just do: > > $ ./build.sh update > > And similarly moved build-support/factor.cmd to build.cmd for the Windows > users. > > It's a bit of a breaking change for those of us whose fingers have memorized > the old location, but it's a lot cleaner looking and less typing. > > If you have any problems, please let me know. Also, if you have a > suggestion for a cooler name than "build.sh" or "build.cmd", please let me > know. > > Thanks, > John. > > -- > Transform Data into Opportunity. > Accelerate data analysis in your applications with > Intel Data Analytics Acceleration Library. > Click to learn more. > http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Typed arguments
Hello, John! 18.03.2016, 17:16, "John Benediktsson" : > The inline feature is mainly used for providing type propagation in Factor, > either because you want the word to know the type of its arguments or because > one of its arguments is a quotation and that requires inlining. That can > improve performance in many cases. Type propagation? I didn't know there you could specify argument types in Factor! Where is it described, how do I use it? > These thoughts from C++ generally apply to Factor: > https://isocpp.org/wiki/faq/inline-functions Thanks for the link! ---=--- Александр -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Typed arguments
> > Type propagation? I didn't know there you could specify argument types > in Factor! Where is it described, how do I use it? > The short answer is there are two main ways to do type propagation: 1) the input to an inline word has a known type (this is what I was referencing) 2) the "typed" vocabulary is used to tell a word what types to expect and specialize on http://docs.factorcode.org/content/article-typed.html The longer answer includes such details as some words the compiler can infer output-types, for example knowing that creates a string object: IN: scratchpad USE: compiler.tree.debugger IN: scratchpad [ 5 CHAR: a string? ] optimized. [ \ t ] And in the case of numbers, the compiler can support interval analysis to know that a number is in a specified range, for example that in the "else" quotation that the number must be less than or equal to zero (thus not being greater than 5) so it can infer ``f`` without doing a computation: IN: scratchpad [ dup 0 > [ 12 > ] [ 5 > ] if ] optimized. [ dup 0 > [ 12 > ] [ drop f ] if ] -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] How would I solve this better in Factor?
Hello! I've finally finished my solution: http://paste.factorcode.org/paste?id=3852 I took a different approach. Instead of manipulating the source input string I create a hash table of all character positions, then remove and add items to it as I go until it's empty. Output is collected as a side-effect of that process in a global variable. This approach combines sub-par performance with difficult-to-read code. On my machine the solve2 word runs in 28.5 seconds, compared to Sankaranarayan's 2.6 seconds, and Bjoern's 3.28 seconds. (Jon's solution never completes: Factor terminates without an error message after about 20 minutes of work.) I think the approach is interesting, but the performance seems to suffer due to the many searches, sorts and hash table manipulations. Apparently, working directly over the one input string is faster. After initially implementing a solution with 6 global variables, I managed to reduce the number to 1 by moving stuff around and using locals. This was fun, and quite easy, although this one time I got the order of arguments wrong and had a hard time finding the cause. Apparently, it's not so easy to simulate code runs when locals are used: you can't just populate stack in the Listener and paste pieces of code into it. Overall, this was a useful excersise in learning Factor. Thank you, Sankaranarayan! ---=--- Александр -- Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk