diff --git a/loopy/statistics.py b/loopy/statistics.py index f5002fba0eb3c2fe4b8c41260b3e7de8fdcc46c1..15b0605ecece5e77751827519a1aca4a13a9b2b0 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -300,7 +300,6 @@ class ExpressionSubscriptCounter(CombineMapper): # else, stride == 1, continue since another idx could contain id0 # loop finished without returning, stride==1 for every instance of local_id0 - # TODO what if key was never found? return TypeToCountMap( {(self.type_inf(expr), 'consecutive'): 1} ) + self.rec(expr.index) @@ -471,11 +470,6 @@ def get_barrier_poly(knl): barrier_poly += reduce(mul, ct) else: barrier_poly += isl.PwQPolynomial('{ 1 }') - ''' - if not isinstance(barrier_poly, isl.PwQPolynomial): - #TODO figure out better fix for this - string = "{"+str(barrier_poly)+"}" - return isl.PwQPolynomial(string) - ''' + return barrier_poly diff --git a/test/test_statistics.py b/test/test_statistics.py index 7a0494ce4cf2984b15017d4aa305fc17e17537fe..dc040864f4a0affe4f0356008d1f5ea46450f471 100644 --- a/test/test_statistics.py +++ b/test/test_statistics.py @@ -41,7 +41,7 @@ def test_op_counter_basic(): e[i, k] = g[i,k]*h[i,k+1] """ ], - name="weird", assumptions="n,m,l >= 1") + name="basic", 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)) @@ -64,7 +64,7 @@ def test_op_counter_reduction(): [ "c[i, j] = sum(k, a[i, k]*b[k, j])" ], - name="matmul", assumptions="n,m,l >= 1") + name="matmul_serial", assumptions="n,m,l >= 1") knl = lp.add_and_infer_dtypes(knl, dict(a=np.float32, b=np.float32)) poly = get_op_poly(knl) @@ -195,7 +195,7 @@ def test_DRAM_access_counter_basic(): e[i, k] = g[i,k]*h[i,k+1] """ ], - name="weird", assumptions="n,m,l >= 1") + name="basic", 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)) @@ -203,8 +203,12 @@ def test_DRAM_access_counter_basic(): n = 512 m = 256 l = 128 - f32 = poly.dict[(np.dtype(np.float32), 'uniform')].eval_with_dict({'n': n, 'm': m, 'l': l}) - f64 = poly.dict[(np.dtype(np.float64), 'uniform')].eval_with_dict({'n': n, 'm': m, 'l': l}) + f32 = poly.dict[ + (np.dtype(np.float32), 'uniform') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) + f64 = poly.dict[ + (np.dtype(np.float64), 'uniform') + ].eval_with_dict({'n': n, 'm': m, 'l': l}) assert f32 == 3*n*m*l assert f64 == 2*n*m @@ -310,7 +314,7 @@ def test_DRAM_access_counter_bitwise(): assert i32 == 4*n*m+2*n*m*l -def test_DRAM_access_counter_weird(): +def test_DRAM_access_counter_mixed(): knl = lp.make_kernel( "[n,m,l] -> {[i,k,j]: 0<=i {[i,k,j]: 0<=i {[i,k,j]: 0<=i {[i,k,j]: 0<=i<50 and 1<=k<98 and 0<=j<10}", @@ -448,8 +448,48 @@ def test_barrier_counter(): m = 256 l = 128 barrier_count = poly.eval_with_dict({'n': n, 'm': m, 'l': l}) - assert barrier_count == 1000 - # TODO more barrier counting tests + assert barrier_count == 50*10*2 + + +def test_all_counters_parallel_matmul(): + + knl = lp.make_kernel( + "{[i,k,j]: 0<=i