Comments (8)
pval is a bit dodgy too, because it encourages you to share lazy computations between threads. I've never used pval in presentations, I always use (spawn . return). No objection to getting rid of it.
from monad-par.
Actually, I thought of one small reason not to. It may be a helpful optimization in some cases to implement pvals as (Full x) IVarContents where the 'x' is a lazy computation. That way they would be treated as futures usually are -- gets would never block, they would just do the work.
This trick can be done for spawn too, IF nested runPars work well and are cheap.
from monad-par.
On 13/10/2011 09:55, Ryan Newton wrote:
Actually, I thought of one small reason not to. It may be a helpful optimization in some cases to implement pvals as (Full x) IVarContents where the 'x' is a lazy computation. That way they would be treated as futures usually are -- gets would never block, they would just do the work.
This trick can be done for spawn too, IF nested runPars work well and are cheap.
But wouldn't that remove the parallelism in examples like
x <- pval a
y <- pval b
get x
get y
....
?
Cheers,
Simon
from monad-par.
Ah, you mean because X is gotten before y? Then assuming child stealing the first thief would have stolen X only to contend with the original thread.
There would still be some parallelism but it would require two steals. The second thief could work on Y while the main thread computes X.
from monad-par.
On 24/10/2011 14:38, Ryan Newton wrote:
Ah, you mean because X is gotten before y? Then assuming child
stealing the first thief would have stolen X only to contend with the
original thread.There would still be some parallelism but it would require two
steals. The second thief could work on Y while the main thread
computes X.
I'm not sure I understand. You first said:
It may be a helpful optimization in some cases to implement pvals as
(Full x) IVarContents where the 'x' is a lazy computation
which implied to me that pval would not include a fork, and would not
create a stealable work item, but would just make an IVar that you could
block on. In which case, there's no parallelism in the example I gave:
x <- pval a
y <- pval b
get x
get y
....
regardless of how many steals happen.
I must have misunderstood what you meant - could you elaborate?
Cheers,
Simon
from monad-par.
Oops! Yes, indeed. I'm sorry, my original description was overly abbreviated. The idea would be to make them regular sparks. (Of course, if the main Par scheduler was not then using sparks this opens up the question of how well spark parallelism and thread parallelism cooperate.)
I hope my subsequent comment then makes more sense:
"This trick can be done for spawn too, IF nested runPars work well and are cheap."
That is spawn would use runPar to make the computation pure and then would spark it. That gets into dangerous terrain, however, because it would seem to require returning an IVar from that runPar and using it in the outer runPar!
from monad-par.
On 24/10/2011 15:50, Ryan Newton wrote:
Oops! Yes, indeed. I'm sorry, my original description was overly
abbreviated. The idea would be to make them regular sparks. (Of
course, if the main Par scheduler was not then using sparks this
opens up the question of how well spark parallelism and thread
parallelism cooperate.)I hope my subsequent comment then makes more sense:
"This trick can be done for spawn too, IF nested runPars work well
and are cheap."That is spawn would use runPar to make the computation pure and then
would spark it. That gets into dangerous terrain, however, because
it would seem to require returning an IVar from that runPar and using
it in the outer runPar!
Ah, I see. I'm not keen on using a mixture of sparks and explicit
scheduling in Par - at the least, performance problems would be
difficult to debug. I see the great advantage of Par as being that we
can do away with the implicit/hidden/magic nature of sparks and have
full control of the scheduling in our library.
But don't let me stop you from experimenting!
Cheers,
Simon
from monad-par.
Yes, I feel compelled to try every scheduling strategy and gather data on all of them ;-).
Also, I fear that we will always have to deal with pure code that creates sparks.
from monad-par.
Related Issues (20)
- Second listing in "Other Slides" 404s HOT 2
- Test suite fails on powerpc HOT 11
- Is it possible to add a MonadFix instance? HOT 1
- ST monad trick HOT 2
- Support more IO operations for ParIO monad HOT 1
- Offer a version of put that can run multiple times HOT 3
- Offer lazy put and newFull
- Can we improve reschedule? HOT 1
- Why is LiftIO the way it is?
- Add CI HOT 1
- Improve exception story
- The Direct module exposes way too much HOT 1
- Harmonize MonadCont for Trace and Direct HOT 2
- Chase-Lev queue looks like trouble HOT 2
- monad-par-0.3.4.8 test suite does not compile with ghc-8.6.1 HOT 3
- monad-par-0.3.4.9 violated PVP by introducing new features HOT 2
- Trace sheduler works as stack, not a queue. HOT 5
- Build failures with mtl-2.3 HOT 2
- `monad-par-0.3.6` build failure with GHC 7.8.4 and 7.10.3 HOT 9
- [Docs Typo]Some links of reference in the comments were outdated HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monad-par.