Runtime and Library Contexts#

Library#

A Library class is an interface that every library descriptor needs to implement. Each library should tell the Legate runtime how to initialize and configure the library, and this class provides a common way to reveal that information to the runtime. Each library should register to the runtime a library descriptor object that implements Library directly or via duck typing. (See legate.core.runtime.Runtime.register_library().)

Library.get_name()

Returns a name of the library

Library.get_shared_library()

Returns the path to the shared library

Library.get_c_header()

Returns a compiled C header string for the library

Library.get_registration_callback()

Returns the name of a C registration callback for the library

Library.get_resource_configuration()

Returns a ResourceConfig object that configures the library

Resource configuration#

A ResourceConfig object describes the maximum number of handles that a library uses.

ResourceConfig.max_tasks

ResourceConfig.max_reduction_ops

ResourceConfig.max_mappers

Context#

A Context object provides APIs for creating stores and issuing tasks and other kinds of operations. When a library registers itself to the Legate runtime, the runtime gives back a context object unique to the library.

context.Context.create_store(ty[, shape, ...])

Creates a fresh store.

context.Context.create_task(task_id[, ...])

Creates a task.

context.Context.create_manual_task(task_id)

Type safe version of Context.create_task.

context.Context.create_auto_task(task_id[, ...])

Type safe version of Context.create_task.

context.Context.create_copy([mapper_id])

Creates a copy operation.

context.Context.create_fill(lhs, value[, ...])

Creates a fill operation.

context.Context.issue_execution_fence([block])

Issues an execution fence.

context.Context.tree_reduce(task_id, store)

Performs a user-defined reduction by building a tree of reduction tasks.

context.Context.get_tunable(tunable_id, dtype)

Queries a tunable parameter to the mapper.

context.Context.provenance

Returns the current provenance string.

context.Context.annotation

Returns the current set of annotations.

context.Context.set_provenance(provenance)

Sets a new provenance string

context.Context.reset_provenance()

Clears the provenance string that is currently set

context.Context.push_provenance(provenance)

Pushes a provenance string to the stack

context.Context.pop_provenance()

Pops the provenance string on top the stack

context.Context.track_provenance(func[, nested])

Wraps a function with provenance tracking.

Legate Runtime#

runtime.Runtime.num_cpus

Returns the total number of CPUs in the system

runtime.Runtime.num_omps

Returns the total number of OpenMP processors in the system

runtime.Runtime.num_gpus

Returns the total number of GPUs in the system

runtime.Runtime.register_library(library)

Registers a library to the runtime.

runtime.Runtime.create_future(data, size)

Creates a future from a buffer holding a scalar value.

Annotation#

An Annotation is a context manager to set library specific annotations that are to be attached to operations issued within a scope. A typical usage of Annotation would look like this:

with Annotation(lib_context, { "key1" : "value1", "key2" : "value2", ... }:
  ...

Then each operation in the scope is annotated with the key-value pairs, which are later rendered in execution profiles.

context.Annotation.__init__(context, pairs)

Constructs a new annotation object