Re: [Factor-talk] Naive loop optimization

2015-02-06 Thread John Benediktsson
> > 1) are specialized arrays the way to go? ie. do the nth & set-nth words > generate memory access as efficient as with pointer dereferencing in C? > Specialized arrays can be useful because they store untagged floats, which can take up less memory than a tagged float in a normal factor array. B

Re: [Factor-talk] Naive loop optimization

2015-02-06 Thread Marmaduke Woodman
Ah really nice. Thanks for the abundant information. The context of such a word is a neural network simulator where between hundreds and thousands of nodes need to be updated in place. Usually, the state of the network is stored as a big array of floats. The size of the network is known ahead of t

Re: [Factor-talk] Naive loop optimization

2015-02-06 Thread John Benediktsson
Some thoughts for you: No, ``dup`` does not do anything but duplicate essentially a pointer to the object. Part of the reason it is slow is that you are operating on a kind of box by keeping your { x y } pairs in arrays (and in some cases unboxing ``first2`` and re-boxing ``2array``). Each of th

[Factor-talk] Naive loop optimization

2015-02-06 Thread Marmaduke Woodman
Hi, I've attempted to write a perhaps naive ODE integration loop in Factor, http://paste.factorcode.org/paste?id=3428 but it seems quite slow: the `bench1` word reports running time of ~3 s, which is an order of magnitude off equivalent OCaml & Haskell, so I imagine due to my lack of Factor ex