1010
1111
1212def _readenv (name , ctor , default ):
13- """Original version from numba/core/config.py
14- class _EnvReloader():
15- ...
16- def process_environ():
17- def _readenv(): ...
13+ """Read/write values from/into system environment variable list.
14+
15+ This function is used to read and write values from (and into) system `env`.
16+ This is adapted from `process_environ()` function of `_EnvLoader` class in
17+ `numba/core/config.py`.
18+
19+ Args:
20+ name (str): The name of the env variable.
21+ ctor (type): The type of the env variable.
22+ default (int,float,str): The default value of the env variable.
23+
24+ Returns:
25+ int,float,string: The environment variable value of the specified type.
1826 """
27+
1928 value = os .environ .get (name )
2029 if value is None :
2130 return default () if callable (default ) else default
2231 try :
2332 return ctor (value )
2433 except Exception :
2534 logging .exception (
26- "environ %s defined but failed to parse '%s'" % (name , value )
35+ "env variable %s defined but failed to parse '%s'" % (name , value )
2736 )
2837 return default
2938
3039
3140def __getattr__ (name ):
32- """Fallback to Numba config"""
41+ """__getattr__ for numba_dpex's config module.
42+
43+ This will be used to fallback to numba's config.
44+
45+ Args:
46+ name (str): The name of the env variable.
47+
48+ Returns:
49+ int,float,str: The environment variable value from numba.
50+ """
3351 return getattr (config , name )
3452
3553
@@ -44,6 +62,7 @@ def __getattr__(name):
4462
4563# Emit debug info
4664DEBUG = _readenv ("NUMBA_DPEX_DEBUG" , int , config .DEBUG )
65+ # The default value for the `debug` flag
4766DEBUGINFO_DEFAULT = _readenv (
4867 "NUMBA_DPEX_DEBUGINFO" , int , config .DEBUGINFO_DEFAULT
4968)
@@ -58,21 +77,18 @@ def __getattr__(name):
5877# a kernel decorated function
5978DEBUG_KERNEL_LAUNCHER = _readenv ("NUMBA_DPEX_DEBUG_KERNEL_LAUNCHER" , int , 0 )
6079
61- # configs for caching
62- # To see the debug messages for the caching.
63- # Execute like:
64- # NUMBA_DPEX_DEBUG_CACHE=1 python <code>
65- DEBUG_CACHE = _readenv ("NUMBA_DPEX_DEBUG_CACHE" , int , 0 )
66- # This is a global flag to turn the caching on/off,
67- # regardless of whatever has been specified in Dispatcher.
68- # Useful for debugging. Execute like:
69- # NUMBA_DPEX_ENABLE_CACHE=0 python <code>
70- # to turn off the caching globally.
80+ # Flag to enable caching, set NUMBA_DPEX_ENABLE_CACHE=0 to turn it off.
7181ENABLE_CACHE = _readenv ("NUMBA_DPEX_ENABLE_CACHE" , int , 1 )
72- # Capacity of the cache, execute it like:
73- # NUMBA_DPEX_CACHE_SIZE=20 python <code>
74- CACHE_SIZE = _readenv ("NUMBA_DPEX_CACHE_SIZE" , int , 128 )
82+ # To specify the default cache size, 20 by default.
83+ CACHE_SIZE = _readenv ("NUMBA_DPEX_CACHE_SIZE" , int , 20 )
84+ # Enable debugging of cahcing mechanism, set 1 to turn it on.
85+ DEBUG_CACHE = _readenv ("NUMBA_DPEX_DEBUG_CACHE" , int , 0 )
86+
87+ # Flag to turn on the ConstantSizeStaticLocalMemoryPass in the kernel pipeline.
88+ # The pass is turned off by default.
89+ STATIC_LOCAL_MEM_PASS = _readenv ("NUMBA_DPEX_STATIC_LOCAL_MEM_PASS" , int , 0 )
7590
91+ # Unused flags
7692TESTING_SKIP_NO_DPNP = _readenv ("NUMBA_DPEX_TESTING_SKIP_NO_DPNP" , int , 0 )
7793TESTING_SKIP_NO_DEBUGGING = _readenv (
7894 "NUMBA_DPEX_TESTING_SKIP_NO_DEBUGGING" , int , 1
0 commit comments