Concurrency.

Jude 10equals2 at gmail.com
Sun Nov 27 22:31:07 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/27/2011 11:51 PM, Debdata wrote:
> Hi,
> 
> I have been evaluating D for the past week, and have some concerns
> regarding the No Default sharing rule. I have been reading the D
> book by Andrei as well. This particular feature has been very
> confusing to me as I come from the c++ world.
> 
> I agree that message passing and resource hiding are a great way to
> go for a lot of cases, but there are an equally large (Larger?)
> number of cases that would benefit from global sharing. Especially
> when threading for performance rather than convenience. The cutting
> edge of high performance threading is really the task stealing
> approach. See intel's TBB, cilk, etc. Implementing things like that
> would become unnecessarily verbose as most things will be shared
> and we have to keep tagging.
> 
> Unless I am missing something. :D
> 
> -Debdatta Basu

Just wanted to make sure you know, there is a keyword to force global
storage: __gshared

Also D has std.parallelism, which seems to implement what you are
talking about...  Would this not be considered [the same as|close
enough to] task stealing?

wikipedia seems to think so...
TBB is a collection of components for parallel programming:
Basic algorithms: parallel_for, parallel_reduce, parallel_scan

void main() {
    // Parallel reduce can be combined with std.algorithm.map to
interesting
    // effect.  The following example (thanks to Russel Winder) calculates
    // pi by quadrature using std.algorithm.map and TaskPool.reduce.
    // getTerm is evaluated in parallel as needed by TaskPool.reduce.
    //
    // Timings on an Athlon 64 X2 dual core machine:
    //
    // TaskPool.reduce:       12.170 s
    // std.algorithm.reduce:  24.065 s

    immutable n = 1_000_000_000;
    immutable delta = 1.0 / n;

    real getTerm(int i) {
        immutable x = ( i - 0.5 ) * delta;
        return delta / ( 1.0 + x * x );
    }

    immutable pi = 4.0 * taskPool.reduce!"a + b"(
        std.algorithm.map!getTerm(iota(n)));
}


But I must admit that I really don't have much experience in this
regard and am more interested in hearing your responses. =P
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJO0yqrAAoJENcHIWLyQiSljswIAOQUG/jxDD6XjplV8vhhxkWQ
plxpAVZWv1Oi9TBpK6QB9PMP9qka+BGAPMmEFyoKv4EozcJHxYda3gfqZm+jKdEb
j2rcE/5ZSWvgcr2NcPiwhYIraYGGb4TqzhhHcN8mbebze3/Lnjf1tWpT9X9QEDLG
eSe/wNMagYHTYAzv1Q1ubbYzawyeyNPclPDDbEEdTVUsJhl02QxKFUxJTX0M2N6a
mHhd6DxOf9Pss9iZfjmegLe3Sz5/xxhZfwrYEisTirvRpElNOvzc2JttznFa7wEe
wVgUVQ844IHvcg06ecY8XFVbIbPUJMia5J6JGofcr4JmLbEDcXBydH33ffa4rAI=
=APH6
-----END PGP SIGNATURE-----


More information about the Digitalmars-d mailing list