diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3cb800680f6070d89ec1d68d79ea267b9319000..0f0f630b023b09f998fb9fe2902939cb9a32ba9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,9 @@ jobs: - uses: actions/checkout@v2 - name: "Main Script" run: | - grep -v mpi4py .test-conda-env-py3.yml > .test-conda-env.yml - CONDA_ENVIRONMENT=.test-conda-env.yml + sudo apt-get update + sudo apt-get install openmpi-bin libopenmpi-dev + CONDA_ENVIRONMENT=.test-conda-env-py3.yml curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh . ./build-and-test-py-project-within-miniconda.sh @@ -45,12 +46,11 @@ jobs: run: | sudo apt-get update sudo apt-get install openmpi-bin libopenmpi-dev - grep -v symengine .test-conda-env-py3.yml > .test-conda-env.yml - CONDA_ENVIRONMENT=.test-conda-env.yml - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-py-project-within-miniconda.sh - . ./build-py-project-within-miniconda.sh - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/run-examples.sh - . ./run-examples.sh + CONDA_ENVIRONMENT=.test-conda-env-py3.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh + . ci-support.sh + build_py_project_in_conda_env + run_examples # vim: sw=4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7017334523806ff5e0b4337669dbf0d37113193e..66fc4e491c73a020bba5baee77f85048805696be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,6 @@ Python 3 POCL: - python3 - pocl - mpi - # https://github.com/pocl/pocl/issues/757 - allow_failure: true except: - tags artifacts: @@ -47,8 +45,6 @@ Python 3 POCL MPI: - python3 - pocl - mpi - # https://github.com/pocl/pocl/issues/757 - allow_failure: true except: - tags artifacts: @@ -85,8 +81,6 @@ Python 3 POCL Examples: - python3 - pocl - large-node - # https://github.com/pocl/pocl/issues/757 - allow_failure: true except: - tags @@ -105,6 +99,28 @@ Python 3 Intel Examples: except: - tags +Python 3 Conda: + tags: + - linux + - large-node + script: | + CONDA_ENVIRONMENT=.test-conda-env.yml + grep -v libhwloc .test-conda-env-py3.yml > $CONDA_ENVIRONMENT + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh + . ./build-and-test-py-project-within-miniconda.sh + +Python 3 Conda Examples: + tags: + - linux + - large-node + script: | + CONDA_ENVIRONMENT=.test-conda-env.yml + grep -v libhwloc .test-conda-env-py3.yml > $CONDA_ENVIRONMENT + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh + . ci-support.sh + build_py_project_in_conda_env + run_examples + Documentation: script: - EXTRA_INSTALL="pybind11 numpy" diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index c95608f48d118948bd788cd5a0e57bcad439a02e..31c74378f0dcf8af7687785ee5cf906172dcecb3 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -14,15 +14,3 @@ dependencies: - pyopencl - python=3 - gmsh - -- pip -- pip: - - git+https://github.com/inducer/pytools - - git+https://github.com/inducer/pymbolic - - git+https://github.com/inducer/loopy - - git+https://github.com/inducer/meshmode - - git+https://github.com/inducer/dagrt - - git+https://github.com/inducer/leap - - git+https://github.com/inducer/pyvisfile - - mpi4py - - pymetis diff --git a/examples/wave/wave-eager-mpi.py b/examples/wave/wave-eager-mpi.py index 4b408bb599c5002a32325f5befd9ab66ab02cee9..40ddbb7b1fb2049f54e173e0c5696a8a5a2d19e3 100644 --- a/examples/wave/wave-eager-mpi.py +++ b/examples/wave/wave-eager-mpi.py @@ -60,7 +60,7 @@ def wave_flux(discr, c, w_tpair): # upwind v_jump = np.dot(normal, v.int-v.ext) - flux_weak -= flat_obj_array( + flux_weak += flat_obj_array( 0.5*(u.int-u.ext), 0.5*normal*scalar(v_jump), ) @@ -80,10 +80,10 @@ def wave_operator(discr, c, w): return ( discr.inverse_mass( flat_obj_array( - c*discr.weak_div(v), - c*discr.weak_grad(u) + -c*discr.weak_div(v), + -c*discr.weak_grad(u) ) - - # noqa: W504 + + # noqa: W504 discr.face_mass( wave_flux(discr, c=c, w_tpair=interior_trace_pair(discr, w)) + wave_flux(discr, c=c, w_tpair=TracePair( @@ -106,7 +106,7 @@ def rk4_step(y, t, h, f): return y + h/6*(k1 + 2*k2 + 2*k3 + k4) -def bump(discr, actx, t=0): +def bump(actx, discr, t=0): source_center = np.array([0.2, 0.35, 0.1])[:discr.dim] source_width = 0.05 source_omega = 3 @@ -171,7 +171,7 @@ def main(): raise ValueError("don't have a stable time step guesstimate") fields = flat_obj_array( - bump(discr, actx), + bump(actx, discr), [discr.zeros(actx) for i in range(discr.dim)] ) diff --git a/examples/wave/wave-eager-var-velocity.py b/examples/wave/wave-eager-var-velocity.py index 721211314dfd5931374f0347e90435c624baf129..9ac8a4c4f2a4a47f46d0a62f7c9271a7dda4f140 100644 --- a/examples/wave/wave-eager-var-velocity.py +++ b/examples/wave/wave-eager-var-velocity.py @@ -61,12 +61,12 @@ def wave_flux(discr, c, w_tpair): # upwind v_jump = np.dot(normal, v.int-v.ext) - flux_weak -= flat_obj_array( + flux_weak += flat_obj_array( 0.5*(u.int-u.ext), 0.5*normal*scalar(v_jump), ) - # FIMXE this flux is only correct for continuous c + # FIXME this flux is only correct for continuous c dd_allfaces_quad = dd_quad.with_dtag("all_faces") c_quad = discr.project("vol", dd_quad, c) flux_quad = discr.project(dd, dd_quad, flux_weak) @@ -91,14 +91,13 @@ def wave_operator(discr, c, w): dd_allfaces_quad = DOFDesc("all_faces", "vel_prod") - # FIXME Fix sign issue return ( discr.inverse_mass( flat_obj_array( - discr.weak_div(dd_quad, scalar(c_quad)*v_quad), - discr.weak_grad(dd_quad, c_quad*u_quad) + -discr.weak_div(dd_quad, scalar(c_quad)*v_quad), + -discr.weak_grad(dd_quad, c_quad*u_quad) ) - - # noqa: W504 + + # noqa: W504 discr.face_mass( dd_allfaces_quad, wave_flux(discr, c=c, w_tpair=interior_trace_pair(discr, w)) diff --git a/examples/wave/wave-eager.py b/examples/wave/wave-eager.py index 7450f435798c249f97dd11e03cd59dbd1e95b542..52ab08244d480ccfe6d58a4476e440fe4ad0e100 100644 --- a/examples/wave/wave-eager.py +++ b/examples/wave/wave-eager.py @@ -58,7 +58,7 @@ def wave_flux(discr, c, w_tpair): # upwind v_jump = np.dot(normal, v.int-v.ext) - flux_weak -= flat_obj_array( + flux_weak += flat_obj_array( 0.5*(u.int-u.ext), 0.5*normal*scalar(v_jump), ) @@ -78,10 +78,10 @@ def wave_operator(discr, c, w): return ( discr.inverse_mass( flat_obj_array( - c*discr.weak_div(v), - c*discr.weak_grad(u) + -c*discr.weak_div(v), + -c*discr.weak_grad(u) ) - - # noqa: W504 + + # noqa: W504 discr.face_mass( wave_flux(discr, c=c, w_tpair=interior_trace_pair(discr, w)) + wave_flux(discr, c=c, w_tpair=TracePair( @@ -100,7 +100,7 @@ def rk4_step(y, t, h, f): return y + h/6*(k1 + 2*k2 + 2*k3 + k4) -def bump(discr, actx, t=0): +def bump(actx, discr, t=0): source_center = np.array([0.2, 0.35, 0.1])[:discr.dim] source_width = 0.05 source_omega = 3 @@ -147,7 +147,7 @@ def main(): discr = EagerDGDiscretization(actx, mesh, order=order) fields = flat_obj_array( - bump(discr, actx), + bump(actx, discr), [discr.zeros(actx) for i in range(discr.dim)] ) diff --git a/grudge/eager.py b/grudge/eager.py index 71a01873001d56883d49754bd4264f18c3c20935..87368161e5045b2a7c1b508b89cf60ebb336053a 100644 --- a/grudge/eager.py +++ b/grudge/eager.py @@ -38,6 +38,8 @@ from grudge.symbolic.primitives import TracePair __doc__ = """ .. autoclass:: EagerDGDiscretization +.. autofunction:: interior_trace_pair +.. autofunction:: cross_rank_trace_pairs """ @@ -160,11 +162,32 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries): return self._bound_face_mass(dd)(u=vec) @memoize_method - def _norm(self, p): - return bind(self, sym.norm(p, sym.var("arg")), local_only=True) + def _norm(self, p, dd): + return bind(self, + sym.norm(p, sym.var("arg", dd=dd), dd=dd), + local_only=True) + + def norm(self, vec, p=2, dd=None): + if dd is None: + dd = "vol" + + dd = sym.as_dofdesc(dd) - def norm(self, vec, p=2): - return self._norm(p)(arg=vec) + if (isinstance(vec, np.ndarray) + and vec.dtype.char == "O" + and not isinstance(vec, DOFArray)): + if p == 2: + return sum( + self.norm(vec[idx], dd=dd)**2 + for idx in np.ndindex(vec.shape))**0.5 + elif p == np.inf: + return max( + self.norm(vec[idx], np.inf, dd=dd) + for idx in np.ndindex(vec.shape)) + else: + raise ValueError("unsupported norm order") + + return self._norm(p, dd)(arg=vec) @memoize_method def _nodal_reduction(self, operator, dd): @@ -198,7 +221,7 @@ def interior_trace_pair(discrwb, vec): return TracePair("int_faces", i, e) -class RankBoundaryCommunication: +class _RankBoundaryCommunication: base_tag = 1273 def __init__(self, discrwb, remote_rank, vol_field, tag=None): @@ -241,7 +264,7 @@ class RankBoundaryCommunication: def _cross_rank_trace_pairs_scalar_field(discrwb, vec, tag=None): - rbcomms = [RankBoundaryCommunication(discrwb, remote_rank, vec, tag=tag) + rbcomms = [_RankBoundaryCommunication(discrwb, remote_rank, vec, tag=tag) for remote_rank in discrwb.connected_ranks()] return [rbcomm.finish() for rbcomm in rbcomms] diff --git a/grudge/execution.py b/grudge/execution.py index e349937455c1bf88f75b200dc4538f3780ad1d8e..0b3616e3f8fce1f83f016cf3c540d2657bf53739 100644 --- a/grudge/execution.py +++ b/grudge/execution.py @@ -43,7 +43,7 @@ from grudge.function_registry import base_function_registry import logging logger = logging.getLogger(__name__) -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa: F401 +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401 MPI_TAG_SEND_TAGS = 1729 diff --git a/grudge/function_registry.py b/grudge/function_registry.py index 7b85d18fcfbd4626b8c6ee6055c421c021c538be..102932261bffbe3c52218611f872f2c912c41e65 100644 --- a/grudge/function_registry.py +++ b/grudge/function_registry.py @@ -28,7 +28,7 @@ THE SOFTWARE. import numpy as np -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa from pytools import RecordWithoutPickling diff --git a/grudge/symbolic/compiler.py b/grudge/symbolic/compiler.py index 7d8189d67ddc99d6412c4686de579e7c65cbebcb..e5b7f7e872541aacd7e352eb6e247e99915077c4 100644 --- a/grudge/symbolic/compiler.py +++ b/grudge/symbolic/compiler.py @@ -37,7 +37,7 @@ import grudge.symbolic.mappers as mappers from pymbolic.primitives import Variable, Subscript from six.moves import intern -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa: F401 +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401 # {{{ instructions diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index 803eaf23d89f4f67e17dcc7964db79ffdfc93e02..3e3256c103b0e55766f039f73e9ec0359994bfc4 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -787,7 +787,7 @@ def mv_normal(dd, ambient_dim, dim=None): cse_scope.DISCRETIZATION) -def normal(dd, ambient_dim, dim=None, quadrature_tag=None): +def normal(dd, ambient_dim, dim=None): return mv_normal(dd, ambient_dim, dim).as_vector() diff --git a/requirements.txt b/requirements.txt index 101166fb2a22e850d7698f14b16369bf083ca3d4..650f0b79b2790757e681c1cf02d807da1e94feb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,14 @@ numpy -git+https://github.com/inducer/pytools.git -git+https://github.com/inducer/pymbolic.git -git+https://github.com/inducer/islpy.git -git+https://github.com/inducer/pyopencl.git -git+https://github.com/inducer/loopy.git -git+https://gitlab.tiker.net/inducer/dagrt.git -git+https://gitlab.tiker.net/inducer/leap.git -git+https://github.com/inducer/meshpy.git -git+https://github.com/inducer/modepy.git -git+https://github.com/inducer/meshmode.git +mpi4py +git+https://github.com/inducer/pytools.git#egg=pytools +git+https://github.com/inducer/pymbolic.git#egg=pymbolic +git+https://github.com/inducer/islpy.git#egg=islpy +git+https://github.com/inducer/pyopencl.git#egg=pyopencl +git+https://github.com/inducer/loopy.git#egg=loo.py +git+https://github.com/inducer/dagrt.git#egg=dagrt +git+https://github.com/inducer/leap.git#egg=leap +git+https://github.com/inducer/meshpy.git#egg=meshpy +git+https://github.com/inducer/modepy.git#egg=modepy +git+https://github.com/inducer/meshmode.git#egg=meshmode +git+https://github.com/inducer/pyvisfile.git#egg=pyvisfile +git+https://github.com/inducer/pymetis.git#egg=pymetis