diff --git a/python/dune/perftool/sumfact/vectorization.py b/python/dune/perftool/sumfact/vectorization.py index e3edaf2cb70d1a06681742445bc83314b42c306b..b54ada4c402a70c1c34981df2dc79a8c717f6ad8 100644 --- a/python/dune/perftool/sumfact/vectorization.py +++ b/python/dune/perftool/sumfact/vectorization.py @@ -50,17 +50,23 @@ def attach_vectorization_info(sf): return _cache_vectorization_info(sf, None) -@backend(interface="vectorization_costfunction", name="greedy") +@backend(interface="vectorization_strategy", name="greedy") def greedy_costfunction(sf): return 1 -@backend(interface="vectorization_costfunction", name="explicit") +@backend(interface="vectorization_strategy", name="explicit") def explicit_costfunction(sf): # Read the explicitly set values for horizontal and vertical vectorization width = get_vcl_type_size(np.float64) - horizontal = int(get_option("vectorization_horizontal", width)) - vertical = int(get_option("vectorization_vertical", 1)) + horizontal = get_option("vectorization_horizontal") + if horizontal is None: + horizontal = width + vertical = get_option("vectorization_vertical") + if vertical is None: + vertical = 1 + horizontal = int(horizontal) + vertical = int(vertical) if sf.horizontal_width == horizontal and sf.vertical_width == vertical: return 1 @@ -71,8 +77,8 @@ def explicit_costfunction(sf): def strategy_cost(strategy): qp, strategy = strategy set_quadrature_points(qp) - func = get_backend(interface="vectorization_costfunction", - name=get_option("vectorization_strategy")) + func = get_backend(interface="vectorization_strategy", + selector=lambda: get_option("vectorization_strategy")) return sum(float(func(sf)) for sf in strategy.values()) @@ -80,8 +86,8 @@ def stringify_vectorization_strategy(strategy): result = [] qp, strategy = strategy - result.append["Printing potential vectorization strategy:"] - result.append["Quadrature point tuple: {}".format(qp)] + result.append("Printing potential vectorization strategy:") + result.append("Quadrature point tuple: {}".format(qp)) # Look for all realizations in the strategy and iterate over them cache_keys = frozenset(v.cache_key for v in strategy.values()) @@ -89,14 +95,16 @@ def stringify_vectorization_strategy(strategy): # Filter all the kernels that are realized by this and print for key in strategy: if strategy[key].cache_key == ck: - result.append["{}:".format(key)] + result.append("{}:".format(key)) # Find one representative to print for val in strategy.values(): if val.cache_key == ck: - result.append[" {}".format(val)] + result.append(" {}".format(val)) break + return result + def decide_vectorization_strategy(): """ Decide how to vectorize! @@ -144,7 +152,7 @@ def decide_vectorization_strategy(): # Register the results for sf in all_sumfacts: - _cache_vectorization_info(sf, sfdict.get(sf, no_vec(sf))) + _cache_vectorization_info(sf, sfdict[sf]) def vectorization_opportunity_generator(sumfacts, width):