Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fada39

Browse files
Adding NUMBA_ENABLE_PROFILING envvar, enabling jit events and sets default value for NUMBA_DEBUGINFO
1 parent 6edd6ef commit 7fada39

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

numba/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,18 @@ def avx_default():
302302
NUMBA_NUM_THREADS = _readenv("NUMBA_NUM_THREADS", int,
303303
NUMBA_DEFAULT_NUM_THREADS)
304304

305+
# Profiling support
306+
307+
# Indicates if profiler is detected. Only VTune can be detected for now
308+
RUNNING_UNDER_PROFILER = 'VS_PROFILER' in os.environ
309+
310+
# Enables jit events in LLVM in order to support profiling of dynamic code
311+
ENABLE_PROFILING = _readenv("NUMBA_ENABLE_PROFILING", int, int(RUNNING_UNDER_PROFILER))
312+
305313
# Debug Info
306314

307315
# The default value for the `debug` flag
308-
DEBUGINFO_DEFAULT = _readenv("NUMBA_DEBUGINFO", int, 0)
316+
DEBUGINFO_DEFAULT = _readenv("NUMBA_DEBUGINFO", int, ENABLE_PROFILING)
309317
CUDA_DEBUGINFO_DEFAULT = _readenv("NUMBA_CUDA_DEBUGINFO", int, 0)
310318

311319
# Inject the configuration values into the module globals

numba/targets/codegen.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ def _init(self, llvm_module):
612612
tm = target.create_target_machine(**tm_options)
613613
engine = ll.create_mcjit_compiler(llvm_module, tm)
614614

615+
if config.ENABLE_PROFILING:
616+
engine.enable_jit_events()
617+
615618
self._tm = tm
616619
self._engine = JitEngine(engine)
617620
self._target_data = engine.target_data

0 commit comments

Comments
 (0)