diff --git a/arraycontext/context.py b/arraycontext/context.py index 838f9692bd261cc4c7e5e593fc941f3346a18976..fea22733da3d46a0b5959f0b15f8fd6aa11deba9 100644 --- a/arraycontext/context.py +++ b/arraycontext/context.py @@ -102,12 +102,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from typing import Sequence, Union +from typing import Sequence, Union, Callable, Any, Tuple from abc import ABC, abstractmethod import numpy as np from pytools import memoize_method from pytools.tag import Tag +from numbers import Number # {{{ ArrayContext @@ -148,6 +149,7 @@ class ArrayContext(ABC): .. automethod:: thaw .. automethod:: tag .. automethod:: tag_axis + .. automethod:: compile """ def __init__(self): @@ -349,6 +351,19 @@ class ArrayContext(ABC): "setup-only" array context "leaks" into the application. """ + def compile(self, f: Callable[[Any], Any], + inputs_like: Tuple[Union[Number, np.ndarray], ...]) -> Callable[ + ..., Any]: + """Compiles a function for use on this array context. Might perform some + optimizations (such as kernel fusion) during compilation. + + :arg f: the function to compile. + :arg inputs_like: the input arguments to the function. + + :return: the compiled function. + """ + return f + # }}} # vim: foldmethod=marker diff --git a/arraycontext/impl/pyopencl.py b/arraycontext/impl/pyopencl.py index a31244124fab0e83cb16a545a32268facc7642f8..237cc0dd54452e0b5fa024fc4c1f47a6e7adbbae 100644 --- a/arraycontext/impl/pyopencl.py +++ b/arraycontext/impl/pyopencl.py @@ -26,10 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from typing import Sequence, Union, Callable, Any, Tuple +from typing import Sequence, Union from functools import partial import operator -from numbers import Number import numpy as np @@ -344,11 +343,6 @@ class PyOpenCLArrayContext(ArrayContext): def clone(self): return type(self)(self.queue, self.allocator, self._wait_event_queue_length) - def compile(self, f: Callable[[Any], Any], - inputs_like: Tuple[Union[Number, np.ndarray], ...]) -> Callable[ - ..., Any]: - return f - # }}} # vim: foldmethod=marker diff --git a/arraycontext/impl/pytato.py b/arraycontext/impl/pytato.py index e62676cc759e4f8ca995bdf6332ec97276a274a1..a49a81e70237c231c2644c24f845442075e17b33 100644 --- a/arraycontext/impl/pytato.py +++ b/arraycontext/impl/pytato.py @@ -224,13 +224,14 @@ class PytatoArrayContext(ArrayContext): A :class:`ArrayContext` that uses :mod:`pytato` data types to represent the DOF arrays targeting OpenCL for offloading operations. - .. attribute:: context - - A :class:`pyopencl.Context`. - .. attribute:: queue A :class:`pyopencl.CommandQueue`. + + .. attribute:: allocator + + A :mod:`pyopencl` memory allocator. Can also be None (default) or False + to use the default allocator. """ def __init__(self, queue, allocator=None): diff --git a/doc/array_context.rst b/doc/array_context.rst index aec9fedfdd6bccf708d5eca4e7b8e908eaa19ff5..7c8b5810f426ec8db42200e4dc7f41924edbc41f 100644 --- a/doc/array_context.rst +++ b/doc/array_context.rst @@ -15,6 +15,6 @@ Array context based on :mod:`pyopencl.array` Array context based on :mod:`pytato` --------------------------------------------- +------------------------------------ .. automodule:: arraycontext.impl.pytato