@@ -388,13 +388,6 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
388388 region_starts = thread_events .index [thread_events ["value" ] != 0 ]
389389 region_ends = thread_events .index [thread_events ["value" ] == 0 ]
390390
391- # Now sanity check regions and try to repair issues caused by missing events:
392- # Cut traces seem to have an extra end event injected by the cutter trying to
393- # be "helpful" If this seems to be the case try trimming the end and post a
394- # warning
395- if len (region_ends ) == len (region_starts ) + 1 :
396- region_ends = region_ends [:- 1 ]
397-
398391 # First region start should be earlier than first region end
399392 if region_ends [0 ] <= region_starts [0 ]:
400393 warn (
@@ -413,6 +406,14 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
413406 while len (region_starts ) > 0 and region_starts [- 1 ] >= region_ends [- 1 ]:
414407 region_starts = region_starts [:- 1 ]
415408
409+ # Now sanity check regions and try to repair issues caused by missing events:
410+ # Cut traces seem to have an extra end event injected by the cutter trying to
411+ # be "helpful" If this seems to be the case try trimming the end and post a
412+ # warning
413+ if len (region_ends ) == len (region_starts ) + 1 :
414+ region_ends = region_ends [:- 1 ]
415+ warn ("Attempting to trim spurious events - cutter inserted?" )
416+
416417 if np .any (region_starts > region_ends ):
417418 raise ValueError ("Unable to make sense of OpenMP region events." )
418419
@@ -426,7 +427,10 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
426427 funcbins = pd .cut (
427428 rank_funcs .droplevel (("task" , "thread" )).index , regionintervals
428429 ).codes
429- region_funcs = rank_funcs .droplevel (("task" , "thread" )).groupby (funcbins )
430+ # Remove negative categories codes -> events not in any region interval
431+ cleaned_rfuncs = rank_funcs .droplevel (("task" , "thread" ))[funcbins >= 0 ]
432+ cleaned_fbins = funcbins [funcbins >= 0 ]
433+ region_funcs = cleaned_rfuncs .groupby (cleaned_fbins )
430434 region_fingerprints_func = region_funcs .apply (
431435 lambda x : ":" .join (
432436 [
@@ -439,9 +443,11 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
439443 funclocbins = pd .cut (
440444 rank_func_locs .droplevel (("task" , "thread" )).index , regionintervals
441445 ).codes
442- region_func_locs = rank_func_locs .droplevel (("task" , "thread" )).groupby (
443- funclocbins
444- )
446+ cleaned_rflocs = rank_func_locs .droplevel (("task" , "thread" ))[
447+ funclocbins >= 0
448+ ]
449+ cleaned_flbins = funclocbins [funclocbins >= 0 ]
450+ region_func_locs = cleaned_rflocs .groupby (cleaned_flbins )
445451 region_fingerprints_loc = region_func_locs .apply (
446452 lambda x : ":" .join (
447453 [
0 commit comments