MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / expand_nvtx_range_names

Function expand_nvtx_range_names

bench/python/benchmark.py:234–301  ·  view source on GitHub ↗

Converts a hierarchical NVTX range tree with parent-child relationship into a flat tree by adding the names of parent nodes in-front of all the child nodes. Hence, a tree like the following: root child_a sub_child_a child_b

(range_info)

Source from the content-addressed store, hash-verified

232
233
234def expand_nvtx_range_names(range_info):
235 """
236 Converts a hierarchical NVTX range tree with parent-child relationship into a flat
237 tree by adding the names of parent nodes in-front of all the child nodes.
238 Hence, a tree like the following:
239 root
240 child_a
241 sub_child_a
242 child_b
243 child_c
244 sub_child_c
245
246 becomes:
247 root
248 root.child_a
249 root.child_a.sub_child_a
250 root.child_b
251 root.child_c
252 root.child_c.sub_child-c
253
254 :param range_info: The range_info dictionary returned by the parsing functions.
255 """
256 final_dict = {}
257
258 # Loop over all the process from the range info dictionary.
259 for process_id in range_info:
260 if process_id not in final_dict:
261 final_dict[process_id] = {}
262
263 # Loop over all the threads from the range info dictionary.
264 for thread_id in range_info[process_id]:
265 if thread_id not in final_dict[process_id]:
266 final_dict[process_id][thread_id] = {}
267
268 # Loop over all the ranges from the range info dictionary.
269 for range_id in range_info[process_id][thread_id]:
270
271 # Fetch the range information.
272 nvtx_range = range_info[process_id][thread_id][range_id]
273
274 # There are two cases to consider:
275 # 1. This was a root node (i.e no parent)
276 # 2. This is not a root node (i.e has a parent)
277 #
278 my_parent_id = nvtx_range.parent_range_id
279 if my_parent_id and my_parent_id != "None":
280 # This is not a root node. Get the information of its parent.
281 parent_nvtx_range = range_info[process_id][thread_id][my_parent_id]
282 # prepend parent's name in the child's name
283 new_name = os.path.join(
284 parent_nvtx_range.flat_name, nvtx_range.flat_name
285 )
286
287 # Most important to update our existing range info dictionary
288 # so any nested children will end up using the new, fully
289 # qualified name of this range.
290 nvtx_range.flat_name = new_name
291 range_info[process_id][thread_id][range_id] = nvtx_range

Callers 1

benchmark_scriptFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected