From 0386f58489e3bc93fb492a603d4debf8f78fa87a Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 7 Jun 2016 20:43:28 -0500 Subject: [PATCH] Device mapper: Add a comment describing the current temporary variable promotion policy in detail. --- loopy/schedule/device_mapping.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/loopy/schedule/device_mapping.py b/loopy/schedule/device_mapping.py index 924e6942f..9e05afcd9 100644 --- a/loopy/schedule/device_mapping.py +++ b/loopy/schedule/device_mapping.py @@ -325,6 +325,10 @@ class PromotedTemporary(Record): def determine_temporaries_to_promote(kernel, temporaries, name_gen): """ + For each temporary in the passed list of temporaries, construct a + :class:`PromotedTemporary` which describes how the temporary should + get promoted into global storage. + :returns: A :class:`dict` mapping temporary names from `temporaries` to :class:`PromotedTemporary` objects """ @@ -343,6 +347,18 @@ def determine_temporaries_to_promote(kernel, temporaries, name_gen): assert temporary.base_storage is None, \ "Cannot promote temporaries with base_storage to global" + # `hw_inames`: The set of hw-parallel tagged inames that this temporary + # is associated with. This is used for determining the shape of the + # global storage needed for saving and restoring the temporary across + # kernel calls. + # + # TODO: Make a policy decision about which dimensions to use. Currently, + # the code looks at each instruction that defines or uses the temporary, + # and takes the common set of hw-parallel tagged inames associated with + # these instructions. + # + # Furthermore, in the case of local temporaries, inames that are tagged + # hw-local do not contribute to the global storage shape. hw_inames = get_common_hw_inames(kernel, def_lists[temporary.name] + use_lists[temporary.name]) @@ -350,6 +366,8 @@ def determine_temporaries_to_promote(kernel, temporaries, name_gen): hw_inames = sorted(hw_inames, key=lambda iname: str(kernel.iname_to_tag[iname])) + # Calculate the sizes of the dimensions that get added in front for + # the global storage of the temporary. shape_prefix = [] backing_hw_inames = [] -- GitLab