From cbe3d24990eaff55381e4cf97d5b3ea832ef7b4f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 29 Feb 2016 00:03:37 -0600 Subject: [PATCH] Fix tests for simul_reduce --- test/test_dg.py | 8 ++++---- test/test_loopy.py | 23 +++++++++++++---------- test/test_sem_reagan.py | 8 ++++---- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/test/test_dg.py b/test/test_dg.py index 63a961423..fafef86c3 100644 --- a/test/test_dg.py +++ b/test/test_dg.py @@ -52,10 +52,10 @@ def test_dg_volume(ctx_factory): "{[n,m,k]: 0<= n,m < Np and 0<= k < K}", ], """ - <> du_drst = sum(m, DrDsDt[n,m]*u[k,m]) - <> dv_drst = sum(m, DrDsDt[n,m]*v[k,m]) - <> dw_drst = sum(m, DrDsDt[n,m]*w[k,m]) - <> dp_drst = sum(m, DrDsDt[n,m]*p[k,m]) + <> du_drst = simul_reduce(sum, m, DrDsDt[n,m]*u[k,m]) + <> dv_drst = simul_reduce(sum, m, DrDsDt[n,m]*v[k,m]) + <> dw_drst = simul_reduce(sum, m, DrDsDt[n,m]*w[k,m]) + <> dp_drst = simul_reduce(sum, m, DrDsDt[n,m]*p[k,m]) # volume flux rhsu[k,n] = dot(drst_dx[k],dp_drst) diff --git a/test/test_loopy.py b/test/test_loopy.py index 48ed2e2e7..13870829e 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -947,8 +947,8 @@ def test_double_sum(ctx_factory): knl = lp.make_kernel( "{[i,j]: 0<=i,j<n }", [ - "a = sum((i,j), i*j)", - "b = sum(i, sum(j, i*j))", + "a = simul_reduce(sum, (i,j), i*j)", + "b = simul_reduce(sum, i, simul_reduce(sum, j, i*j))", ], assumptions="n>=1") @@ -1098,8 +1098,8 @@ def test_arg_guessing_with_reduction(ctx_factory): knl = lp.make_kernel( "{[i,j]: 0<=i,j<n }", """ - a = 1.5 + sum((i,j), i*j) - d = 1.5 + sum((i,j), b[i,j]) + a = 1.5 + simul_reduce(sum, (i,j), i*j) + d = 1.5 + simul_reduce(sum, (i,j), b[i,j]) b[i, j] = i*j c[i+j, j] = b[j,i] """, @@ -1895,19 +1895,22 @@ def test_poisson(ctx_factory): sdim = 3 knl = lp.make_kernel( - "{ [c,i,j,k,ell,ell2]: \ + "{ [c,i,j,k,ell,ell2,ell3]: \ 0 <= c < nels and \ 0 <= i < nbf and \ 0 <= j < nbf and \ 0 <= k < nqp and \ - 0 <= ell < sdim and \ - 0 <= ell2 < sdim }", + 0 <= ell,ell2,ell3 < sdim}", """ - dpsi(bf,k0,dir) := sum(ell2, DFinv[c,ell2,dir] * DPsi[bf,k0,ell2] ) - Ael[c,i,j] = J[c] * w[k] * sum(ell, dpsi(i,k,ell) * dpsi(j,k,ell)) + dpsi(bf,k0,dir,ell_r) := \ + sum(ell_r, DFinv[c,ell_r,dir] * DPsi[bf,k0,ell_r] ) + Ael[c,i,j] = \ + J[c] * w[k] * sum(ell, dpsi(i,k,ell,ell2) * dpsi(j,k,ell,ell3)) """, assumptions="nels>=1 and nbf >= 1 and nels mod 4 = 0") + print(knl) + knl = lp.fix_parameters(knl, nbf=nbf, sdim=sdim, nqp=nqp) ref_knl = knl @@ -1978,7 +1981,7 @@ def test_generate_c_snippet(): u = var("u") from functools import partial - l_sum = partial(lp.Reduction, "sum") + l_sum = partial(lp.Reduction, "sum", allow_simultaneous=True) Instr = lp.Assignment # noqa diff --git a/test/test_sem_reagan.py b/test/test_sem_reagan.py index a00fce177..f4b91b236 100644 --- a/test/test_sem_reagan.py +++ b/test/test_sem_reagan.py @@ -47,16 +47,16 @@ def test_tim2d(ctx_factory): knl = lp.make_kernel( "[K] -> {[i,j,e,m,o,gi]: 0<=i,j,m,o<%d and 0<=e<K and 0<=gi<3}" % n, [ - "ur(a,b) := sum(o, D[a,o]*u[e,o,b])", - "us(a,b) := sum(o, D[b,o]*u[e,a,o])", + "ur(a,b) := simul_reduce(sum, o, D[a,o]*u[e,o,b])", + "us(a,b) := simul_reduce(sum, o, D[b,o]*u[e,a,o])", #"Gu(mat_entry,a,b) := G[mat_entry,e,m,j]*ur(m,j)", "Gux(a,b) := G$x[0,e,a,b]*ur(a,b)+G$x[1,e,a,b]*us(a,b)", "Guy(a,b) := G$y[1,e,a,b]*ur(a,b)+G$y[2,e,a,b]*us(a,b)", "lap[e,i,j] = " - " sum(m, D[m,i]*Gux(m,j))" - "+ sum(m, D[m,j]*Guy(i,m))" + " simul_reduce(sum, m, D[m,i]*Gux(m,j))" + "+ simul_reduce(sum, m, D[m,j]*Guy(i,m))" ], [ -- GitLab