X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fusing.sgml;h=2c8e1ca6f6b2761dab6edca3e5c3e82f9d5656f8;hb=182b16bccea2eab1a8af93a6246db3d391e436c7;hp=69cd3d052d4a661ded1edae37fa44087c6bf2546;hpb=29920fbc163944859166a6fde6136e6db50982ef;p=ghc-hetmet.git diff --git a/ghc/docs/users_guide/using.sgml b/ghc/docs/users_guide/using.sgml index 69cd3d0..2c8e1ca 100644 --- a/ghc/docs/users_guide/using.sgml +++ b/ghc/docs/users_guide/using.sgml @@ -4,61 +4,6 @@ GHC, using using GHC - GHC can work in one of three “modes”: - - - - ghc - --interactive - - interactive mode - - ghci - - - Interactive mode, which is also available as - ghci. Interactive mode is described in - more detail in . - - - - - ghc - --make - - make mode - - - - - In this mode, GHC will build a multi-module Haskell - program automatically, figuring out dependencies for itself. - If you have a straightforward Haskell program, this is - likely to be much easier, and faster, than using - make. - - - - - - ghc - - -E - -C - -S - -c - - - - - - This is the traditional batch-compiler mode, in which - GHC can compile source files one at a time, or link objects - together into an executable. - - - - Options overview @@ -160,14 +105,9 @@ module X where pragma in a source file or set from the GHCi command-line with :set. - As a rule of thumb, all the language options are dynamic, as - are the warning options and the debugging options. The rest are - static, with the notable exceptions of , - , , - , and . - - The flag reference tables () lists - the status of each flag. + As a rule of thumb, options which relate to filenames are + static, and the rest are dynamic. The flag reference tables () lists the status of each flag. @@ -242,6 +182,332 @@ module X where + + Modes of operation + + GHC's behaviour is firstly controlled by a mode flag. Only + one of these flags may be given, but it does not necessarily need + to be the first option on the command-line. The available modes + are: + + + + ghc + ––interactive + + interactive mode + + ghci + + + Interactive mode, which is also available as + ghci. Interactive mode is described in + more detail in . + + + + + ghc + ––make + + make mode + + + + + In this mode, GHC will build a multi-module Haskell + program automatically, figuring out dependencies for itself. + If you have a straightforward Haskell program, this is + likely to be much easier, and faster, than using + make. Make mode is described in . + + + + + ghc + –e expr + + eval mode + + + Expression-evaluation mode. This is very similar to + interactive mode, except that there is a single expression + to evaluate (expr) which is given + on the command line. See for + more details. + + + + + + ghc + + -E + -C + -S + -c + + + + + + + + This is the traditional batch-compiler mode, in which + GHC can compile source files one at a time, or link objects + together into an executable. This mode also applies if + there is no other mode flag specified on the command line, + in which case it means that the specified files should be + compiled and then linked to form a program. See . + + + + + ghc + –M + dependency-generation mode + + + Dependency-generation mode. In this mode, GHC can be + used to generate dependency information suitable for use in + a Makefile. See . + + + + + ghc + ––mk-dll + dependency-generation mode + + + DLL-creation mode (Windows only). See . + + + + + + Using <command>ghc</command> <option>––make</option> + + + + separate compilation + + + When given the option, + GHC will build a multi-module Haskell program by following + dependencies from a single root module (usually + Main). For example, if your + Main module is in a file called + Main.hs, you could compile and link the + program like this: + + +ghc ––make Main.hs + + + The command line may contain any number of source file + names or module names; GHC will figure out all the modules in + the program by following the imports from these initial modules. + It will then attempt to compile each module which is out of + date, and finally if there is a Main module, + the program will also be linked into an executable. + + The main advantages to using ghc + ––make over traditional + Makefiles are: + + + + GHC doesn't have to be restarted for each compilation, + which means it can cache information between compilations. + Compiling a muli-module program with ghc + ––make can be up to twice as fast as + running ghc individually on each source + file. + + + You don't have to write a + Makefile. + + Makefilesavoiding + + + GHC re-calculates the dependencies each time it is + invoked, so the dependencies never get out of sync with the + source. + + + + Any of the command-line options described in the rest of + this chapter can be used with + , but note that any options + you give on the command line will apply to all the source files + compiled, so if you want any options to apply to a single source + file only, you'll need to use an OPTIONS + pragma (see ). + + If the program needs to be linked with additional objects + (say, some auxilliary C code), then the object files can be + given on the command line and GHC will include them when linking + the executable. + + Note that GHC can only follow dependencies if it has the + source file available, so if your program includes a module for + which there is no source file, even if you have an object and an + interface file for the module, then GHC will complain. The + exception to this rule is for package modules, which may or may + not have source files. + + The source files for the program don't all need to be in + the same directory; the option can be used + to add directories to the search path (see ). + + + + Expression evaluation mode + + This mode is very similar to interactive mode, except that + there is a single expression to evaluate which is specified on + the command line as an argument to the + option: + + +ghc -e expr + + + Haskell source files may be named on the command line, and + they will be loaded exactly as in interactive mode. The + expression is evaluated in the context of the loaded + modules. + + For example, to load and run a Haskell program containing + a module Main, we might say + + +ghc -e Main.main Main.hs + + + or we can just use this mode to evaluate expressions in + the context of the Prelude: + + +$ ghc -e "interact (unlines.map reverse.lines)" +hello +olleh + + + + + Batch compiler mode + + In this mode, GHC will compile one or more source files + given on the command line. + + The first phase to run is determined by each input-file + suffix, and the last phase is determined by a flag. If no + relevant flag is present, then go all the way through linking. + This table summarises: + + + + + + + + + + + Phase of the compilation system + Suffix saying “start here” + Flag saying “stop after” + (suffix of) output file + + + + + literate pre-processor + .lhs + - + .hs + + + + C pre-processor (opt.) + .hs (with + ) + + .hspp + + + + Haskell compiler + .hs + , + .hc, .s + + + + C compiler (opt.) + .hc or .c + + .s + + + + assembler + .s + + .o + + + + linker + other + - + a.out + + + + + + + + + + + Thus, a common invocation would be: + + +ghc -c Foo.hs + + to compile the Haskell source file + Foo.hs to an object file + Foo.o. + + Note: What the Haskell compiler proper produces depends on + whether a native-code generatornative-code + generator is used (producing assembly + language) or not (producing C). See for more details. + + Note: C pre-processing is optional, the + + flag turns it on. See for more + details. + + Note: The option -E + option runs just the pre-processing passes + of the compiler, dumping the result in a file. Note that this + differs from the previous behaviour of dumping the file to + standard output. + + + Help and verbosity options @@ -250,10 +516,10 @@ module X where - -help - -? - -? - -help + + + + Cause GHC to spew a long usage message to standard output and then exit. @@ -261,8 +527,8 @@ module X where - -v - -v + + The option makes GHC verbose: it reports its version number @@ -279,7 +545,7 @@ module X where - -vn + n To provide more control over the compiler's verbosity, @@ -290,7 +556,7 @@ module X where - -v0 + Disable all non-essential messages (this is the default). @@ -298,17 +564,17 @@ module X where - -v1 + Minimal verbosity: print one line per compilation (this is the default when - or - is on). + or + is on). - -v2 + Print the name of each compilation phase as it is executed. (equivalent to @@ -317,7 +583,7 @@ module X where - -v3 + The same as , except that in addition the full command line (if appropriate) for @@ -326,7 +592,7 @@ module X where - -v4 + The same as except that the intermediate program representation after each @@ -339,402 +605,43 @@ module X where - --version - --version + + + + Print a one-line string including GHC's version number. - --numeric-version - --numeric-version + + Print GHC's numeric version number only. - - - - - Using <command>ghc</command> <option>--make</option> - - - - separate compilation - - - When given the option, GHC will - build a multi-module Haskell program by following dependencies - from a single root module (usually Main). For - example, if your Main module is in a file - called Main.hs, you could compile and link - the program like this: - - -ghc --make Main.hs - - - The command line must contain one source file or module - name; GHC will figure out all the modules in the program by - following the imports from this initial module. It will then - attempt to compile each module which is out of date, and finally - if the top module is Main, the program - will also be linked into an executable. - - The main advantages to using ghc --make - over traditional Makefiles are: - - - - GHC doesn't have to be restarted for each compilation, - which means it can cache information between compilations. - Compiling a muli-module program with ghc - --make can be up to twice as fast as running - ghc individually on each source - file. - - - You don't have to write a - Makefile. - - Makefilesavoiding - - - GHC re-calculates the dependencies each time it is - invoked, so the dependencies never get out of sync with the - source. - - - - Any of the command-line options described in the rest of - this chapter can be used with , but note - that any options you give on the command line will apply to all - the source files compiled, so if you want any options to apply to - a single source file only, you'll need to use an - OPTIONS pragma (see ). - - If the program needs to be linked with additional objects - (say, some auxilliary C code), these can be specified on the - command line as usual. - - - - GHC without <option>--make</option> - - Without , GHC will compile one or - more source files given on the command line. - - The first phase to run is determined by each input-file - suffix, and the last phase is determined by a flag. If no - relevant flag is present, then go all the way through linking. - This table summarises: - - - - - - - - - - - Phase of the compilation system - Suffix saying “start here” - Flag saying “stop after” - (suffix of) output file - - - - - literate pre-processor - .lhs - - - .hs - - - - C pre-processor (opt.) - - .hs (with - ) - - .hspp - - - - Haskell compiler - .hs - , - .hc, .s - - - - C compiler (opt.) - .hc or .c - - .s - - - - assembler - .s - - .o - - - - linker - other - - - a.out - - - - - - - - - - - Thus, a common invocation would be: ghc -c - Foo.hs - - Note: What the Haskell compiler proper produces depends on - whether a native-code generatornative-code - generator is used (producing assembly - language) or not (producing C). See for more details. - - Note: C pre-processing is optional, the - - flag turns it on. See for more details. - - Note: The option -E - option runs just the pre-processing passes - of the compiler, dumping the result in a file. Note that this - differs from the previous behaviour of dumping the file to - standard output. - - - - Re-directing the compilation output(s) - - output-directing options - redirecting compilation output - - - -o - -o + + - GHC's compiled output normally goes into a - .hc, .o, etc., - file, depending on the last-run compilation phase. The - option -o - option re-directs the output of that - last-run phase to file foo. - - Note: this “feature” can be - counterintuitive: ghc -C -o foo.o foo.hs - will put the intermediate C code in the file - foo.o, name notwithstanding! + Print the path to GHC's library directory. This is + the top of the directory tree containing GHC's libraries, + interfaces, and include files (usually something like + /usr/local/lib/ghc-5.04 on Unix). This + is the value of + $libdirlibdir + in the package configuration file (see ). - - -odir - -odir - - The option isn't of much use if - you have several input files… - Non-interface output files are normally put in the same - directory as their corresponding input file came from. You - may specify that they be put in another directory using the - -odir - <dir> option (the “Oh, - dear” option). For example: - - -% ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch` - - - The output files, Foo.o, - Bar.o, and - Bumble.o would be put into a - subdirectory named after the architecture of the executing - machine (sun4, - mips, etc). The directory must already - exist; it won't be created. - - Note that the option does - not affect where the interface files - are put. In the above example, they would still be put in - parse/Foo.hi, - parse/Bar.hi, and - gurgle/Bumble.hi. - - - - - -ohi - -ohi - - - - - - - -osuf - -hisuf - -osuf - -hisuf - - EXOTICA: The -osuf - <suffix> option will change the - .o file suffix for object files to - whatever you specify. (We use this in compiling the - prelude.). - - Similarly, the -hisuf - <suffix> option will change the - .hi file suffix for non-system - interface files (see ). - - The / - game is useful if you want to compile a program with both - GHC and HBC (say) in the same directory. Let HBC use the - standard .hi/.o - suffixes; add to your make rule for - GHC compiling… - - - - - Keeping Intermediate Files - intermediate files, saving - - .hc files, saving - - .s files, saving - - - - The following options are useful for keeping certain - intermediate files around, when normally GHC would throw these - away after compilation: - - - - -keep-hc-files - - -keep-hc-files - - - Keep intermediate .hc files when - doing .hs-to-.o - compilations via C (NOTE: .hc files - aren't generated when using the native code generator, you - may need to use -fvia-C to force them - to be produced). - - - - - -keep-s-files - - -keep-s-files - - - Keep intermediate .s files. - - - - - -keep-raw-s-files - - -keep-raw-s-files - - - Keep intermediate .raw-s files. - These are the direct output from the C compiler, before - GHC does “assembly mangling” to produce the - .s file. Again, these are not produced - when using the native code generator. - - - - - -keep-tmp-files - - -keep-tmp-files - - - temporary files - keeping - - - Instructs the GHC driver not to delete any of its - temporary files, which it normally keeps in - /tmp (or possibly elsewhere; see ). Running GHC with - -v will show you what temporary files - were generated along the way. - - - - - - - Redirecting temporary files - - - temporary files - redirecting - - - - - -tmpdir - -tmpdir - - If you have trouble because of running out of space - in /tmp (or wherever your - installation thinks temporary files should go), you may - use the -tmpdir - <dir> option option to specify - an alternate directory. For example, says to put temporary files in the current - working directory. - - Alternatively, use your TMPDIR - environment variable.TMPDIR - environment variable Set it to the - name of the directory where temporary files should be put. - GCC and other programs will honour the - TMPDIR variable as well. - - Even better idea: Set the - DEFAULT_TMPDIR make variable when - building GHC, and never worry about - TMPDIR again. (see the build - documentation). - - - - - + &separate; + Warnings and sanity-checking @@ -747,7 +654,7 @@ ghc --make Main.hs generated during compilation. By default, you get a standard set of warnings which are generally likely to indicate bugs in your program. These are: - , + , , , , and @@ -764,7 +671,8 @@ ghc --make Main.hs Provides the standard warnings plus , , - and + , + , and . @@ -772,7 +680,7 @@ ghc --make Main.hs : - -w option + Turns off all warnings, including the standard ones. @@ -780,11 +688,20 @@ ghc --make Main.hs : - -Wall option + Turns on all warning options. + + : + + + Makes any warning into a fatal error. Useful so that you don't + miss warnings when doing batch compilation. + + + The full set of warning options is described below. To turn @@ -809,7 +726,7 @@ ghc --make Main.hs : - -fwarn-duplicate-exports option + duplicate exports, warning export lists, duplicates @@ -826,7 +743,7 @@ ghc --make Main.hs : - -fwarn-hi-shadowing option + shadowing interface files @@ -840,7 +757,7 @@ ghc --make Main.hs : - -fwarn-incomplete-patterns option + incomplete patterns, warning patterns, incomplete @@ -862,9 +779,20 @@ g [] = 2 + : + + + Turns on warnings for various harmless but untidy + things. This currently includes: importing a type with + (..) when the export is abstract, and + listing duplicate class assertions in a qualified type. + + + + : - -fwarn-missing-fields option + missing fields, warning fields, missing @@ -879,7 +807,7 @@ g [] = 2 : - -fwarn-missing-methods option + missing methods, warning methods, missing @@ -887,13 +815,25 @@ g [] = 2 an instance declaration is missing one or more methods, and the corresponding class declaration has no default declaration for them. + The warning is suppressed if the method name + begins with an underscore. Here's an example where this is useful: + + class C a where + _simpleFn :: a -> String + complexFn :: a -> a -> String + complexFn x y = ... _simpleFn ... + + The idea is that: (a) users of the class will only call complexFn; + never _simpleFn; and (b) + instance declarations can define either complexFn or _simpleFn. + : - -fwarn-missing-signatures option + type signatures, missing If you would like GHC to check that every top-level @@ -906,7 +846,7 @@ g [] = 2 : - -fwarn-name-shadowing option + shadowing, warning This option causes a warning to be emitted whenever an @@ -924,7 +864,7 @@ g [] = 2 : - -fwarn-overlapping-patterns option + overlapping patterns, warning patterns, overlapping @@ -954,13 +894,27 @@ f "2" = 2 patterns that can fail, eg. \(x:xs)->.... Normally, these aren't treated as incomplete patterns by . + ``Lambda-bound patterns'' includes all places where there is a single pattern, + including list comprehensions and do-notation. In these cases, a pattern-match + failure is quite legitimate, and triggers filtering (list comprehensions) or + the monad fail operation (monads). For example: + + f :: [Maybe a] -> [a] + f xs = [y | Just y <- xs] + + Switching on will elicit warnings about + these probably-innocent cases, which is why the flag is off by default. + The deriving( Read ) mechanism produces monadic code with + pattern matches, so you will also get misleading warnings about the compiler-generated + code. (This is arguably a Bad Thing, but it's awkward to fix.) + : - -fwarn-type-defaults option + defaulting mechanism, warning Have the compiler warn/inform you where in your source the Haskell defaulting mechanism for numeric types kicks @@ -980,54 +934,66 @@ f "2" = 2 : - -fwarn-unused-binds option + unused binds, warning binds, unused Report any function definitions (and local bindings) which are unused. For top-level functions, the warning is only given if the binding is not exported. + A definition is regarded as "used" if (a) it is exported, or (b) it is + mentioned in the right hand side of another definition that is used, or (c) the + function it defines begins with an underscore. The last case provides a + way to suppress unused-binding warnings selectively. + Notice that a variable + is reported as unused even if it appears in the right-hand side of another + unused binding. : - -fwarn-unused-imports option + unused imports, warning imports, unused - Report any objects that are explicitly imported but - never used. + Report any modules that are explicitly imported but + never used. However, the form import M() is + never reported as an unused import, because it is a useful idiom + for importing instance declarations, which are anonymous in Haskell. : - -fwarn-unused-matches option + unused matches, warning matches, unused Report all unused variables which arise from pattern matches, including patterns consisting of a single variable. For instance f x y = [] would report - x and y as unused. To - eliminate the warning, all unused variables can be replaced - with wildcards. + x and y as unused. The + warning is suppressed if the variable name begins with an underscore, thus: + + f _x = True + + If you're feeling really paranoid, the - option-dcore-lint - option is a good choice. It turns on - heavyweight intra-pass sanity-checking within GHC. (It checks - GHC's sanity, not yours.) + + option + is a good choice. It turns on heavyweight intra-pass + sanity-checking within GHC. (It checks GHC's sanity, not + yours.) - &separate; &packages; @@ -1054,13 +1020,11 @@ f "2" = 2 following “packages” of optimisations (or lack thereof) should suffice. - Once you choose a - “package,” stick with it—don't chop and - change. Modules' interfaces will change - with a shift to a new option, and you may - have to recompile a large chunk of all importing modules before - your program can again be run safely (see ). + Note that higher optimisation levels cause more + cross-module optimisation to be performed, which can have an + impact on how much of your program needs to be recompiled when + you change something. This is one reaosn to stick to + no-optimisation when developing code. @@ -1097,6 +1061,10 @@ f "2" = 2 Means: “Generate good-quality code without taking too long about it.” Thus, for example: ghc -c -O Main.lhs + + currently also implies + . This may change in the + future. @@ -1121,23 +1089,11 @@ f "2" = 2 - : - -O2-for-C option - gcc, invoking with -O2 - - Says to run GCC with , which may - be worth a few percent in execution speed. Don't forget - , lest you use the native-code - generator and bypass GCC altogether! - - - - : -Ofile <file> option optimising, customised - (NOTE: not supported yet in GHC 5.x. Please ask if + (NOTE: not supported since GHC 4.x. Please ask if you're interested in this.) For those who need absolute @@ -1159,8 +1115,8 @@ f "2" = 2 We don't use a flag for day-to-day work. We use to get respectable speed; e.g., when we want to measure something. When we want to go for - broke, we tend to use (and - we go for lots of coffee breaks). + broke, we tend to use (and we go for + lots of coffee breaks). The easiest way to see what (etc.) “really mean” is to run with , @@ -1196,6 +1152,20 @@ f "2" = 2 + : + + + Causes GHC to ignore uses of the function + Exception.assert in source code (in + other words, rewriting Exception.assert p + e to e (see ). This flag is turned on by + . + + + + + @@ -1224,54 +1194,15 @@ f "2" = 2 This option causes all constructor fields which are marked strict (i.e. “!”) to be unboxed or - unpacked if possible. For example: - - -data T = T !Float !Float - - - will create a constructor T - containing two unboxed floats if the - flag is given. - This may not always be an optimisation: if the - T constructor is scrutinised and the - floats passed to a non-strict function for example, they - will have to be reboxed (this is done automatically by the - compiler). - - This option should only be used in conjunction with - , in order to expose unfoldings to the - compiler so the reboxing can be removed as often as - possible. For example: - - -f :: T -> Float -f (T f1 f2) = f1 + f2 - - - The compiler will avoid reboxing - f1 and f2 by - inlining + on floats, but only when - is on. - - Any single-constructor data is eligible for - unpacking; for example - - -data T = T !(Int,Int) - - - will store the two Ints directly - in the T constructor, by flattening - the pair. Multi-level unpacking is also supported: - - -data T = T !S -data S = S !Int !Int - - - will store two unboxed Int#s - directly in the T constructor. + unpacked if possible. It is equivalent to adding an + UNPACK pragma to every strict + constructor field (see ). + + This option is a bit of a sledgehammer: it might + sometimes make things worse. Selectively unboxing fields + by using UNPACK pragmas might be + better. @@ -1292,33 +1223,26 @@ data S = S !Int !Int - : - - - inlining, controlling - unfolding, controlling - - (Default: 30) By raising or lowering this number, - you can raise or lower the amount of pragmatic junk that - gets spewed into interface files. (An unfolding has a - “size” that reflects the cost in terms of - “code bloat” of expanding that unfolding in - another module. A bigger function would be assigned a - bigger cost.) - - - - : inlining, controlling unfolding, controlling - (Default: 30) This option is similar to - , except - that it governs unfoldings within a single module. - Increasing this figure is more likely to result in longer + (Default: 45) Governs the maximum size that GHC will + allow a function unfolding to be. (An unfolding has a + “size” that reflects the cost in terms of + “code bloat” of expanding that unfolding at + at a call site. A bigger function would be assigned a + bigger cost.) + + Consequences: (a) nothing larger than this will be + inlined (unless it has an INLINE pragma); (b) nothing + larger than this will be spewed into an interface + file. + + + Increasing this figure is more likely to result in longer compile times than faster code. The next option is more useful: @@ -1342,36 +1266,31 @@ data S = S !Int !Int - + - -&phases; - - + + &phases; + + Using Concurrent Haskell - -Concurrent Haskell—use - + Concurrent Haskell—use -GHC (as of version 4.00) supports Concurrent Haskell by default, -without requiring a special option or libraries compiled in a certain -way. To get access to the support libraries for Concurrent Haskell -(i.e. Concurrent and friends), use the - option. - +GHC supports Concurrent Haskell by default, without requiring a +special option or libraries compiled in a certain way. To get access +to the support libraries for Concurrent Haskell, just import +Control.Concurrent (details are in the accompanying +library documentation). -Three RTS options are provided for modifying the behaviour of the -threaded runtime system. See the descriptions of -, , and - in . +RTS options are provided for modifying the behaviour of the threaded +runtime system. See . -Concurrent Haskell is described in more detail in . +Concurrent Haskell is described in more detail in the documentation +for the Control.Concurrent module. @@ -1385,21 +1304,21 @@ LinkEnd="sec-Concurrent">. [You won't be able to execute parallel Haskell programs unless PVM3 -(Parallel Virtual Machine, version 3) is installed at your site.] - +(Parallel Virtual Machine, version 3) is installed at your site.] + To compile a Haskell program for parallel execution under PVM, use the - option,-parallel -option both when compiling and -linking. You will probably want to import -Parallel into your Haskell modules. - + option,-parallel +option both when compiling and +linking. You will probably want to import +Parallel into your Haskell modules. + To run your parallel program, once PVM is going, just invoke it “as normal”. The main extra RTS option is -, to say how many PVM +, to say how many PVM “processors” your program to run on. (For more details of all relevant RTS options, please see .) @@ -1411,8 +1330,8 @@ out of them (e.g., parallelism profiles) is a battle with the vagaries of PVM, detailed in the following sections. - -Dummy's guide to using PVM + +Dummy's guide to using PVM PVM, how to use @@ -1431,11 +1350,23 @@ setenv PVM_DPATH $PVM_ROOT/lib/pvmd Creating and/or controlling your “parallel machine” is a purely-PVM -business; nothing specific to Parallel Haskell. - +business; nothing specific to Parallel Haskell. The following paragraphs +describe how to configure your parallel machine interactively. + - -You use the pvmpvm command command to start PVM on your + +If you use parallel Haskell regularly on the same machine configuration it +is a good idea to maintain a file with all machine names and to make the +environment variable PVM_HOST_FILE point to this file. Then you can avoid +the interactive operations described below by just saying + + + +pvm $PVM_HOST_FILE + + + +You use the pvmpvm command command to start PVM on your machine. You can then do various things to control/monitor your “parallel machine;” the most useful being: @@ -1497,8 +1428,8 @@ The PVM documentation can tell you much, much more about pvm! - -Parallelism profiles + +Parallelism profiles parallelism profiles @@ -1511,25 +1442,25 @@ With Parallel Haskell programs, we usually don't care about the results—only with “how parallel” it was! We want pretty pictures. - -Parallelism profiles (à la hbcpp) can be generated with the --q RTS option (concurrent, parallel) RTS option. The + +Parallelism profiles (à la hbcpp) can be generated with the +-qP RTS option (concurrent, parallel) RTS option. The per-processor profiling info is dumped into files named -<full-path><program>.gr. These are then munged into a PostScript picture, +<full-path><program>.gr. These are then munged into a PostScript picture, which you can then display. For example, to run your program -a.out on 8 processors, then view the parallelism profile, do: - +a.out on 8 processors, then view the parallelism profile, do: + - + -% ./a.out +RTS -N8 -q -% grs2gr *.???.gr > temp.gr # combine the 8 .gr files into one -% gr2ps -O temp.gr # cvt to .ps; output in temp.ps -% ghostview -seascape temp.ps # look at it! +$ ./a.out +RTS -qP -qp8 +$ grs2gr *.???.gr > temp.gr # combine the 8 .gr files into one +$ gr2ps -O temp.gr # cvt to .ps; output in temp.ps +$ ghostview -seascape temp.ps # look at it! - + The scripts for processing the parallelism profiles are distributed @@ -1538,13 +1469,13 @@ in ghc/utils/parallel/. - -Other useful info about running parallel programs + +Other useful info about running parallel programs - + The “garbage-collection statistics” RTS options can be useful for seeing what parallel programs are doing. If you do either --Sstderr RTS option or , then +-Sstderr RTS option or , then you'll get mutator, garbage-collection, etc., times on standard error. The standard error of all PE's other than the `main thread' appears in /tmp/pvml.nnn, courtesy of PVM. @@ -1577,12 +1508,12 @@ for concurrent/parallel execution. - -: - - --N<N> RTS option (parallel) -(PARALLEL ONLY) Use <N> PVM processors to run this program; + +: + + +-qp<N> RTS option +(PARALLEL ONLY) Use <N> PVM processors to run this program; the default is 2. @@ -1616,60 +1547,98 @@ records the movement of threads between the green (runnable) and red green queue is split into green (for the currently running thread only) and amber (for other runnable threads). We do not recommend that you use the verbose suboption if you are planning to use the -hbcpp profiling tools or if you are context switching at every heap -check (with ). - - - - -: - - --t<num> RTS option -(PARALLEL ONLY) Limit the number of concurrent threads per processor -to <num>. The default is 32. Each thread requires slightly over 1K -words in the heap for thread state and stack objects. (For -32-bit machines, this translates to 4K bytes, and for 64-bit machines, -8K bytes.) - - - - -: - - --d RTS option (parallel) +hbcpp profiling tools or if you are context switching at every heap +check (with ). +--> + + + + +: + + +-qt<num> RTS option +(PARALLEL ONLY) Limit the thread pool size, i.e. the number of concurrent +threads per processor to <num>. The default is +32. Each thread requires slightly over 1K words in +the heap for thread state and stack objects. (For 32-bit machines, this +translates to 4K bytes, and for 64-bit machines, 8K bytes.) + + + + + +: + + +-qe<num> RTS option +(parallel) (PARALLEL ONLY) Limit the spark pool size +i.e. the number of pending sparks per processor to +<num>. The default is 100. A larger number may be +appropriate if your program generates large amounts of parallelism +initially. + + + + +: + + +-qQ<num> RTS option (parallel) (PARALLEL ONLY) Set the size of packets transmitted between processors -to <num>. The default is 1024 words. A larger number may be +to <num>. The default is 1024 words. A larger number may be appropriate if your machine has a high communication cost relative to computation speed. - - - + + + + +: + + +-qh<num> RTS option (parallel) +(PARALLEL ONLY) Select a packing scheme. Set the number of non-root thunks to pack in one packet to +<num>-1 (0 means infinity). By default GUM uses full-subgraph +packing, i.e. the entire subgraph with the requested closure as root is +transmitted (provided it fits into one packet). Choosing a smaller value +reduces the amount of pre-fetching of work done in GUM. This can be +advantageous for improving data locality but it can also worsen the balance +of the load in the system. + + + + +: + + +-qg<num> RTS option +(parallel) (PARALLEL ONLY) Select a globalisation +scheme. This option affects the +generation of global addresses when transferring data. Global addresses are +globally unique identifiers required to maintain sharing in the distributed +graph structure. Currently this is a binary option. With <num>=0 full globalisation is used +(default). This means a global address is generated for every closure that +is transmitted. With <num>=1 a thunk-only globalisation scheme is +used, which generated global address only for thunks. The latter case may +lose sharing of data but has a reduced overhead in packing graph structures +and maintaining internal tables of global addresses. + + + @@ -1727,6 +1696,48 @@ statements or clauses. &runtime; + + + Generating and compiling External Core Files + + intermediate code generation + + GHC can dump its optimized intermediate code (said to be in “Core” format) + to a file as a side-effect of compilation. Core files, which are given the suffix + .hcr, can be read and processed by non-GHC back-end + tools. The Core format is formally described in An External Representation for the GHC Core Language, + and sample tools (in Haskell) + for manipulating Core files are available in the GHC source distribution + directory /fptools/ghc/utils/ext-core. + Note that the format of .hcr + files is different (though similar) to the Core output format generated + for debugging purposes (). + + The Core format natively supports notes which you can add to + your source code using the CORE pragma (see ). + + + + + + + + + + Generate .hcr files. + + + + + +GHC can also read in External Core files as source; just give the .hcr file on +the command line, instead of the .hs or .lhs Haskell source. +A current infelicity is that you need to give teh -fglasgow-exts flag too, because +ordinary Haskell 98, when translated to External Core, uses things like rank-2 types. + + &debug; &flags;