1010from common import find_file
1111
1212
13+ def find_windows_tbb_runtime_dir () -> Path | None :
14+ build_root = Path ("build" ).resolve ()
15+ fallback : Path | None = None
16+ for current_root , _ , files in os .walk (build_root ):
17+ current_files = set (files )
18+ if "tbb12.dll" not in current_files :
19+ continue
20+
21+ candidate = Path (current_root )
22+ if "tbbmalloc.dll" in current_files or "tbbmalloc_proxy.dll" in current_files :
23+ return candidate
24+ if fallback is None :
25+ fallback = candidate
26+
27+ return fallback
28+
29+
1330def configure_windows_opencl_tbb () -> None :
1431 if os .environ .get ("RUNNER_OS" ) != "Windows" :
1532 return
@@ -22,11 +39,11 @@ def configure_windows_opencl_tbb() -> None:
2239 if not config_path .exists ():
2340 return
2441
25- tbb_dll = find_file ([ Path ( "build" ). resolve ()], "tbb12.dll" )
26- if tbb_dll is None :
42+ tbb_runtime_dir = find_windows_tbb_runtime_dir ( )
43+ if tbb_runtime_dir is None :
2744 return
2845
29- tbb_dir = str (tbb_dll . parent .resolve ())
46+ tbb_dir = str (tbb_runtime_dir .resolve ())
3047 existing_lines = config_path .read_text (encoding = "utf-8" ).splitlines ()
3148 updated_lines : list [str ] = []
3249 updated = False
@@ -48,6 +65,11 @@ def main() -> int:
4865 configure_windows_opencl_tbb ()
4966
5067 env = os .environ .copy ()
68+ if os .environ .get ("RUNNER_OS" ) == "Windows" :
69+ tbb_runtime_dir = find_windows_tbb_runtime_dir ()
70+ if tbb_runtime_dir is not None :
71+ env ["PATH" ] = f"{ tbb_runtime_dir } { os .pathsep } { env .get ('PATH' , '' )} "
72+
5173 device_selector = env .get ("DEVICE_SELECTOR" , "" )
5274 if device_selector :
5375 env ["ONEAPI_DEVICE_SELECTOR" ] = device_selector
0 commit comments