Classes and Methods

PyGAS is composed of a small set of core components that implement the PGAS extension to Python, a modest set of convenience functions for higher-level functionality, and a collection of tools commonly used when writing programs using PyGAS.

Core Components

class pygas.Proxy(obj)[source]

This is the fundamental PyGAS object. It wraps an existing object and mimics its behavior, even when the original object is on a remote thread. UPC programmers can think of Proxies as shared pointers because they store a (thread_id, local_addr) tuple internally.

owner

The id of the thread where the original object resides.

__init__(obj)[source]

Initialize a Proxy to the given object.

Parameters:obj (object) – the object to be wrapped
resolve()[source]

Return a copy of the original object wrapped by this Proxy.

Return type:object
__getattr__(name)[source]

Get a copy of a remote attribute.

Parameters:name (string) – the attribute name
__setattr__(name, value)[source]

Set a remote attribute to a copy of a local object.

Parameters:
  • name (string) – the attribute name
  • value (object) – the new attribute value
Return type:

None

__call__(*args, **kwargs)[source]

Invoke the __call__ method on the original object and return a copy of the result.

Parameters:
  • args (dictionary) – positional arguments
  • kwargs – keyword arguments
Return type:

object

pygas.share(obj, from_thread=0)[source]

Create and broadcast a Proxy to the given object. This is a collective operation. It is effectively syntactic sugar for:

broadcast(Proxy(obj), from_thread=...)
Parameters:
  • obj (object) – the object to be shared.
  • from_thread (int) – the thread wishing to share obj.
Return type:

Proxy

Extended Components

pygas.THREADS = 1

The number of threads in this parallel job.

pygas.MYTHREAD = 0

The thread number of the current thread.

pygas.broadcast(obj, from_thread=0)[source]

Broadcast copies of the given object. This is a collective operation.

Parameters:
  • obj (object) – the object to be copied.
  • from_thread (int) – the thread wishing to copy obj.
Returns:

A copy of the given object.

Miscellaneous Tools

class pygas.SplitTimer(name='timer')[source]

Implements a context manager that simplifies timing sections of code. Use like:

with SplitTimer("computation") as timer:
    compute()
print timer.report()
average()[source]

Average time of all splits.

Return type:float
report()[source]

Return report of performance.

Return type:string

Table Of Contents

Previous topic

Tutorial

Next topic

Example Programs

This Page