Re: Loop optimisation with identical counters

2010-11-05 Thread Sebastian Fischer
Which proposal do you mean? I referred to Christian's questions whether it is possible to generate `ff` and `gg` from `f` and `g`. If `h` is similar to `g`, then `hh` could reuse `ff` while with an inlining approach something like `ff` would be duplicated. I'm not sure something like tha

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
On Nov 5, 2010, at 8:56 PM, Brandon S Allbery KF8NH wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 11/5/10 19:22 , David Peixotto wrote: >>Probably there are some wins to be had by choosing a good optimization >>sequence for the code generated from GHC, rather than just

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
On Nov 5, 2010, at 7:55 PM, Roman Leshchinskiy wrote: > On 06/11/2010, at 00:28, David Peixotto wrote: > >> Yes, the LLVM code has Sp, Hp, Base all annotated as noalias. I believe that >> Sp, Hp, and Base should never alias, but a (boxed) R1 should always alias >> with either Sp or Hp. I had a

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 06/11/2010, at 02:27, Sebastian Fischer wrote: > Interesting. This approach requires `f` to be inlined into its call site in > order to eliminate the redundant argument. This is different from the > proposal to provide a specialized version of `f` (where the arguments are > combined) which c

Re: Loop optimisation with identical counters

2010-11-05 Thread Sebastian Fischer
On Nov 6, 2010, at 8:22 AM, David Peixotto wrote: To summarize, I found that it is possible to get LLVM to do this transformation through a combination of tail-call elimination, inlining, induction variable optimization, and global value numbering. Interesting. This approach requires `f` t

Re: Loop optimisation with identical counters

2010-11-05 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/5/10 19:22 , David Peixotto wrote: > Probably there are some wins to be had by choosing a good optimization > sequence for the code generated from GHC, rather than just using `-O1`, > `-O2`, etc. I believe It should be possible to fin

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 06/11/2010, at 00:28, David Peixotto wrote: > Yes, the LLVM code has Sp, Hp, Base all annotated as noalias. I believe that > Sp, Hp, and Base should never alias, but a (boxed) R1 should always alias > with either Sp or Hp. I had a hard time determining exactly how LLVM uses the > noalias ann

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
Hi Roman, On Nov 5, 2010, at 6:44 PM, Roman Leshchinskiy wrote: > On 05/11/2010, at 23:22, David Peixotto wrote: > >> I spent some time looking at the code generated for llvm and the >> optimizations >> it can apply. There were quite a bit of details to examine and I wrote it up >> as blog post

Re: Re[2]: Rigid types fun

2010-11-05 Thread Mitar
Hi! On Fri, Nov 5, 2010 at 12:12 PM, Bulat Ziganshin wrote: > look into HsLua sources. it does something like you asking (converting > return type into sequence of commands) so it mau be what you are > looking for. it uses typeclasses for this effect. the same technique > used in haskell printf i

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 05/11/2010, at 23:22, David Peixotto wrote: > I spent some time looking at the code generated for llvm and the optimizations > it can apply. There were quite a bit of details to examine and I wrote it up > as blog post here: > http://www.dmpots.com/blog/2010/11/05/optimizing-haskell-loops-with-

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
I spent some time looking at the code generated for llvm and the optimizations it can apply. There were quite a bit of details to examine and I wrote it up as blog post here: http://www.dmpots.com/blog/2010/11/05/optimizing-haskell-loops-with-llvm.html. To summarize, I found that it is possible to

Re: Rigid types fun

2010-11-05 Thread Mitar
Hi! On Fri, Nov 5, 2010 at 12:50 PM, Alexey Khudyakov wrote: > I'm not sure what do you exactly want. But what about applicative functors? > They offer nice notation > >> Nerve <$> (Axon <$> newChan) <*> (AxonAny <$> newChan) Ooo. That is nice. Mitar ___

Re: Rigid types fun

2010-11-05 Thread Alexey Khudyakov
On 05.11.2010 14:08, Mitar wrote: So I know I can move some hard-coded combination into a function. But I would like to cover all combinations and tell with arguments which combination I want. I'm not sure what do you exactly want. But what about applicative functors? They offer nice notation

Re[2]: Rigid types fun

2010-11-05 Thread Bulat Ziganshin
Hello Mitar, Friday, November 5, 2010, 2:08:52 PM, you wrote: > I would like to call it like "create (Axon undefined) (AxonAny > undefined)" and get in that case "Nerve (Axon a) (AxonAny b)" as a > result. If I would call it like "create (AxonAny undefined) (AxonAny > undefined)" I would get "Ner

Re: Rigid types fun

2010-11-05 Thread Mitar
Hi! On Fri, Nov 5, 2010 at 10:49 AM, Bulat Ziganshin wrote: > Friday, November 5, 2010, 12:45:21 PM, you wrote: > >> from <- newChan >> for <- newChan >> let nerve = Nerve (Axon from) (AxonAny for) > > create = do from <- newChan >            for <- newChan >            return$ Nerve (Axon from)

Re: Rigid types fun

2010-11-05 Thread Bulat Ziganshin
Hello Mitar, Friday, November 5, 2010, 12:45:21 PM, you wrote: > from <- newChan > for <- newChan > let nerve = Nerve (Axon from) (AxonAny for) create = do from <- newChan for <- newChan return$ Nerve (Axon from) (AxonAny for) main = do nerve <- create ... --

Rigid types fun

2010-11-05 Thread Mitar
Hi! I have much fun with rigid types, type signatures and GADTs. And I would like to invite also others in and share my joy. ;-) Please see the attached file and chase a solution to how to make it compile. I would like to have a function which I would call like: createNerve (Axon undefined) (Axo