[Edinburgh-pm] parallel semantics in perl

Wim Vanderbauwhede wim.vanderbauwhede at gmail.com
Tue Dec 14 04:35:54 PST 2010

Hi all,

Thanks again for all your answers
I should maybe give a little bit more information on my proposed
approach, rather than just ask for syntax suggestions.
I'm not attempting to solve the autoparallelisation problem, all I
want is an easier way to write programs for manycore/multiprocessor
machines (fsvo easy).

My approach is essentially to split the code in computational parts
and communication/control parts. The computational part runs
sequentially, computations will have to be handled by Perl objects.
The communication code is the one that does parallel evaluation. So it
is not my intention to support all of Perl for that part of the code.
You'll be free to add support for your favourite constructs as soon as
I get it on GitHub (which hopefully is next week).

Some of you were at my Gannet talk at ICSA, well I simply use a subset
of Perl as a high-level language for Gannet. It gets compiled into a
minimal functional language with stream support (Gannet). I already
have a PoC of the parser. The computational parts will be run on
embedded Perl interpreters at every core (most likely using libperl++,
other suggestions welcome).

Obviously if someone writes code with a sequential shared-memory
mental model, performance will be lousy, but if you take the trouble
to adopt a dataflow model, you can get very good performance.

My motivation is for applications such as BioPerl: lots of people
write stuff in Perl, and if they have access to a big machine it could
go really fast without needing a rewrite in C.

Posting my idea on this list is definitely a great reality check :-)



On 14 December 2010 10:51, Miles Gould <miles at assyrian.org.uk> wrote:
> On Mon, Dec 13, 2010 at 08:15:09PM +0000, Wim Vanderbauwhede wrote:
>> I'm looking into a way to run Perl on a manycore or multiprocessor
>> system without visible threads or forks. To do so I want to assume
>> parallel evaluation, i.e. all independent statements in a block or
>> function argument list are evaluated in parallel. Similarly, loops are
>> sequential; but in many cases they can be unrolled and evaluated in
>> parallel.
> I'm not quite sure what you're asking. I see three possibilities:
> 1) Within each block, build up use-def chains, and try to run every set
> of nonorderable statements in parallel. Side-effecting builtins like
> "print" (but not, say, "open", because that's treated as a variable
> definition) dominate every statement that's after them in a lexical
> block, and purity of function calls is determined recursively.
> This may make no sense: I'd have to think about it harder. And really,
> if autoparallelisation were this easy, someone would have solved the
> problem by now.
> Thinking a /little/ bit harder: references and aliasing kill you here.
> But reference-heavy code is much rarer in Perl than it is in (to pick an
> example /purely/ at random) C++, so this might actually be somewhat
> useful, given a really good test suite.
> 2) Treat /blocks/ as sequential, but by default run different
> /invocations/ of blocks parallelly. So if I write, say,
> foreach my $flintstone (qw/Fred Barney Betty Wilma Bamm-bamm Dino Pebbles/) {
>        my $surname = surname($flintstone);
>        say "Yabba-dabba-doo, $flintstone $surname!";
> }
> then the assignment to $surname would always happen before the
> corresponding call to "say", but Fred's block would run in parallel with
> Barney's block, and so on.
> 3) As above, but only run invocations in parallel if the user has
> annotated them in some way.
>> For example, whereas statements in a bare {...} block will be
>> evaluated in parallel,  a do {...} could mean sequential evaluation. A
>> "foreach" in full could be parallel, a "for" sequential.
> In common with everyone else, I really hate this idea :-) I like Aaron's
> lexically-scoped pragma idea; failing that, I'd suggest simply adding
> "pfor", "pdo", "pgrep" keywords (or "sfor", "sdo" etc for option 2).
> Miles
> --
> for life is not a paragraph and death i think is no parenthesis
>  -- e e cummings
> _______________________________________________
> Edinburgh-pm mailing list
> Edinburgh-pm at pm.org
> http://mail.pm.org/mailman/listinfo/edinburgh-pm

If it's pointless, what's the point?
If there is a point to it, what's the point?
(Tibor Fischer, "The Thought Gang")

More information about the Edinburgh-pm mailing list