-
Notifications
You must be signed in to change notification settings - Fork 24
Restore rparWith r0
documented behaviour
#34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It does not pass with the current implementation of `rparWith`.
I know the implementation of rparWith looks ugly, but the lazy 'Lift' box is necessary, to make sure rparWith has no built-in rseq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the same without optimization, but broken with optimization.
No it's not the order of the output of the test program changes, depending on the implementation of
|
The documentation for |
@Borgvall thanks for spotting the problem and for the test case! Yes we also need to fix the documentation. Personally I'd also like to have a better understanding of where the original implementation went wrong - @treeowl is there a succinct way to describe the problem that we could put in a comment? It would be nice if |
If we adopt my proposed |
I tried to reproduce the issue #17 with this branch, using the example code of the report, where I replaced module Main where
import Control.Parallel.Strategies
main :: IO ()
main = do let xs = take 1000 $ product . take 1000 . repeat <$> [1..]
x = product (xs `using` parTraversable rseq)
putStrLn (show x) |
#17 was fixed by using |
I think this PR can be closed. It's subsumed by #36. |
LazyBox printWhenEvaluated <- evaluate $ runEval $ do | ||
let printWhenEvaluated = unsafePerformIO $ putStrLn "Must be printed at the end." | ||
sparkedResult <- rparWith r0 printWhenEvaluated | ||
return $ LazyBox sparkedResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #3 has been accepted, one can simplify this mess after merge to master:
printWhenEvaluated <- unsafePerformIO (putStrnLn "Must be printed at the end.") `usingIO` rparWith r0
In addition I have added a test case, to prevent this regression in the future.