diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 037743a0aaa87562fa209f472460802d6ea1ca42..7920c542e31a0469f17ac9e4151ab91da9915bbd 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -1223,8 +1223,7 @@ Note that loopy will infer the data types for arrays c and e from the informatio .. doctest:: - >>> for key in op_map.dict.keys(): - ... print("%s : %s" % (key, op_map.dict[key])) + >>> print(op_map) float64 : [n, m, l] -> { 2 * n * m : n >= 1 and m >= 1 and l >= 1 } int32 : [n, m, l] -> { n * m : n >= 1 and m >= 1 and l >= 1 } float32 : [n, m, l] -> { 3 * n * m * l : n >= 1 and m >= 1 and l >= 1 } @@ -1251,8 +1250,7 @@ Counting array accesses >>> from loopy.statistics import get_DRAM_access_poly >>> load_store_map = get_DRAM_access_poly(knl) - >>> for key in load_store_map.dict.keys(): - ... print("%s : %s" % (key, load_store_map.dict[key])) + >>> print(load_store_map) (dtype('float32'), 'uniform', 'store') : [n, m, l] -> { n * m * l : n >= 1 and m >= 1 and l >= 1 } (dtype('float64'), 'uniform', 'load') : [n, m, l] -> { 2 * n * m : n >= 1 and m >= 1 and l >= 1 } (dtype('float64'), 'uniform', 'store') : [n, m, l] -> { n * m : n >= 1 and m >= 1 and l >= 1 } @@ -1284,7 +1282,7 @@ We can evaluate these polynomials using :func:`islpy.eval_with_dict`: ~~~~~~~~~~~ -Since we have not tagged any of the inames or parallelized the kernel across threads (which would have produced iname tags), :func:`loopy.get_DRAM_access_poly` considers the array accesses *uniform*. Now we'll parallelize the kernel and count the array accesses again: +Since we have not tagged any of the inames or parallelized the kernel across threads (which would have produced iname tags), :func:`loopy.get_DRAM_access_poly` considers the array accesses *uniform*. Now we'll parallelize the kernel and count the array accesses again. The resulting :class:`islpy.PwQPolynomial` will be more complicated this time, so we'll print the mapping manually to make it more legible: .. doctest:: diff --git a/loopy/statistics.py b/loopy/statistics.py index af2dcce297642be58a95dd159127ad4dce411965..52c6b5eeba4f246fd79b9600db5edee9dfbd3c47 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -76,7 +76,10 @@ class ToCountMap: return isl.PwQPolynomial('{ 0 }') def __str__(self): - return str(self.dict) + result = "" + for key in self.dict.keys(): + result += ("%s : %s\n" % (key, self.dict[key])) + return result def __repr__(self): return repr(self.dict)