Skip to content

Defining the semantics for a lazy array context #6

@kaushikcfd

Description

@kaushikcfd

Background

  • Lazy Array framework we will be using: github.com/inducer/pytato
  • Lazy Array Context requires a context for symbolic operations (i.e. Pytato.Namespace) and an execution context. (probably a PyOpenCL command queue).
  • Compile is a new operation that needs to be supported by ArrayContext. ArrayContext.compile would take a python callable, f, and return a JIT-ed function corresponding to f.

Looking at PyOpenCLArrayContext

  • freeze: gets rid of the array context's queue, giving the caller the freedom to operate on the frozen array without being wary of the actx's state.
  • thaw: attaches the array context's queue to the array, so any operations on the array are enqueued onto actx's queue.
  • compile: takes a python callable and just returns the python callable.

Proposal: PytatoPyOpenCLArrayContext

  • Uses pytato for lazy evaluation and any valued arrays are represented via pyopencl arrays.
  • freeze: takes a Union[pytato.Array, pyopencl.array] and returns a pyopencl.array without the actx's queue.
  • thaw: takes a pyopencl.array and returns a pytato.DataWrapper with the actx's namespace and queue attached to the cl array.
  • compile: takes a callable and a numpy object array of DofArrays of pyopencl arrays and returns a A: CompiledOperator that would have a method A.__call__(self, x: np.ndarray[DofArray[PyOpenCLArray]]) -> np.ndarray[DofArray[PyOpenCLArray]]. The pyopencl arrays fed into and out of A.__call__ would still have the actx's command queue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions