Adding a Par construct to Python?

jeremy at martinfamily.freeserve.co.uk jeremy at martinfamily.freeserve.co.uk
Sun May 17 14:37:37 CEST 2009


On 17 May, 13:05, jer... at martinfamily.freeserve.co.uk wrote:
> From a user point of view I think that adding a 'par' construct to
> Python for parallel loops would add a lot of power and simplicity,
> e.g.
>
> par i in list:
>     updatePartition(i)
>
...actually, thinking about this further, I think it would be good to
add a 'sync' keyword which causes a thread rendezvous within a
parallel loop. This would allow parallel loops to run for longer in
certain circumstances without having the overhead of stopping and
restarting all the threads, e.g.

par i in list:
    for j in iterations:
       updatePartion(i)
       sync
       commitBoundaryValues(i)
       sync

This example is a typical iteration over a grid, e.g. finite elements,
calculation, where the boundary values need to be read by neighbouring
partitions before they are updated. It assumes that the new values of
the boundary values are stored in temporary variables until they can
be safely updated.

Jeremy



More information about the Python-list mailing list