Re: GHC core plugins

2010-01-29 Thread Simon Marlow

On 29/01/10 09:32, José Pedro Magalhães wrote:

Hi,

2010/1/28 Max Bolingbroke mailto:batterseapo...@hotmail.com>>

2010/1/28 José Pedro Magalhães mailto:j...@cs.uu.nl>>:
 > Yes, that helped quite a lot. One last thing: currently it takes
me about 6
 > minutes to rebuild the compiler after I change the core pass. Are
there any
 > tricks of the build system I can use to speed this up? I'm
already using a
 > fast build without optimizations and docs...

Hmm. Some things that help with this for me are to:
1) Compile with -j12 (or lower, depending on your hardware spec)
2) Compile with "cd compiler && make stage=2" to only build the stage
2 compiler (if this isn't already happening). Make sure the stage 1
compiler is built with optimisations! (I use the stage2devel
configuration, which already does this)

This reduces compile times to a few minutes for me. Still tedious, but
not too bad.


Thanks. Doing this reduces compilation time to about 30s, but
unfortunately my pass is not updated (even though it is compiled). I
have to do 'make stage=2' at the root directory, not inside compiler.
This brings compilation time to 1m10s (which is still better than what I
was doing), but I really don't know what would need building outside the
compiler directory...


The correct way to update your stage 2 compiler without rebuilding 
extraneous dependencies is:


  $ cd ghc
  $ make 2

for more info, see

http://hackage.haskell.org/trac/ghc/wiki/Building/Using#RebuildingtheGHCbinaryaftermakingchanges


As an aside, is there any hope of using SYB in the core pass? As a
generic programmer I quickly get tired of traversing the entire AST when
I want just a few changes in specific places...


That's a discussion we ought to have at some point.  Note however that 
Core is actually a very deep data type (Ids contain unfoldings, which 
contain more expressions, which contain Ids, which contain types, and so 
on), and is also cyclic.  Simply traversing the whole thing would be a 
very bad idea.


There is a ghc-syb package which has SYB instances for HsSyn I think. 
HsSyn is not as deep or cyclic as Core.


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-29 Thread José Pedro Magalhães
Hi,

2010/1/28 Max Bolingbroke 

> 2010/1/28 José Pedro Magalhães :
> > Yes, that helped quite a lot. One last thing: currently it takes me about
> 6
> > minutes to rebuild the compiler after I change the core pass. Are there
> any
> > tricks of the build system I can use to speed this up? I'm already using
> a
> > fast build without optimizations and docs...
>
> Hmm. Some things that help with this for me are to:
> 1) Compile with -j12 (or lower, depending on your hardware spec)
> 2) Compile with "cd compiler && make stage=2" to only build the stage
> 2 compiler (if this isn't already happening). Make sure the stage 1
> compiler is built with optimisations! (I use the stage2devel
> configuration, which already does this)
>
> This reduces compile times to a few minutes for me. Still tedious, but
> not too bad.
>

Thanks. Doing this reduces compilation time to about 30s, but unfortunately
my pass is not updated (even though it is compiled). I have to do 'make
stage=2' at the root directory, not inside compiler. This brings compilation
time to 1m10s (which is still better than what I was doing), but I really
don't know what would need building outside the compiler directory...

As an aside, is there any hope of using SYB in the core pass? As a generic
programmer I quickly get tired of traversing the entire AST when I want just
a few changes in specific places...


Thanks,
Pedro


>
> Hope that helps,
> Max
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-28 Thread Max Bolingbroke
2010/1/28 José Pedro Magalhães :
> Yes, that helped quite a lot. One last thing: currently it takes me about 6
> minutes to rebuild the compiler after I change the core pass. Are there any
> tricks of the build system I can use to speed this up? I'm already using a
> fast build without optimizations and docs...

Hmm. Some things that help with this for me are to:
1) Compile with -j12 (or lower, depending on your hardware spec)
2) Compile with "cd compiler && make stage=2" to only build the stage
2 compiler (if this isn't already happening). Make sure the stage 1
compiler is built with optimisations! (I use the stage2devel
configuration, which already does this)

This reduces compile times to a few minutes for me. Still tedious, but
not too bad.

Hope that helps,
Max
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-28 Thread José Pedro Magalhães
Hi Max,

2010/1/27 Max Bolingbroke 

> 2010/1/27 José Pedro Magalhães :
> > Alright, ticket created: http://hackage.haskell.org/trac/ghc/ticket/3843
> >
> > In any case, for now I am willing to hard-code a new core-to-core pass on
> > the compiler. Any pointers for where I have to look at?
>
> I recommend you look at compiler/simplCore/CSE.lhs. It is a simple
> example of a core-to-core pass.
>
> However, in short you'll need to:
> 1) Create a function which implements your core to core pass, of a
> type such as [CoreBind] -> [CoreBind]
>  *) If that function lives in a new module, edit ghc.cabal.in to tell
> the build system about the module
> 2) Add a constructor to the CoreToDo data type in
> compiler/simplCore/CoreMonad.lhs
> 3) Add a case for it to the coreDumpFlag and Outputable instance
> 4) Add that pass to the list returned by getCoreToDo in CoreMonad. The
> order of the list is the order the passes will be run in.
>  *) If you want the pass to be under the control of a new flag, you'll
> need to add a new dynflag - add a constructor to the DOpt data type in
> compiler/main/DynFlags.lhs, and add something to build that
> constructor to one of the lists that get fed to the command line
> handling code in the same module. It should be fairly obvious how to
> do this.
> 5) Add a handler for the new constructor to
> compiler/simplCore/SimplCore.lhs, in the doCorePass function which
> calls into the core pass function you wrote
>
> Hope that helps,
> Max
>

