Contexts in ScotchPy¶
Contexts are implemented in ScotchPy with the Context class.
The Context class¶
- class Context(init=True)¶
The graph constructor itself calls libscotch’s
contextAllocfunction, and usuallycontextInitis called too.- Parameters:
init – If True, the context allocation is followed by the init. If not, the
init()method needs to be called before.
- init()¶
This routine Initializes the fields of the Context object instance. Called by a class constructor when
init=True(by default). Mandatory before calling context routines or after callingexit()in order to re-use the same Context instance.
- exit()¶
This routine cleans-up all fields of the instance. Is the opposite of the
init()routine. Called automatically when the object is destroyed. Calling explicitly this method is only required when aninit()call follows.
- option_get_num(optinum, optival)¶
This routine retrieves the value of a given integer context value of index
optinuminoptival.- Parameters:
optinum (Integer) – The index of the context value to retrieve.
optival (Integer) – The value of the context value.
- option_set_num(optinum, optival)¶
This routine sets the value of a given integer context value of index
optinumtooptival.- Parameters:
optinum (Integer) – The index of the context value to set.
optival (Integer) – The value of the context value.
- random_clone()¶
This routine clones the current state of the random number generator of the context.
- random_reset()¶
This routine resets the state of the random number generator of the context.
- random_seed(seedval)¶
This routine sets the state of the random number generator of the context with the given seed.
- Parameters:
seedval (Integer) – The seed value.
- thread_import1(thrdnbr)¶
This routine initiates the capture, into the context, of an existing pool of threads. It must be called only by the master thread providing
thrdnbrnumber of threads (including the master thread itself).- Parameters:
thrdnbr (Integer) – The number of threads to capture.
- thread_import2(thrdnum)¶
This routine captures the
thrdnumthread as a slave thread of the context. It must be called by each slave thread and the master thread after them.threading.Threadmust be used here. See in “tests/test_context.py” for an example.- Parameters:
thrdnum (Integer) – The number of the thread to capture.
- thread_spawn(thrdnbr, coretab)¶
This routine populates the context with a pool of
thrdnbr- 1 slave threads, in addition to the master thread.- Parameters:
thrdnbr (Integer) – The number of threads to spawn.
coretab (Any iterable of integers) – The core table, when not None, is an array of
thrdnbrintegers that gives the core number on which each thread should be bound.
- bind_graph(orggraf, cntgraf)¶
This routine initializes a context container object with the graph
orggraf. The graphcntgrafis a context container that will contain the graphorggraf. The graphorggrafis not duplicated, but only linked to the context container. The context container is used to store the graph and to provide a context for all graph operations.
- bind_mesh(orgmesh, cntmesh)¶
This routine initializes a context container object with the mesh
orgmesh. The meshcntmeshis a context container that will contain the meshorgmesh. The meshorgmeshis not duplicated, but only linked to the context container. The context container is used to store the mesh and to provide a context for all mesh operations.
Various functions are defined as wrappers of Context operations: