From 37e9bd65254773860b2aa0ecb4340e0e1b2bc293 Mon Sep 17 00:00:00 2001 From: James Stevens <jdsteve2@illinois.edu> Date: Thu, 9 Jul 2015 11:19:55 -0500 Subject: [PATCH] added barrier counter --- loopy/statistics.py | 2 +- test/test_statistics.py | 46 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/loopy/statistics.py b/loopy/statistics.py index 23959e579..8e1210c11 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -203,7 +203,7 @@ class ExpressionOpCounter(CombineMapper): class ExpressionSubscriptCounter(CombineMapper): - # TODO count barriers: get_one_scheduled_kernel(k).schedule (list) then look for instanceOf barrier + def __init__(self, knl): self.knl = knl from loopy.expression import TypeInferenceMapper diff --git a/test/test_statistics.py b/test/test_statistics.py index 2e49b64f1..189a12bc8 100644 --- a/test/test_statistics.py +++ b/test/test_statistics.py @@ -148,12 +148,10 @@ def test_op_counter_bitwise(): l = 128 i32 = poly.dict[np.dtype(np.int32)].eval_with_dict({'n': n, 'm': m, 'l': l}) i64 = poly.dict[np.dtype(np.int64)].eval_with_dict({'n': n, 'm': m, 'l': l}) # noqa - print(poly.dict) f64 = poly[np.dtype(np.float64)].eval_with_dict({'n': n, 'm': m, 'l': l}) assert i32 == n*m+3*n*m*l assert i64 == 6*n*m assert f64 == 0 - # TODO test bitwise operations on int64 def test_op_counter_triangular_domain(): @@ -329,7 +327,49 @@ def test_DRAM_access_counter_weird(): knl = lp.tag_inames(knl, {"j_inner": "l.0", "j_outer": "g.0"}) poly = get_DRAM_access_poly(knl) # noqa - # TODO assertions + n = 512 + m = 256 + l = 128 + f64uniform = poly.dict[ + (np.dtype(np.float64), 'uniform') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) + f32nonconsec = poly.dict[ + (np.dtype(np.float32), 'nonconsecutive') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) + assert f64uniform == 2*n*m + assert f32nonconsec == 3*n*m*l + + +def test_DRAM_access_counter_nonconsec(): + + knl = lp.make_kernel( + "[n,m,l] -> {[i,k,j]: 0<=i<n and 0<=k<m and 0<=j<l}", + [ + """ + c[i, j, k] = a[i,j,k]*b[i,j,k]/3.0+a[i,j,k] + e[i, k] = g[i,k]*(2+h[i,k]) + """ + ], + name="nonconsec", assumptions="n,m,l >= 1") + knl = lp.add_and_infer_dtypes(knl, dict( + a=np.float32, b=np.float32, g=np.float64, h=np.float64)) + knl = lp.split_iname(knl, "i", 16) + knl = lp.tag_inames(knl, {"i_inner": "l.0", "i_outer": "g.0"}) + + poly = get_DRAM_access_poly(knl) # noqa + n = 512 + m = 256 + l = 128 + f64nonconsec = poly.dict[ + (np.dtype(np.float64), 'nonconsecutive') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) + f32nonconsec = poly.dict[ + (np.dtype(np.float32), 'nonconsecutive') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) + assert f64nonconsec == 2*n*m + assert f32nonconsec == 3*n*m*l + + #TODO more consec/nonconsec tests ''' def test_DRAM_access_counter_triangular_domain(): -- GitLab