Lines 1-5
Link Here
|
1 |
--- lib/CL/devices/cpuinfo.c.orig 2020-12-16 13:02:13 UTC |
1 |
--- lib/CL/devices/cpuinfo.c.orig 2021-10-12 16:33:15.000000000 +0200 |
2 |
+++ lib/CL/devices/cpuinfo.c |
2 |
+++ lib/CL/devices/cpuinfo.c 2021-10-16 09:29:13.414668000 +0200 |
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 |
@@ -41,9 +47,6 @@ static const char* cpuinfo = "/proc/cpuinfo"; |
16 |
@@ -41,9 +47,6 @@ |
17 |
//Linux' cpufrec interface |
17 |
//Linux' cpufrec interface |
18 |
static const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; |
18 |
static const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; |
19 |
|
19 |
|
Lines 23-29
Link Here
|
23 |
/* Strings to parse in /proc/cpuinfo. Else branch is for x86, x86_64 */ |
23 |
/* Strings to parse in /proc/cpuinfo. Else branch is for x86, x86_64 */ |
24 |
#if defined __powerpc__ |
24 |
#if defined __powerpc__ |
25 |
#define FREQSTRING "clock" |
25 |
#define FREQSTRING "clock" |
26 |
@@ -156,8 +159,51 @@ pocl_cpuinfo_detect_max_clock_frequency() |
26 |
@@ -156,8 +159,51 @@ |
27 |
} |
27 |
} |
28 |
return -1; |
28 |
return -1; |
29 |
} |
29 |
} |
Lines 75-81
Link Here
|
75 |
/** |
75 |
/** |
76 |
* Detects the number of parallel hardware threads supported by |
76 |
* Detects the number of parallel hardware threads supported by |
77 |
* the CPU by parsing the cpuinfo. |
77 |
* the CPU by parsing the cpuinfo. |
78 |
@@ -235,6 +281,19 @@ pocl_cpuinfo_detect_compute_unit_count() |
78 |
@@ -235,6 +281,19 @@ |
79 |
} |
79 |
} |
80 |
return -1; |
80 |
return -1; |
81 |
} |
81 |
} |
Lines 95-101
Link Here
|
95 |
|
95 |
|
96 |
#if __arm__ || __aarch64__ |
96 |
#if __arm__ || __aarch64__ |
97 |
enum |
97 |
enum |
98 |
@@ -302,6 +361,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi |
98 |
@@ -302,6 +361,7 @@ |
99 |
* short_name is in the .data anyways.*/ |
99 |
* short_name is in the .data anyways.*/ |
100 |
device->long_name = device->short_name; |
100 |
device->long_name = device->short_name; |
101 |
|
101 |
|
Lines 103-109
Link Here
|
103 |
/* 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 */ |
104 |
device->vendor = cpuvendor_default; |
104 |
device->vendor = cpuvendor_default; |
105 |
if (device->vendor_id == 0) |
105 |
if (device->vendor_id == 0) |
106 |
@@ -404,7 +464,26 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi |
106 |
@@ -404,7 +464,26 @@ |
107 |
char *new_name = (char*)malloc (len); |
107 |
char *new_name = (char*)malloc (len); |
108 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
108 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
109 |
device->long_name = new_name; |
109 |
device->long_name = new_name; |
Lines 130-154
Link Here
|
130 |
/* If the vendor_id field is still empty, we should get the PCI ID associated |
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 |
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 |
132 |
* provisional) OpenCL 3.0 specification that has finally clarified the |
133 |
@@ -415,10 +494,20 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi |
133 |
@@ -415,13 +494,23 @@ |
134 |
*/ |
134 |
*/ |
135 |
if (!device->vendor_id) |
135 |
if (!device->vendor_id) |
136 |
{ |
136 |
{ |
137 |
- f = fopen (pci_bus_root_vendor_file, "r"); |
137 |
- f = fopen (pci_bus_root_vendor_file, "r"); |
138 |
- num_read = fscanf (f, "%x", &device->vendor_id); |
138 |
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
139 |
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
139 |
+ /* |
140 |
+ /* |
140 |
+ * Future work: try to extract vendor ID from PCI root bus from MIB |
141 |
+ * Future work: try to extract vendor ID from PCI root bus from MIB |
141 |
+ */ |
142 |
+ */ |
|
|
143 |
+#elif defined(__linux__) |
142 |
+#elif defined(__linux__) |
144 |
+ FILE *f = fopen (pci_bus_root_vendor_file, "r"); |
143 |
+ FILE *f = fopen (pci_bus_root_vendor_file, "r"); |
145 |
+ int num_read = fscanf (f, "%x", &device->vendor_id); |
144 |
if (f) |
146 |
fclose (f); |
145 |
{ |
147 |
/* no error checking, if it failed we just won't have the info */ |
146 |
/* no error checking, if it failed we just won't have the info */ |
|
|
147 |
num_read = fscanf (f, "%x", &device->vendor_id); |
148 |
fclose (f); |
149 |
} |
148 |
+#else |
150 |
+#else |
149 |
+ /* |
151 |
+ /* |
150 |
+ * Other aliens ... |
152 |
+ * Other aliens ... |
151 |
+ */ |
153 |
+ */ |
152 |
+#endif |
154 |
+#endif |
153 |
} |
155 |
} |
154 |
} |
156 |
} |