<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Thanks a lot for the quick answer.<br><br>Accordingly, I have just changed the code into below one, however<br>sparks are still being pruned.<br><br>Do you have any other ideas?<br><br>Bests,<br>Burak.<br><br>------<br><br>split4ToEnc :: RSAPublicKey -> [Integer] -> [Integer]<br>split4ToEnc (PUB n e) [] = []<br>split4ToEnc (PUB n e) (x:xs) = <br> ((ersa (PUB n e) secondPart2) ++ (ersa (PUB n e) secondPart1) ++ (ersa (PUB n e) firstPart2) ++ (ersa (PUB n e) firstPart1)) `using` strategy<br> where <br> firstPart1 = fst (Main.splitAt((length (x:xs)) `div` 4) (fst(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br> firstPart2 = snd (Main.splitAt((length (x:xs)) `div` 4) (fst(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br> secondPart1 = fst (Main.splitAt((length (x:xs)) `div` 4) (snd(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br> secondPart2 = snd (Main.splitAt((length (x:xs)) `div` 4) (snd(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br> strategy res = do<br> (rpar `dot` rdeepseq) (ersa (PUB n e) firstPart1) <br> (rpar `dot` rdeepseq) (ersa (PUB n e) firstPart2) <br> (rpar `dot` rdeepseq) (ersa (PUB n e) secondPart1) <br> (rpar `dot` rdeepseq) (ersa (PUB n e) secondPart2)<br> rdeepseq res<br><br>-----<br><br><br><div>> From: aslatter@gmail.com<br>> Date: Sat, 24 Sep 2011 11:19:49 -0500<br>> Subject: Re: [Haskell-cafe] A Missing Issue on Second Generation Strategies<br>> To: ekcburak@hotmail.com<br>> CC: haskell-cafe@haskell.org<br>> <br>> On Sat, Sep 24, 2011 at 11:14 AM, Antoine Latter <aslatter@gmail.com> wrote:<br>> > 2011/9/24 Burak Ekici <ekcburak@hotmail.com>:<br>> >> Dear List,<br>> >><br>> >> I am trying to parallelize RSA encryption and decryption by using below<br>> >> manner,<br>> >> but when I run executable output file with "+RTS -s -N2" command on Windows<br>> >> 7,<br>> >> output stats say 4 sparks are being created however none of them converted<br>> >> into<br>> >> real OS threads.<br>> >><br>> >> -- SPARKS :4 (0 converted, 4 pruned) --<br>> >><br>> >> I was thinking that the problem could occur due to lack of forcing<br>> >> parallelization but,<br>> >> as far as I know 'rdeepseq' works for that aim.<br>> >><br>> >> Briefly, I could not solve the issue why parallelization was not being<br>> >> implemented.<br>> >> I would be appreciated if any of you shed a light on the issue that I<br>> >> missed.<br>> >><br>> >> Here is the mentioned part of code:<br>> >><br>> >> split4ToEnc :: RSAPublicKey -> [Integer] -> [Integer]<br>> >> split4ToEnc (PUB n e) [] = []<br>> >> split4ToEnc (PUB n e) (x:xs) =<br>> >> ((ersa (PUB n e) secondPart2) ++ (ersa (PUB n e) secondPart1) ++ (ersa (PUB<br>> >> n e) firstPart2) ++ (ersa (PUB n e) firstPart1)) `using` strategy<br>> >> where<br>> >> firstPart1 = fst (Main.splitAt((length (x:xs)) `div` 4) (fst(Main.splitAt<br>> >> ((length (x:xs)) `div` 2) (x:xs))))<br>> >> firstPart2 = snd (Main.splitAt((length (x:xs)) `div` 4) (fst(Main.splitAt<br>> >> ((length (x:xs)) `div` 2) (x:xs))))<br>> >> secondPart1 = fst (Main.splitAt((length (x:xs)) `div` 4)<br>> >> (snd(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br>> >> secondPart2 = snd (Main.splitAt((length (x:xs)) `div` 4)<br>> >> (snd(Main.splitAt ((length (x:xs)) `div` 2) (x:xs))))<br>> >> strategy res = do<br>> >> a <- rpar (ersa (PUB n e) (firstPart1) `using` rdeepseq)<br>> >> b <- rpar (ersa (PUB n e) (firstPart2) `using` rdeepseq)<br>> >> c <- rpar (ersa (PUB n e) (secondPart1) `using` rdeepseq)<br>> >> d <- rpar (ersa (PUB n e) (secondPart2) `using` rdeepseq)<br>> >> rdeepseq res<br>> >><br>> ><br>> > This isn't an area I'm expert in, but your strategy looks off to me -<br>> > since you're not using 'a', 'b', 'c' and 'd' anywhere, it would make<br>> > sense that you're not seeing much speedup. Also, the strategy doesn't<br>> > seem to be doing anything with it's input, which looks different from<br>> > most of the examples I've seen.<br>> ><br>> > In summary, your strategy doesn't appear to have anything relating it<br>> > to the computation you're doing with the `using`, if that makes any<br>> > sense.<br>> ><br>> <br>> May a better way to phrase things is that your strategy never does<br>> anything to its input (like force any parts of it to evaluate), it<br>> merely sparks of computations that no one ever looks at. Which is why<br>> they get pruned.<br>> <br>> ><br>> ><br>> >><br>> >> Thanks a lot,<br>> >> Burak.<br>> >><br>> >><br>> >><br>> >> _______________________________________________<br>> >> Haskell-Cafe mailing list<br>> >> Haskell-Cafe@haskell.org<br>> >> http://www.haskell.org/mailman/listinfo/haskell-cafe<br>> >><br>> >><br>> ><br></div>                                            </div></body>
</html>