Map and Spawn don't mix?

Russel Winder russel at russel.org.uk
Sun Mar 6 08:44:13 PST 2011


If I do:

  auto tasks = new Tid[numberOfTasks] ;  
  foreach ( i ; 0 .. numberOfTasks ) { tasks[i] = spawn ( & partialSum , thisTid , i , sliceSize , delta ) ; }

everything workls as desired, I get parallelism and appropriate scaling.
However if I try:

  auto tasks = map ! ( ( i ) { return spawn ( & partialSum , thisTid , i , sliceSize , delta ) ; } ) ( iota ( numberOfTasks ) ) ;

the code runs but everything is serialized, no parallelism, no speed up.

I would say this is a bug, but perhaps it is a consequence of the way map works?

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at russel.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110306/e7875978/attachment.pgp>


More information about the Digitalmars-d mailing list