Skip to content
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

Edit section Single Machine Concurrency #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nushio3
Copy link

@nushio3 nushio3 commented Sep 4, 2015

Add parallel-io to the list of the Single Machine Concurrency libraries.

Add parallel-io to the list of the Single Machine Concurrency libraries.
@nushio3
Copy link
Author

nushio3 commented Sep 4, 2015

parallel-io is the first-aid-cure-all medicine I use whenever I find my Haskell program slow and my many CPU cores vacant except one. For really compute-heavy task we Haskellers have more professional tools such as accelerate in our arsenal, but for any other casual programming parallel is just satisfactory. It is a Haskeller's joy to see all your program suddenly parallelize, since the code you write is 100% pure, and all the CPU cores utilized.

p.s. don't forget to deepseq the results of the individual computations!

@Gabriella439
Copy link
Owner

Normally I would use the async library for this purpose, specifically the mapConcurrently function or the Concurrently applicative. For example, the parallel function can be implemented either as:

parallel = mapConcurrently id

-- or:

parallel = runConcurrently . sequenceA . Concurrently

Also, both libraries are implemented in roughly the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants