From 8da1ab88aa8a386356cce9d882a1224eb45d40bd Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 26 Aug 2024 14:16:54 -0700 Subject: [PATCH 1/3] choose_devices: don't short-circuit dev choice when answers available --- pyopencl/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index ab71643ba..f52ee3569 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1648,7 +1648,7 @@ def parse_device(choice): if not devices: raise Error("no devices found") - elif len(devices) == 1: + elif len(devices) == 1 and not answers: pass else: if not answers: @@ -1672,7 +1672,7 @@ def parse_device(choice): if answers: raise RuntimeError("not all provided choices were used by " - "choose_device. (left over: '%s')" % ":".join(answers)) + "choose_devices. (left over: '%s')" % ":".join(answers)) return devices From 55f3e0c2a65491275a55ea25c9d69da22f179271 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Tue, 27 Aug 2024 21:24:05 -0500 Subject: [PATCH 2/3] print automatically chosen device --- pyopencl/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index f52ee3569..c251c0c80 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1649,6 +1649,7 @@ def parse_device(choice): if not devices: raise Error("no devices found") elif len(devices) == 1 and not answers: + print(f"Choosing only available device: {devices[0]}") pass else: if not answers: From edbff40a8affc33e0f05835eef86fe3ffe6edf22 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Tue, 27 Aug 2024 21:28:34 -0500 Subject: [PATCH 3/3] dont print in non-interactive case --- pyopencl/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index c251c0c80..15d1e2bb9 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1649,7 +1649,7 @@ def parse_device(choice): if not devices: raise Error("no devices found") elif len(devices) == 1 and not answers: - print(f"Choosing only available device: {devices[0]}") + cc_print(f"Choosing only available device: {devices[0]}") pass else: if not answers: