10
10
11
11
12
12
def _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.
18
26
"""
27
+
19
28
value = os .environ .get (name )
20
29
if value is None :
21
30
return default () if callable (default ) else default
22
31
try :
23
32
return ctor (value )
24
33
except Exception :
25
34
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 )
27
36
)
28
37
return default
29
38
30
39
31
40
def __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
+ """
33
51
return getattr (config , name )
34
52
35
53
@@ -44,6 +62,7 @@ def __getattr__(name):
44
62
45
63
# Emit debug info
46
64
DEBUG = _readenv ("NUMBA_DPEX_DEBUG" , int , config .DEBUG )
65
+ # The default value for the `debug` flag
47
66
DEBUGINFO_DEFAULT = _readenv (
48
67
"NUMBA_DPEX_DEBUGINFO" , int , config .DEBUGINFO_DEFAULT
49
68
)
@@ -58,21 +77,18 @@ def __getattr__(name):
58
77
# a kernel decorated function
59
78
DEBUG_KERNEL_LAUNCHER = _readenv ("NUMBA_DPEX_DEBUG_KERNEL_LAUNCHER" , int , 0 )
60
79
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 off.
71
81
ENABLE_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 off.
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 )
75
90
91
+ # Unused flags
76
92
TESTING_SKIP_NO_DPNP = _readenv ("NUMBA_DPEX_TESTING_SKIP_NO_DPNP" , int , 0 )
77
93
TESTING_SKIP_NO_DEBUGGING = _readenv (
78
94
"NUMBA_DPEX_TESTING_SKIP_NO_DEBUGGING" , int , 1
0 commit comments