forked from OSchip/llvm-project
[opt-viewer] For single-process, fall back on map instead of Pool.map
This allows for nicer backtrace and debugging when -j1 is passed: $ opt-viewer.py CMakeFiles/LLVMScalarOpts.dir/LoopVersioningLICM.cpp.opt.yaml html Traceback (most recent call last): File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 405, in <module> generate_report(pmap, all_remarks, file_remarks, args.source_dir, args.output_dir) File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 362, in generate_report pmap(_render_file_bound, file_remarks.items()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 251, in map return self.map_async(func, iterable, chunksize).get() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 567, in get raise self._value Exception: blah $ opt-viewer.py -j 1 CMakeFiles/LLVMScalarOpts.dir/LoopVersioningLICM.cpp.opt.yaml html Traceback (most recent call last): File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 405, in <module> generate_report(pmap, all_remarks, file_remarks, args.source_dir, args.output_dir) File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 362, in generate_report pmap(_render_file_bound, file_remarks.items()) File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 317, in _render_file SourceFileRenderer(source_dir, output_dir, filename).render(remarks) File "/org/llvm/utils/opt-viewer/opt-viewer.py", line 168, in __init__ raise Exception("blah") Exception: blah llvm-svn: 295080
This commit is contained in:
parent
d3b5641586
commit
4f6decadc5
|
@ -316,8 +316,8 @@ def _render_file(source_dir, output_dir, ctx, entry):
|
|||
SourceFileRenderer(source_dir, output_dir, filename).render(remarks)
|
||||
|
||||
|
||||
def gather_results(pool, filenames):
|
||||
remarks = pool.map(get_remarks, filenames)
|
||||
def gather_results(pmap, filenames):
|
||||
remarks = pmap(get_remarks, filenames)
|
||||
|
||||
def merge_file_remarks(file_remarks_job, all_remarks, merged):
|
||||
for filename, d in file_remarks_job.iteritems():
|
||||
|
@ -348,7 +348,7 @@ def map_remarks(all_remarks):
|
|||
context.caller_loc[caller] = arg['DebugLoc']
|
||||
|
||||
|
||||
def generate_report(pool, all_remarks, file_remarks, source_dir, output_dir):
|
||||
def generate_report(pmap, all_remarks, file_remarks, source_dir, output_dir):
|
||||
try:
|
||||
os.makedirs(output_dir)
|
||||
except OSError as e:
|
||||
|
@ -358,7 +358,7 @@ def generate_report(pool, all_remarks, file_remarks, source_dir, output_dir):
|
|||
raise
|
||||
|
||||
_render_file_bound = functools.partial(_render_file, source_dir, output_dir, context)
|
||||
pool.map(_render_file_bound, file_remarks.items())
|
||||
pmap(_render_file_bound, file_remarks.items())
|
||||
|
||||
if context.should_display_hotness():
|
||||
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: (r.Hotness, r.__dict__), reverse=True)
|
||||
|
@ -391,9 +391,14 @@ if __name__ == '__main__':
|
|||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if args.jobs == 1:
|
||||
pmap = map
|
||||
else:
|
||||
pool = Pool(processes=args.jobs)
|
||||
all_remarks, file_remarks = gather_results(pool, args.yaml_files)
|
||||
pmap = pool.map
|
||||
|
||||
all_remarks, file_remarks = gather_results(pmap, args.yaml_files)
|
||||
|
||||
map_remarks(all_remarks)
|
||||
|
||||
generate_report(pool, all_remarks, file_remarks, args.source_dir, args.output_dir)
|
||||
generate_report(pmap, all_remarks, file_remarks, args.source_dir, args.output_dir)
|
||||
|
|
Loading…
Reference in New Issue