Skip to content

Commit 22c11ca

Browse files
committed
rename flag to DISABLE_OPENCL
1 parent 40136ed commit 22c11ca

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

pytissueoptics/rayscattering/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616
from .energyLogging import EnergyLogger
1717
from .materials import ScatteringMaterial
18-
from .opencl import CONFIG, forceCalculationOnCPU, hardwareAccelerationIsAvailable
18+
from .opencl import CONFIG, disableOpenCL, hardwareAccelerationIsAvailable
1919
from .photon import Photon
2020
from .scatteringScene import ScatteringScene
2121
from .source import DirectionalSource, DivergentSource, IsotropicPointSource, PencilPointSource
@@ -49,6 +49,7 @@
4949
"View2DSliceZ",
5050
"samples",
5151
"Stats",
52+
"disableOpenCL",
5253
"hardwareAccelerationIsAvailable",
5354
"CONFIG",
5455
]

pytissueoptics/rayscattering/opencl/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
OPENCL_OK = True
6-
PYTISSUE_FORCE_CPU = os.environ.get('PYTISSUE_FORCE_CPU', '0')
6+
OPENCL_DISABLED = os.environ.get("PTO_DISABLE_OPENCL", "0") == "1"
77

88
if OPENCL_AVAILABLE:
99
try:
@@ -15,15 +15,17 @@
1515
else:
1616
CONFIG = None
1717

18-
def forceCalculationOnCPU():
19-
os.environ["PYTISSUE_FORCE_CPU"] = "1"
20-
print("You can define PYTISSUE_FORCE_CPU=1 in your profile to avoid this call.")
18+
19+
def disableOpenCL():
20+
os.environ["PTO_DISABLE_OPENCL"] = "1"
21+
print("You can define PTO_DISABLE_OPENCL=1 in your profile to avoid this call.")
22+
2123

2224
def validateOpenCL() -> bool:
2325
notAvailableMessage = "Error: Hardware acceleration not available. Falling back to CPU. "
24-
25-
if os.environ.get("PYTISSUE_FORCE_CPU", '0') != '0':
26-
warnings.warn("User requested not using OpenCL with environment variable 'PYTISSUE_FORCE_CPU'=1.")
26+
27+
if os.environ.get("PTO_DISABLE_OPENCL", "0") == "1":
28+
warnings.warn("User requested not to use OpenCL with environment variable 'PTO_DISABLE_OPENCL'=1.")
2729
return False
2830
if not OPENCL_AVAILABLE:
2931
warnings.warn(notAvailableMessage + "Please install pyopencl.")
@@ -37,7 +39,7 @@ def validateOpenCL() -> bool:
3739

3840

3941
def hardwareAccelerationIsAvailable() -> bool:
40-
return OPENCL_AVAILABLE and OPENCL_OK and not PYTISSUE_FORCE_CPU
42+
return OPENCL_AVAILABLE and OPENCL_OK and not OPENCL_DISABLED
4143

4244

4345
__all__ = ["IPPTable", "WEIGHT_THRESHOLD"]

0 commit comments

Comments
 (0)