Yes, that helped quite a lot. One last thing: currently it takes me about 6
minutes to rebuild the compiler after I change the core pass. Are there any
tricks of the build system I can use to speed this up? I'm already using a
fast build without optimizations and docs...


Thanks,
Pedro
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-27 Thread austin s
On Wed, Jan 27, 2010 at 10:24 AM, austin s  wrote:
> 2010/1/27 Simon Peyton-Jones :
>> | Also, is Hoopl expected to be used on core -> core plugins, and, if so, is
>> | the
>> | infrastructure in place for this?
>>
>> no, Hoopl works on imperative control flow graphs, the C-- part of the back 
>> end, not on Core.
>>
>> Simon
>> ___
>> Glasgow-haskell-users mailing list
>> Glasgow-haskell-users@haskell.org
>> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>>
>
> Quick Question, even if it is OT: Is the Hoopl code available anywhere?
>
> --
> - Austin
>

Whoops, forgot to add g-h-u to the to: field. ;)

-- 
- Austin
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: GHC core plugins

2010-01-27 Thread Simon Peyton-Jones
| Also, is Hoopl expected to be used on core -> core plugins, and, if so, is
| the
| infrastructure in place for this?

no, Hoopl works on imperative control flow graphs, the C-- part of the back 
end, not on Core.

Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-27 Thread Daniel Peebles
I hope it'll be possible :) I heard a general overview of the plugins
infrastructure a few months ago and it sounded like what I'd need, but I was
unable to find a very detailed account of how it works and what specific
information is available to plugins, so maybe I'm just dreaming.


2010/1/27 Tyson Whitehead 

> On January 27, 2010 05:44:00 José Pedro Magalhães wrote:
> > Alright, ticket created: http://hackage.haskell.org/trac/ghc/ticket/3843
> >
> > In any case, for now I am willing to hard-code a new core-to-core pass on
> > the compiler. Any pointers for where I have to look at?
>
> Just wondering a couple of things about core -> core plugins.
>
> Is the second use case mentioned by pumpkingod there (tracking which
> rewrite
> rules are firing and when) actually possible using a core -> core plugin?
>
> (it would be great to have this information fed into some sort of emacs
> plugin
> where one could drill down on specific functions to see what is happening)
>
> Also, is Hoopl expected to be used on core -> core plugins, and, if so, is
> the
> infrastructure in place for this?
>
> Thanks!  -Tyson
>
> ___
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-27 Thread Tyson Whitehead
On January 27, 2010 05:44:00 José Pedro Magalhães wrote:
> Alright, ticket created: http://hackage.haskell.org/trac/ghc/ticket/3843
>
> In any case, for now I am willing to hard-code a new core-to-core pass on
> the compiler. Any pointers for where I have to look at?

Just wondering a couple of things about core -> core plugins.

Is the second use case mentioned by pumpkingod there (tracking which rewrite 
rules are firing and when) actually possible using a core -> core plugin?

(it would be great to have this information fed into some sort of emacs plugin 
where one could drill down on specific functions to see what is happening)

Also, is Hoopl expected to be used on core -> core plugins, and, if so, is the 
infrastructure in place for this?

Thanks!  -Tyson


signature.asc
Description: This is a digitally signed message part.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-27 Thread José Pedro Magalhães
Alright, ticket created: http://hackage.haskell.org/trac/ghc/ticket/3843

In any case, for now I am willing to hard-code a new core-to-core pass on
the compiler. Any pointers for where I have to look at?


