[Edinburgh-pm] parallel semantics in perl
Nick
oinksocket at letterboxes.org
Tue Dec 14 03:04:41 PST 2010
On 13/12/10 20:15, Wim Vanderbauwhede wrote:
> I'm looking into a way to run Perl on a manycore or multiprocessor
> system without visible threads or forks.
Are you interested in syntax or implementation? I'm guessing the former.
Anyway, Google finds this - I've not read this in detail, but it may be
relevant. Perhaps you've already read it.
http://www.dagolden.com/index.php/935/parallel-map-with-paralleliterator/
It works like this.
use Parallel::Iterator qw<iterate_as_array>;
my @result = iterate_as_array( $worker_sub, @list );
Presumably it could also easily work like this (using a (&) subroutine
prototype, i.e. sub iterate_as_array(&@) { ... } ):
my @result = iterate_as_array { stuff_here($_) } @list;
Or even, with a bit of Devel::Declare'ation, and dropping the assignment to
@result, you *might* be able to:
use Parallel qw<map>;
for_each my $i (@list) :par {
stuff_here($i);
}
Where for_each is still ultimately despatched to a function.
Unfortunately I believe Devel::Declare has a performance penalty, as well as
being bleeding edge and a bit complicated.
N
More information about the Edinburgh-pm
mailing list