in reply to Getting started with MCE (the Many-Core Engine)
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:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting started with MCE (the Many-Core Engine)
by Anonymous Monk on Jun 11, 2018 at 15:39 UTC | |
by 1nickt (Canon) on Jun 11, 2018 at 18:14 UTC | |
by Anonymous Monk on Jun 13, 2018 at 00:18 UTC | |
by marioroy (Prior) on Jun 13, 2018 at 13:37 UTC | |
by Anonymous Monk on Jun 13, 2018 at 15:30 UTC | |
| |
by vr (Curate) on Jun 11, 2018 at 19:45 UTC | |
by Anonymous Monk on Jun 12, 2018 at 17:45 UTC | |
by Anonymous Monk on Jun 12, 2018 at 17:18 UTC |