From 8c6787422df56118a089a6ab356e13f8cb5186fe Mon Sep 17 00:00:00 2001
From: Matthias Diener <mdiener@illinois.edu>
Date: Sat, 12 Jun 2021 11:51:59 -0500
Subject: [PATCH] change compile() location and some doc fixes

---
 arraycontext/context.py       | 17 ++++++++++++++++-
 arraycontext/impl/pyopencl.py |  8 +-------
 arraycontext/impl/pytato.py   |  9 +++++----
 doc/array_context.rst         |  2 +-
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/arraycontext/context.py b/arraycontext/context.py
index 838f969..fea2273 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 a312441..237cc0d 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 e62676c..a49a81e 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 aec9fed..7c8b581 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
-- 
GitLab