diff --git a/examples/python/kernel_stat_collector.py b/examples/python/kernel_stat_collector.py new file mode 100644 index 0000000000000000000000000000000000000000..5924b6b30ca7524d12050764b6e43dffe7eb4917 --- /dev/null +++ b/examples/python/kernel_stat_collector.py @@ -0,0 +1,88 @@ +import loopy as lp +import numpy as np +from loopy.kernel_stat_collector.kernel_stat_collector import KernelStatCollector +from loopy.kernel_stat_collector.kernel_stat_collector import KernelStatOptions as kso # noqa + + +knl = lp.make_kernel( + "{[i,k,j]: 0<=i { 1/14 * n }"), PwQPolynomial("[n] -> { 1/14 * n }")], [PwQPolynomial("[n] -> { 16 }"), PwQPolynomial("[n] -> { 16 }")]]' + assert len(stats[kso.SYNC_MAP]) == 2 + assert stats[kso.SYNC_MAP]["kernel_launch"].eval_with_dict(param_dict) == 1 + assert stats[kso.OP_MAP][lp.Op(np.float32, 'mul', CG.SUBGROUP)].eval_with_dict(param_dict) == 2048 + assert len(stats[kso.MEM_ACCESS_MAP]) == 4 + + +if __name__ == "__main__": + if len(sys.argv) > 1: + exec(sys.argv[1]) + else: + from pytest import main + main([__file__]) +