Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Haskell
Wiki community
Recent changes
Random page
HaskellWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
GHC/Data Parallel Haskell/GHC.PArr
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Convenience without the speed: syntactic sugar for a high-level array library == The following explains how to install and use parallel arrays and array comprehensions to prototype nested data-parallel algorithms in Haskell. But your programs will only run sequentially! That's what we mean by "convenience without speed"! === Installation === Any compiler in GHC's 6.8 series includes support for parallel arrays. It is invoked by supplying the compiler option <tt>-XPArr</tt> and importing the module <hask>GHC.PArr</hask>. Moreover, to use [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#parallel-list-comprehensions parallel array comprehensions], the compiler option <tt>-fglasgow-exts</tt> is required. '''Caveat:''' This version of DPH is essentially an initial high-level prototype that we '''do not support''' anymore. Feel free to use it to experiment with the array syntax, but please do not expect good performance. === A small example === The following module implements the dot product of two vectors using parallel arrays: <haskell> {-# OPTIONS -fparr -fglasgow-exts #-} module DotP (dotp) where import GHC.PArr dotp :: Num a => [:a:] -> [:a:] -> a dotp xs ys = sumP [:x * y | x <- xs | y <- ys:] </haskell> You can use this module in an interactive GHCi session as follows: <blockquote><pre> Prelude> :set -fparr -fglasgow-exts Prelude> :load DotP [1 of 1] Compiling DotP ( code/haskell/DotP.hs, interpreted ) Ok, modules loaded: DotP. *DotP> dotp [:1..3:] [:4..6:] 32 *DotP> </pre></blockquote> (NB: The <tt>:set</tt> is needed despite the <tt>OPTIONS</tt> pragma in <tt>DotP.hs</tt>, so that you can use array syntax on the interactive command line of GHCi.) Unfortunately, the current version of Haddock does not grok the special array syntax, so there is no nice HTML version of the interface of <hask>GHC.PArr</hask>. Instead, please consult the [http://darcs.haskell.org/packages/base/GHC/PArr.hs source code of <hask>GHC.PArr</hask>] for details on the supplied array operations.
Summary:
Please note that all contributions to HaskellWiki are considered to be released under simple permissive license (see
HaskellWiki:Copyrights
for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Cancel
Editing help
(opens in new window)
Toggle limited content width