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
(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!
==== Using vectorised code ==== Finally, we need a main module that calls the vectorised code, but is itself not vectorised, so that it may contain I/O. In this simple example, we convert two simple lists to parallel arrays, compute their dot product, and print the result: <haskell> import Data.Array.Parallel import Data.Array.Parallel.PArray (PArray, fromList) import DotP (dotp_wrapper) -- import vectorised code main :: IO () main = let v = fromList [1..10] -- convert lists... w = fromList [1,2..20] -- ...to parallel arrays result = dotp_wrapper v w -- invoke vectorised code in print result -- print the result </haskell> We compile this module with <blockquote> <code>ghc -c -Odph -fdph-par Main.hs</code> </blockquote> and finally link the two modules into an executable <code>dotp</code> with <blockquote> <code>ghc -o dotp -threaded -fdph-par -rtsopts DotP.o Main.o</code> </blockquote> We need the <code>-threaded</code> option to link with GHC's multi-threaded runtime and <code>-fdph-par</code> to link with the standard parallel DPH backend. We include <code>-rtsopts</code> to be able to explicitly determine the number of OS threads used to execute our code.
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