Thanks,
Pedro

2010/1/27 Simon Peyton-Jones 

> Yes, I apologise for being slow about this.  A good idea would be to create
> a Trac ticket, so that people can register interest in having the patch by
> adding themselves to the cc list.  The more people that want it, the higher
> up my priority list...
>
> Better still if everyone adds a comment to the ticket to explain what their
> pass is like, and why they want the plugin feature.
>
> Simon
>
> | -Original Message-
> | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-
> | users-boun...@haskell.org] On Behalf Of Max Bolingbroke
> | Sent: 26 January 2010 18:38
> | To: José Pedro Magalhães
> | Cc: GHC users
> | Subject: Re: GHC core plugins
> |
> | Hi José,
> |
> | The patch implementing GHC plugins is with Simon PJ and awaiting merge
> | into GHC (and has been for some time - he's a busy guy and its a big
> | patch). However, even once it's merged some more work will need to be
> | done to make sure that it plays nicely with the shared library support
> | (now that has been implemented on all major platforms).
> |
> | In short, the easiest way to add a pass to the compiler right now is
> | to download GHC and build it yourself
> | (http://hackage.haskell.org/trac/ghc/wiki/Building). Sorry!
> |
> | All the best,
> | Max
> |
> | 2010/1/26 José Pedro Magalhães :
> | > Hello all,
> | >
> | > What's the current status of GHC plugins [1] in HEAD? Can I use them?
> If
> | > not, what's the easiest way to add another core-to-core pass to the
> | > compiler?
> | >
> | >
> | > Thanks,
> | > Pedro
> | >
> | > [1] http://hackage.haskell.org/trac/ghc/wiki/Plugins
> | >
> | > ___
> | > Glasgow-haskell-users mailing list
> | > Glasgow-haskell-users@haskell.org
> | > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> | >
> | >
> | ___
> | Glasgow-haskell-users mailing list
> | Glasgow-haskell-users@haskell.org
> | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: GHC core plugins

2010-01-26 Thread Simon Peyton-Jones
Yes, I apologise for being slow about this.  A good idea would be to create a 
Trac ticket, so that people can register interest in having the patch by adding 
themselves to the cc list.  The more people that want it, the higher up my 
priority list...

Better still if everyone adds a comment to the ticket to explain what their 
pass is like, and why they want the plugin feature.

Simon

| -Original Message-
| From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-
| users-boun...@haskell.org] On Behalf Of Max Bolingbroke
| Sent: 26 January 2010 18:38
| To: José Pedro Magalhães
| Cc: GHC users
| Subject: Re: GHC core plugins
| 
| Hi José,
| 
| The patch implementing GHC plugins is with Simon PJ and awaiting merge
| into GHC (and has been for some time - he's a busy guy and its a big
| patch). However, even once it's merged some more work will need to be
| done to make sure that it plays nicely with the shared library support
| (now that has been implemented on all major platforms).
| 
| In short, the easiest way to add a pass to the compiler right now is
| to download GHC and build it yourself
| (http://hackage.haskell.org/trac/ghc/wiki/Building). Sorry!
| 
| All the best,
| Max
| 
| 2010/1/26 José Pedro Magalhães :
| > Hello all,
| >
| > What's the current status of GHC plugins [1] in HEAD? Can I use them? If
| > not, what's the easiest way to add another core-to-core pass to the
| > compiler?
| >
| >
| > Thanks,
| > Pedro
| >
| > [1] http://hackage.haskell.org/trac/ghc/wiki/Plugins
| >
| > ___
| > Glasgow-haskell-users mailing list
| > Glasgow-haskell-users@haskell.org
| > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
| >
| >
| ___
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC core plugins

2010-01-26 Thread Max Bolingbroke
Hi José,

The patch implementing GHC plugins is with Simon PJ and awaiting merge
into GHC (and has been for some time - he's a busy guy and its a big
patch). However, even once it's merged some more work will need to be
done to make sure that it plays nicely with the shared library support
(now that has been implemented on all major platforms).

In short, the easiest way to add a pass to the compiler right now is
to download GHC and build it yourself
(http://hackage.haskell.org/trac/ghc/wiki/Building). Sorry!

All the best,
Max

2010/1/26 José Pedro Magalhães :
> Hello all,
>
> What's the current status of GHC plugins [1] in HEAD? Can I use them? If
> not, what's the easiest way to add another core-to-core pass to the
> compiler?
>
>
> Thanks,
> Pedro
>
> [1] http://hackage.haskell.org/trac/ghc/wiki/Plugins
>
> ___
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users