use strict; use warnings; use MCE; use MCE::Loop; use MCE::Shared; my $volume = 1e9; # crank it up my $max_workers = MCE::Util::get_ncpu; my $chunk_size = int $volume / $max_workers; MCE::Loop::init { max_workers => $max_workers, chunk_size => $chunk_size, bounds_only => 1, }; my $fu = MCE::Shared-> scalar( 0 ); mce_loop_s { # note "s" my $partial_result = 0; my ( $begin, $end ) = @$_; $partial_result += $_ for $begin .. $end; print 'Worker', MCE-> wid, ' here, my partial result is ', $partial_result, "\n"; $fu-> incrby( $partial_result ); } 1, $volume; print "\nDone: @{[ $fu-> get ]}\n"; __END__ Worker4 here, my partial result is 218750000125000000 Worker1 here, my partial result is 31250000125000000 Worker3 here, my partial result is 156250000125000000 Worker2 here, my partial result is 93750000125000000 Done: 500000000500000000

Hi, not sure if it explains for dummies or not. Feel free to ask further, if it doesn't. Important:


In reply to Re: Getting started with MCE (the Many-Core Engine) by vr
in thread Getting started with MCE (the Many-Core Engine) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.