static voidpmergesort(long int * in, long int * tmp, long int n, int nthread){long int nhalf = n/2;if(n <= N_small){insertsort1(in, n);return;}if(nthread > 1){#pragma omp parallel num_threads(2){if(omp_get_thread_num() == 0)pmergesort(tmp, in, nhalf, nthread>>1);else pmergesort(tmp+nhalf, in+nhalf, n-nhalf, nthread>>1);}} else {mergesort3(tmp, in, nhalf);mergesort3(tmp+nhalf, in+nhalf, n-nhalf);}merge( tmp, in, nhalf, n);}
_______________________________________________
Are the tools of Control.Parallel comparable to OpenMP? Michael
--- On Thu, 5/26/11, michael rice <nowgate@yahoo.com> wrote:
From: michael rice <nowgate@yahoo.com>
Subject: Re: [Haskell-cafe] Parallel compilation and execution?
To: "David Virebayre" <dav.vire+haskell@gmail.com>
Cc: "Daniel Fischer" <daniel.is.fischer@googlemail.com>, haskell-cafe@haskell.org
Date: Thursday, May 26, 2011, 9:32 AM
Fair question. I copied the parallel version from: http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.htmlMichael
--- On Thu, 5/26/11, David Virebayre <dav.vire+haskell@gmail.com> wrote:
From: David Virebayre <dav.vire+haskell@gmail.com>
Subject: Re: [Haskell-cafe] Parallel compilation and execution?
To: "michael rice" <nowgate@yahoo.com>
Cc: haskell-cafe@haskell.org, "Daniel Fischer" <daniel.is.fischer@googlemail.com>
Date: Thursday, May 26, 2011, 8:56 AM2011/5/26 michael rice <nowgate@yahoo.com>
Thank, DanielMultiple threads are in evidence in my system monitor, but I wonder why I'm getting two different answers, one twice the other. The first is the parallel solution and the second is the non.Why do you add n1+n2+1 in the parallel program, but only n1+n2 in the non-parallel one ?
Michael==========={-import Control.Parallelnfib :: Int -> Intnfib n | n <= 1 = 1| otherwise = par n1 (pseq n2 (n1 + n2 + 1))where n1 = nfib (n-1)n2 = nfib (n-2)-}nfib :: Int -> Intnfib n | n <= 1 = 1| otherwise = nfib (n-1) + nfib (n-2)main = do putStrLn $ show $ nfib 39=============[michael@hostname ~]$ ghc --make -threaded nfib.hs[1 of 1] Compiling Main ( nfib.hs, nfib.o )Linking nfib ...[michael@hostname ~]$ ./nfib +RTS -N3204668309[michael@hostname ~]$ ghc --make nfib.hs[1 of 1] Compiling Main ( nfib.hs, nfib.o )Linking nfib ...[michael@hostname ~]$ ./nfib102334155[michael@hostname ~]$
-----Inline Attachment Follows-----_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe