From 53e7e37c8d7820a0e32c309a004cba643f3cdcf9 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Sat, 8 Feb 2025 11:13:58 +0200 Subject: [PATCH 1/3] feat: remove force_device_scalars=True from examples --- examples/from_firedrake.py | 2 +- examples/moving-geometry.py | 2 +- examples/plot-connectivity.py | 2 +- examples/simple-dg.py | 2 +- examples/to_firedrake.py | 2 +- examples/tp-lagrange-stl.py | 2 +- meshmode/__init__.py | 2 +- test/test_partition.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/from_firedrake.py b/examples/from_firedrake.py index e6e39ea1..2ac23281 100644 --- a/examples/from_firedrake.py +++ b/examples/from_firedrake.py @@ -57,7 +57,7 @@ def main(visualize=True): # Make connections cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) fd_connection = build_connection_from_firedrake(actx, fd_fspace) fd_bdy_connection = \ diff --git a/examples/moving-geometry.py b/examples/moving-geometry.py index ee1228b8..7f21b5c1 100644 --- a/examples/moving-geometry.py +++ b/examples/moving-geometry.py @@ -245,7 +245,7 @@ def source(t, x): if __name__ == "__main__": cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) from pytools import ProcessTimer for _ in range(1): diff --git a/examples/plot-connectivity.py b/examples/plot-connectivity.py index 7d3bbd59..ce27d5db 100644 --- a/examples/plot-connectivity.py +++ b/examples/plot-connectivity.py @@ -11,7 +11,7 @@ def main(): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) from meshmode.mesh.generation import ( # noqa: F401 generate_icosahedron, diff --git a/examples/simple-dg.py b/examples/simple-dg.py index 26722f1c..51da62f6 100644 --- a/examples/simple-dg.py +++ b/examples/simple-dg.py @@ -464,7 +464,7 @@ def main(lazy=False): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx_outer = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx_outer = PyOpenCLArrayContext(queue) if lazy: actx_rhs = PytatoPyOpenCLArrayContext(queue) else: diff --git a/examples/to_firedrake.py b/examples/to_firedrake.py index 8027a8fd..08e2e60e 100644 --- a/examples/to_firedrake.py +++ b/examples/to_firedrake.py @@ -52,7 +52,7 @@ def main(): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) nel_1d = 16 from meshmode.mesh.generation import generate_regular_rect_mesh diff --git a/examples/tp-lagrange-stl.py b/examples/tp-lagrange-stl.py index 063efa5d..e048a525 100644 --- a/examples/tp-lagrange-stl.py +++ b/examples/tp-lagrange-stl.py @@ -18,7 +18,7 @@ def main(): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) npts1d = 100 # use 300 for actual print rs_coords = np.linspace(-1, 1, npts1d) diff --git a/meshmode/__init__.py b/meshmode/__init__.py index 1ba90f10..d891e8f7 100644 --- a/meshmode/__init__.py +++ b/meshmode/__init__.py @@ -85,4 +85,4 @@ def _acf(): context = cl._csc() queue = cl.CommandQueue(context) - return PyOpenCLArrayContext(queue, force_device_scalars=True) + return PyOpenCLArrayContext(queue) diff --git a/test/test_partition.py b/test/test_partition.py index e57fac57..7b33e766 100644 --- a/test/test_partition.py +++ b/test/test_partition.py @@ -408,7 +408,7 @@ def _test_mpi_boundary_swap(dim, order, num_groups): from meshmode.array_context import PyOpenCLArrayContext cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext(queue, force_device_scalars=True) + actx = PyOpenCLArrayContext(queue) from meshmode.discretization import Discretization vol_discr = Discretization(actx, local_mesh, group_factory) From b27c4458a0e7606cc4a4a36a186136e352fe3cd4 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Sat, 8 Feb 2025 11:22:41 +0200 Subject: [PATCH 2/3] fix: update CI badges --- README.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 57001668..6df84351 100644 --- a/README.rst +++ b/README.rst @@ -4,10 +4,10 @@ meshmode: High-Order Meshes and Discontinuous Function Spaces .. image:: https://gitlab.tiker.net/inducer/meshmode/badges/main/pipeline.svg :alt: Gitlab Build Status :target: https://gitlab.tiker.net/inducer/meshmode/commits/main -.. image:: https://github.com/inducer/meshmode/workflows/CI/badge.svg +.. image:: https://github.com/inducer/meshmode/actions/workflows/ci.yml/badge.svg :alt: Github Build Status - :target: https://github.com/inducer/meshmode/actions?query=branch%3Amain+workflow%3ACI -.. image:: https://badge.fury.io/py/meshmode.png + :target: https://github.com/inducer/meshmode/actions/workflows/ci.yml +.. image:: https://badge.fury.io/py/meshmode.svg :alt: Python Package Index Release Page :target: https://pypi.org/project/meshmode/ @@ -35,5 +35,5 @@ Meshmode emerged as the shared discretization layer for `pytential Places on the web related to meshmode: -* `Source code on Github `_ -* `Documentation `_ +* `Source code on Github `__ +* `Documentation `__ From e2a664846f58520009a2e46f5197b2fadcedc26a Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Sat, 8 Feb 2025 15:21:06 +0200 Subject: [PATCH 3/3] fix: add __array_ufunc__ to containers in examples --- examples/parallel-vtkhdf.py | 2 +- examples/simple-dg.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/parallel-vtkhdf.py b/examples/parallel-vtkhdf.py index 3ff980ed..287597b2 100644 --- a/examples/parallel-vtkhdf.py +++ b/examples/parallel-vtkhdf.py @@ -73,7 +73,7 @@ def main(*, ambient_dim: int) -> None: logger.info("[%4d] fields: finished", comm.rank) from meshmode.discretization.visualization import make_visualizer - vis = make_visualizer(actx, discr, vis_order=order, force_equidistant=False) + vis = make_visualizer(actx, discr, force_equidistant=False) logger.info("[%4d] make_visualizer: finished", comm.rank) filename = f"parallel-vtkhdf-example-{ambient_dim}d.hdf" diff --git a/examples/simple-dg.py b/examples/simple-dg.py index 51da62f6..efc396b2 100644 --- a/examples/simple-dg.py +++ b/examples/simple-dg.py @@ -341,6 +341,9 @@ class TracePair: interior: ArrayContainer exterior: ArrayContainer + # NOTE: let the container do the broadcasting + arithmetic + __array_ufunc__ = None + def __getattr__(self, name): return map_array_container( lambda ary: getattr(ary, name), @@ -450,6 +453,9 @@ class WaveState: u: DOFArray v: np.ndarray # [object] + # NOTE: let the container do the broadcasting + arithmetic + __array_ufunc__ = None + def __post_init__(self): assert isinstance(self.v, np.ndarray) and self.v.dtype.char == "O"