2
2
#
3
3
# SPDX-License-Identifier: Apache-2.0
4
4
5
- import logging
5
+ import warnings
6
6
7
7
from llvmlite import binding as ll
8
8
from llvmlite import ir as llvmir
@@ -31,7 +31,9 @@ def _optimize_functions(self, ll_module):
31
31
32
32
@property
33
33
def inline_threshold (self ):
34
- """The inlining threshold value to be used to optimize the final library"""
34
+ """
35
+ The inlining threshold value to be used to optimize the final library.
36
+ """
35
37
if hasattr (self , "_inline_threshold" ):
36
38
return self ._inline_threshold
37
39
else :
@@ -41,7 +43,7 @@ def inline_threshold(self):
41
43
def inline_threshold (self , value : int ):
42
44
"""Returns the current inlining threshold level for the library."""
43
45
if value < 0 or value > 3 :
44
- logging . warning (
46
+ warnings . warn (
45
47
"Unsupported inline threshold. Set a value between 0 and 3"
46
48
)
47
49
self ._inline_threshold = 0
@@ -55,44 +57,22 @@ def _optimize_final_module(self):
55
57
# Make optimization level depending on config.DPEX_OPT variable
56
58
pmb .opt_level = config .DPEX_OPT
57
59
if config .DPEX_OPT > 2 :
58
- logging . warning (
60
+ warnings . warn (
59
61
"Setting NUMBA_DPEX_OPT greater than 2 known to cause issues "
60
62
+ "related to very aggressive optimizations that leads to "
61
63
+ "broken code."
62
64
)
63
65
64
66
pmb .disable_unit_at_a_time = False
65
67
66
- if config .INLINE_THRESHOLD is not None :
67
- # Check if a decorator-level inline threshold was set and use that
68
- # instead of the global configuration.
69
- if (
70
- hasattr (self , "_inline_threshold" )
71
- and self ._inline_threshold > 0
72
- and self ._inline_threshold <= 3
73
- ):
74
- logging .warning (
75
- "Setting INLINE_THRESHOLD leads to very aggressive "
76
- + "optimizations that may produce incorrect binary."
77
- )
78
- pmb .inlining_threshold = self ._inline_threshold
79
- elif not hasattr (self , "_inline_threshold" ):
80
- logging .warning (
81
- "Setting INLINE_THRESHOLD leads to very aggressive "
82
- + "optimizations that may produce incorrect binary."
83
- )
84
- pmb .inlining_threshold = config .INLINE_THRESHOLD
85
- else :
86
- if (
87
- hasattr (self , "_inline_threshold" )
88
- and self ._inline_threshold > 0
89
- and self ._inline_threshold <= 3
90
- ):
91
- logging .warning (
92
- "Setting INLINE_THRESHOLD leads to very aggressive "
93
- + "optimizations that may produce incorrect binary."
68
+ if hasattr (self , "_inline_threshold" ) and self ._inline_threshold > 0 :
69
+ if self ._inline_threshold >= 3 :
70
+ warnings .warn (
71
+ "Due to an existing compiler bug, setting INLINE_THRESHOLD "
72
+ f"to { self ._inline_threshold } can lead to incorrect "
73
+ "code generation on certain devices."
94
74
)
95
- pmb .inlining_threshold = self ._inline_threshold
75
+ pmb .inlining_threshold = self ._inline_threshold
96
76
97
77
pmb .disable_unroll_loops = True
98
78
pmb .loop_vectorize = False
0 commit comments