diff --git a/examples/advection/surface.py b/examples/advection/surface.py index 8eca7ab43755b293c2a50388b438747d17c4fb83..19d009f6e5109e94f443d516193804df50131de1 100644 --- a/examples/advection/surface.py +++ b/examples/advection/surface.py @@ -104,11 +104,9 @@ class Plotter: def main(ctx_factory, dim=2, order=4, use_quad=False, visualize=False): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) # {{{ parameters diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py index 753bf263dc437e4c9bea332d1885fda066ab3f4e..96a1d294ebc0cee0b06b2bf25b75beb13722d9c9 100644 --- a/examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -99,11 +99,9 @@ def main(ctx_factory, dim=2, order=4, use_quad=False, visualize=False, flux_type="upwind"): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) # {{{ parameters diff --git a/examples/advection/weak.py b/examples/advection/weak.py index 72a2932d0dcdeb9fc0c48db00bc9b84c288291e2..ef1ef54b8bc2a712d932aa6c8bbb04dbed42bb52 100644 --- a/examples/advection/weak.py +++ b/examples/advection/weak.py @@ -99,11 +99,9 @@ class Plotter: def main(ctx_factory, dim=2, order=4, visualize=False): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) # {{{ parameters diff --git a/examples/euler/acoustic_pulse.py b/examples/euler/acoustic_pulse.py index c44a6322e466347452e8654ca1ded24ee757e246..c8fbf9303d50bb99eeee7bbb2aecac44d1a28acb 100644 --- a/examples/euler/acoustic_pulse.py +++ b/examples/euler/acoustic_pulse.py @@ -212,17 +212,11 @@ def main(ctx_factory, order=3, final_time=1, resolution=16, cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) if lazy: - actx = PytatoPyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - ) + actx = PytatoPyOpenCLArrayContext(queue, allocator=allocator) else: - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + actx = PyOpenCLArrayContext(queue, allocator=allocator) run_acoustic_pulse( actx, diff --git a/examples/euler/vortex.py b/examples/euler/vortex.py index 974981efbdcd433faf84001dce52599ffe80fb53..2c5f40c6f4234ce8ad5a52e67514487cedb33beb 100644 --- a/examples/euler/vortex.py +++ b/examples/euler/vortex.py @@ -162,17 +162,11 @@ def main(ctx_factory, order=3, final_time=5, resolution=8, cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) if lazy: - actx = PytatoPyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - ) + actx = PytatoPyOpenCLArrayContext(queue, allocator=allocator) else: - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + actx = PyOpenCLArrayContext(queue, allocator=allocator) if lf_stabilization: flux_type = "lf" diff --git a/examples/geometry.py b/examples/geometry.py index 5d8439122431ff0b3c293162353401370284e53a..33e463b6735e1c75904e85a7ce7dd55fe17f63ae 100644 --- a/examples/geometry.py +++ b/examples/geometry.py @@ -25,26 +25,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -import numpy as np # noqa import pyopencl as cl import pyopencl.tools as cl_tools +from grudge import geometry, shortcuts from grudge.array_context import PyOpenCLArrayContext - -from grudge import shortcuts -from grudge import geometry from grudge.discretization import make_discretization_collection -def main(write_output=True): +def main(write_output: bool = True) -> None: cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) from meshmode.mesh import BTAG_ALL from meshmode.mesh.generation import generate_warped_rect_mesh diff --git a/examples/maxwell/cavities.py b/examples/maxwell/cavities.py index c05272b2a7f78c8da5959629c361bc2b32ec26fa..ced99dd658e92209b14da92b68e30e569d5f29de 100644 --- a/examples/maxwell/cavities.py +++ b/examples/maxwell/cavities.py @@ -44,11 +44,9 @@ logger = logging.getLogger(__name__) def main(ctx_factory, dim=3, order=4, visualize=False): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) from meshmode.mesh.generation import generate_regular_rect_mesh mesh = generate_regular_rect_mesh( diff --git a/examples/wave/var-propagation-speed.py b/examples/wave/var-propagation-speed.py index 572fc652febf84391ccad3eb73797cc24d7f67ea..2a42b02a54674d9cd1e38f26b736b4aaec0b244a 100644 --- a/examples/wave/var-propagation-speed.py +++ b/examples/wave/var-propagation-speed.py @@ -44,11 +44,9 @@ logger = logging.getLogger(__name__) def main(ctx_factory, dim=2, order=4, visualize=False): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) from meshmode.mesh.generation import generate_regular_rect_mesh mesh = generate_regular_rect_mesh( diff --git a/examples/wave/wave-min-mpi.py b/examples/wave/wave-min-mpi.py index acdc47e4dae46bb30f2e0afb249219dea424c814..0b68de64d6be5244eb296ef59f0fa5faead38aea 100644 --- a/examples/wave/wave-min-mpi.py +++ b/examples/wave/wave-min-mpi.py @@ -52,12 +52,9 @@ def main(dim=2, order=4, visualize=True): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) - actx = MPIPyOpenCLArrayContext( - comm, - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = MPIPyOpenCLArrayContext(comm, queue, allocator=allocator) from meshmode.distributed import get_partition_by_pymetis, membership_list_to_map from meshmode.mesh.processing import partition_mesh diff --git a/examples/wave/wave-op-mpi.py b/examples/wave/wave-op-mpi.py index ea47e202e0c1bc010ce62db6cce26fd38531691a..ffe62339b821e235355fa92daf6e0ff3744c7a61 100644 --- a/examples/wave/wave-op-mpi.py +++ b/examples/wave/wave-op-mpi.py @@ -28,13 +28,12 @@ import logging from dataclasses import dataclass import numpy as np -import numpy.linalg as la # noqa import pyopencl as cl import pyopencl.tools as cl_tools from arraycontext import dataclass_array_container, with_container_arithmetic from meshmode.dof_array import DOFArray -from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa +from meshmode.mesh import BTAG_ALL from pytools.obj_array import flat_obj_array, make_obj_array import grudge.geometry as geo @@ -186,16 +185,15 @@ def main(ctx_factory, dim=2, order=3, if numpy: actx = actx_class(comm) - elif lazy: - cl_ctx = ctx_factory() - queue = cl.CommandQueue(cl_ctx) - actx = actx_class(comm, queue, mpi_base_tag=15000) else: cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = actx_class(comm, queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + if lazy: + actx = actx_class(comm, queue, allocator=allocator, mpi_base_tag=15000) + else: + actx = actx_class(comm, queue, allocator=allocator) from meshmode.distributed import get_partition_by_pymetis, membership_list_to_map from meshmode.mesh.processing import partition_mesh diff --git a/examples/wave/wave-op-var-velocity.py b/examples/wave/wave-op-var-velocity.py index 00099398a91ec8a3ddb327e47e0477d21311e167..7bbf7488b4dad1984b8eac1840dfe54253a00749 100644 --- a/examples/wave/wave-op-var-velocity.py +++ b/examples/wave/wave-op-var-velocity.py @@ -151,11 +151,9 @@ def bump(actx, dcoll, t=0, width=0.05, center=None): def main(ctx_factory, dim=2, order=3, visualize=False): cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - actx = PyOpenCLArrayContext( - queue, - allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)), - force_device_scalars=True, - ) + + allocator = cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) + actx = PyOpenCLArrayContext(queue, allocator=allocator) nel_1d = 16 from meshmode.mesh.generation import generate_regular_rect_mesh diff --git a/test/test_mpi_communication.py b/test/test_mpi_communication.py index 342c52676eb3f64db8d3cac7f80ced280175e4d1..69b4d5c9b92d59b5c9790deb2731aaba92b20f7d 100644 --- a/test/test_mpi_communication.py +++ b/test/test_mpi_communication.py @@ -86,7 +86,7 @@ def run_test_with_mpi_inner(): if actx_class is MPIPytatoArrayContext: actx = actx_class(comm, queue, mpi_base_tag=15000) elif actx_class is MPIPyOpenCLArrayContext: - actx = actx_class(comm, queue, force_device_scalars=True) + actx = actx_class(comm, queue) else: raise ValueError("unknown actx_class")