8 __all__ = [
'range_push',
'range_pop',
'mark']
11 def windows_nvToolsExt_lib():
12 lib_path = windows_nvToolsExt_path()
14 lib_name = os.path.basename(lib_path)
15 lib = os.path.splitext(lib_name)[0]
16 return ctypes.cdll.LoadLibrary(lib)
21 def windows_nvToolsExt_path():
22 WINDOWS_HOME =
'C:/Program Files/NVIDIA Corporation/NvToolsExt' 23 NVTOOLEXT_HOME = os.getenv(
'NVTOOLSEXT_PATH', WINDOWS_HOME)
24 if os.path.exists(NVTOOLEXT_HOME):
25 lib_paths = glob.glob(NVTOOLEXT_HOME +
'/bin/x64/nvToolsExt*.dll')
26 if len(lib_paths) > 0:
27 lib_path = lib_paths[0]
35 if platform.system() !=
'Windows':
36 lib = ctypes.cdll.LoadLibrary(
None)
38 lib = windows_nvToolsExt_lib()
39 lib.nvtxMarkA.restype =
None 45 Pushes a range onto a stack of nested range span. Returns zero-based 46 depth of the range that is started. 49 msg (string): ASCII message to associate with range 51 if _libnvToolsExt()
is None:
52 raise RuntimeError(
'Unable to load nvToolsExt library')
53 return lib.nvtxRangePushA(ctypes.c_char_p(msg.encode(
"ascii")))
58 Pops a range off of a stack of nested range spans. Returns the 59 zero-based depth of the range that is ended. 61 if _libnvToolsExt()
is None:
62 raise RuntimeError(
'Unable to load nvToolsExt library')
63 return lib.nvtxRangePop()
68 Describe an instantaneous event that occurred at some point. 71 msg (string): ASCII message to associate with the event. 73 if _libnvToolsExt()
is None:
74 raise RuntimeError(
'Unable to load nvToolsExt library')
75 return lib.nvtxMarkA(ctypes.c_char_p(msg.encode(
"ascii")))