File: 0002-check-also-CPU-devices.patch

package info (click to toggle)
pyvkfft 2024.1.4%2Bds1-3.1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 36,820 kB
  • sloc: python: 5,527; cpp: 210; makefile: 25; sh: 9
file content (51 lines) | stat: -rw-r--r-- 1,928 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From: =?utf-8?q?Picca_Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
Date: Tue, 27 Feb 2024 11:13:58 +0100
Subject: check also CPU devices

---
 pyvkfft/accuracy.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/pyvkfft/accuracy.py b/pyvkfft/accuracy.py
index ea28172..1cdad33 100644
--- a/pyvkfft/accuracy.py
+++ b/pyvkfft/accuracy.py
@@ -69,6 +69,7 @@ gpu_ctx_dic = {}
 
 
 def init_ctx(backend, gpu_name=None, opencl_platform=None, verbose=False):
+    verbose=True
     if backend in gpu_ctx_dic:
         return
     if backend == "pycuda":
@@ -97,13 +98,30 @@ def init_ctx(backend, gpu_name=None, opencl_platform=None, verbose=False):
             raise RuntimeError("init_ctx: backend=%s is not available" % backend)
         d = None
         for p in cl.get_platforms():
+            if verbose:
+                print(f"platforme: {p}")
             if d is not None:
                 break
             if opencl_platform is not None:
                 if opencl_platform.lower() not in p.name.lower():
                     continue
+            if verbose:
+                print(f"devices: {p.get_devices()}")
             for d0 in p.get_devices():
                 if d0.type & cl.device_type.GPU:
+                    if verbose:
+                        print(f"trying GPU device: {d0}")
+                    if gpu_name is not None:
+                        if gpu_name.lower() in d0.name.lower():
+                            d = d0
+                    else:
+                        d = d0
+                if d is not None:
+                    break
+            for d0 in p.get_devices():
+                if d0.type & cl.device_type.CPU:
+                    if verbose:
+                        print(f"trying CPU device: {d0}")
                     if gpu_name is not None:
                         if gpu_name.lower() in d0.name.lower():
                             d = d0