Lines 1-5
Link Here
|
1 |
--- lib/CL/devices/cpuinfo.c.orig 2019-04-04 12:06:59 UTC |
1 |
--- lib/CL/devices/cpuinfo.c.orig 2020-12-16 14:02:13.000000000 +0100 |
2 |
+++ lib/CL/devices/cpuinfo.c |
2 |
+++ lib/CL/devices/cpuinfo.c 2020-12-19 10:46:13.846666000 +0100 |
3 |
@@ -34,6 +34,12 @@ |
3 |
@@ -34,6 +34,12 @@ |
4 |
#include "config.h" |
4 |
#include "config.h" |
5 |
#include "cpuinfo.h" |
5 |
#include "cpuinfo.h" |
Lines 13-19
Link Here
|
13 |
static const char* cpuinfo = "/proc/cpuinfo"; |
13 |
static const char* cpuinfo = "/proc/cpuinfo"; |
14 |
#define MAX_CPUINFO_SIZE 64*1024 |
14 |
#define MAX_CPUINFO_SIZE 64*1024 |
15 |
//#define DEBUG_POCL_CPUINFO |
15 |
//#define DEBUG_POCL_CPUINFO |
16 |
@@ -153,8 +159,51 @@ pocl_cpuinfo_detect_max_clock_frequency() |
16 |
@@ -41,9 +47,6 @@ |
|
|
17 |
//Linux' cpufrec interface |
18 |
static const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; |
19 |
|
20 |
-// Vendor of PCI root bus |
21 |
-static const char *pci_bus_root_vendor_file = "/sys/bus/pci/devices/0000:00:00.0/vendor"; |
22 |
- |
23 |
/* Strings to parse in /proc/cpuinfo. Else branch is for x86, x86_64 */ |
24 |
#if defined __powerpc__ |
25 |
#define FREQSTRING "clock" |
26 |
@@ -156,8 +159,51 @@ |
17 |
} |
27 |
} |
18 |
return -1; |
28 |
return -1; |
19 |
} |
29 |
} |
Lines 54-60
Link Here
|
54 |
+/** |
64 |
+/** |
55 |
+ * Unimplemented for other platforms. |
65 |
+ * Unimplemented for other platforms. |
56 |
+ */ |
66 |
+ */ |
57 |
+ int |
67 |
+int |
58 |
+pocl_cpuinfo_detect_max_clock_frequency() |
68 |
+pocl_cpuinfo_detect_max_clock_frequency() |
59 |
+{ |
69 |
+{ |
60 |
+ return 0; |
70 |
+ return 0; |
Lines 65-71
Link Here
|
65 |
/** |
75 |
/** |
66 |
* Detects the number of parallel hardware threads supported by |
76 |
* Detects the number of parallel hardware threads supported by |
67 |
* the CPU by parsing the cpuinfo. |
77 |
* the CPU by parsing the cpuinfo. |
68 |
@@ -232,6 +281,19 @@ pocl_cpuinfo_detect_compute_unit_count() |
78 |
@@ -235,6 +281,19 @@ |
69 |
} |
79 |
} |
70 |
return -1; |
80 |
return -1; |
71 |
} |
81 |
} |
Lines 83-91
Link Here
|
83 |
+} |
93 |
+} |
84 |
+#endif |
94 |
+#endif |
85 |
|
95 |
|
86 |
#ifdef POCL_ANDROID |
96 |
#if __arm__ || __aarch64__ |
87 |
|
97 |
enum |
88 |
@@ -326,6 +388,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi |
98 |
@@ -302,6 +361,7 @@ |
89 |
* short_name is in the .data anyways.*/ |
99 |
* short_name is in the .data anyways.*/ |
90 |
device->long_name = device->short_name; |
100 |
device->long_name = device->short_name; |
91 |
|
101 |
|
Lines 93-99
Link Here
|
93 |
/* default vendor and vendor_id, in case it cannot be found by other means */ |
103 |
/* default vendor and vendor_id, in case it cannot be found by other means */ |
94 |
device->vendor = cpuvendor_default; |
104 |
device->vendor = cpuvendor_default; |
95 |
if (device->vendor_id == 0) |
105 |
if (device->vendor_id == 0) |
96 |
@@ -425,6 +488,25 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi |
106 |
@@ -404,7 +464,26 @@ |
97 |
char *new_name = (char*)malloc (len); |
107 |
char *new_name = (char*)malloc (len); |
98 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
108 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
99 |
device->long_name = new_name; |
109 |
device->long_name = new_name; |
Lines 101-107
Link Here
|
101 |
+ int mib[2]; |
111 |
+ int mib[2]; |
102 |
+ size_t len = 0; |
112 |
+ size_t len = 0; |
103 |
+ char *model; |
113 |
+ char *model; |
104 |
+ |
114 |
|
105 |
+ mib[0] = CTL_HW; |
115 |
+ mib[0] = CTL_HW; |
106 |
+ mib[1] = HW_MODEL; |
116 |
+ mib[1] = HW_MODEL; |
107 |
+ if (sysctl(mib, 2, NULL, &len, NULL, 0)) |
117 |
+ if (sysctl(mib, 2, NULL, &len, NULL, 0)) |
Lines 116-121
Link Here
|
116 |
+ device->long_name = model; |
126 |
+ device->long_name = model; |
117 |
+ } |
127 |
+ } |
118 |
+#endif |
128 |
+#endif |
|
|
129 |
+ |
130 |
/* If the vendor_id field is still empty, we should get the PCI ID associated |
131 |
* with the CPU vendor (if there is one), to be ready for the (currently |
132 |
* provisional) OpenCL 3.0 specification that has finally clarified the |
133 |
@@ -415,10 +494,20 @@ |
134 |
*/ |
135 |
if (!device->vendor_id) |
136 |
{ |
137 |
- f = fopen (pci_bus_root_vendor_file, "r"); |
138 |
- num_read = fscanf (f, "%x", &device->vendor_id); |
139 |
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
140 |
+ /* |
141 |
+ * Future work: try to extract vendor ID from PCI root bus from MIB |
142 |
+ */ |
143 |
+#elif defined(__linux__) |
144 |
+ FILE *f = fopen (pci_bus_root_vendor_file, "r"); |
145 |
+ int num_read = fscanf (f, "%x", &device->vendor_id); |
146 |
fclose (f); |
147 |
/* no error checking, if it failed we just won't have the info */ |
148 |
+#else |
149 |
+ /* |
150 |
+ * Other aliens ... |
151 |
+ */ |
152 |
+#endif |
153 |
} |
119 |
} |
154 |
} |
120 |
|
155 |
|
121 |
/* |
|
|