Skip to content
Snippets Groups Projects
Commit d35842be authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

print_highlighted_code -> get_highlighted_code.

parent 8f4f32cd
No related branches found
No related tags found
No related merge requests found
...@@ -203,22 +203,25 @@ class CompiledKernel: ...@@ -203,22 +203,25 @@ class CompiledKernel:
return evt, outputs return evt, outputs
def print_code(self):
print get_highlighted_code(self.code)
# }}} # }}}
def print_highlighted_code(text): def get_highlighted_code(text):
try: try:
from pygments import highlight from pygments import highlight
except ImportError: except ImportError:
print text return text
else: else:
from pygments.lexers import CLexer from pygments.lexers import CLexer
from pygments.formatters import TerminalFormatter from pygments.formatters import TerminalFormatter
print highlight(text, CLexer(), TerminalFormatter()) return highlight(text, CLexer(), TerminalFormatter())
...@@ -257,7 +260,7 @@ def drive_timing_run(kernel_generator, queue, launch, flop_count=None, ...@@ -257,7 +260,7 @@ def drive_timing_run(kernel_generator, queue, launch, flop_count=None,
print "SOLUTION #%d" % soln_count print "SOLUTION #%d" % soln_count
print "-----------------------------------------------" print "-----------------------------------------------"
if print_code: if print_code:
print_highlighted_code(compiled.code) print get_highlighted_code(compiled.code)
print "-----------------------------------------------" print "-----------------------------------------------"
elapsed = time_run(compiled) elapsed = time_run(compiled)
...@@ -497,7 +500,7 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet ...@@ -497,7 +500,7 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet
print 75*"-" print 75*"-"
print "Reference Code:" print "Reference Code:"
print 75*"-" print 75*"-"
print_highlighted_code(ref_compiled.code) print get_highlighted_code(ref_compiled.code)
print 75*"-" print 75*"-"
ref_args, ref_input_arrays, ref_output_arrays = \ ref_args, ref_input_arrays, ref_output_arrays = \
...@@ -543,7 +546,7 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet ...@@ -543,7 +546,7 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet
print "Kernel #%d:" % i print "Kernel #%d:" % i
print 75*"-" print 75*"-"
if print_code: if print_code:
print_highlighted_code(compiled.code) print get_highlighted_code(compiled.code)
print 75*"-" print 75*"-"
if dump_binary: if dump_binary:
print type(compiled.cl_program) print type(compiled.cl_program)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment