Lines 1-5
Link Here
|
1 |
--- lib/CL/devices/cpuinfo.c.orig 2016-11-20 11:31:19.521203000 +0100 |
1 |
--- lib/CL/devices/cpuinfo.c.orig 2017-04-05 14:15:40 UTC |
2 |
+++ lib/CL/devices/cpuinfo.c 2016-11-20 11:29:24.502817000 +0100 |
2 |
+++ lib/CL/devices/cpuinfo.c |
3 |
@@ -31,9 +31,13 @@ |
3 |
@@ -31,9 +31,13 @@ |
4 |
# include "vccompat.hpp" |
4 |
# include "vccompat.hpp" |
5 |
#endif |
5 |
#endif |
Lines 10-25
Link Here
|
10 |
#include "config.h" |
10 |
#include "config.h" |
11 |
#include "cpuinfo.h" |
11 |
#include "cpuinfo.h" |
12 |
|
12 |
|
13 |
+#if 0 |
13 |
+#ifdef __linux__ |
14 |
const char* cpuinfo = "/proc/cpuinfo"; |
14 |
static const char* cpuinfo = "/proc/cpuinfo"; |
15 |
#define MAX_CPUINFO_SIZE 64*1024 |
15 |
#define MAX_CPUINFO_SIZE 64*1024 |
16 |
//#define DEBUG_POCL_CPUINFO |
16 |
//#define DEBUG_POCL_CPUINFO |
17 |
@@ -152,8 +156,29 @@ pocl_cpuinfo_detect_max_clock_frequency( |
17 |
@@ -153,8 +157,29 @@ pocl_cpuinfo_detect_max_clock_frequency( |
18 |
} |
18 |
} |
19 |
return -1; |
19 |
return -1; |
20 |
} |
20 |
} |
|
|
21 |
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
22 |
+/** |
23 |
+ * Detects the maximum clock frequency of the CPU. |
24 |
+ * |
25 |
+ * Assumes all cores have the same max clock freq. |
26 |
+ * |
27 |
+ * @return The clock frequency in MHz. |
28 |
+ */ |
29 |
+int |
30 |
+pocl_cpuinfo_detect_max_clock_frequency() |
31 |
+{ |
32 |
+ //XXX PLEASE NOTE, THIS IS NOT TOO PORTABLE (AND/OR ACCURATE)! |
33 |
+ const char mib[] = "hw.clockrate"; |
34 |
+ int clockrate; |
35 |
+ size_t size = sizeof(clockrate); |
36 |
+ |
37 |
+ sysctlbyname(mib, (void *)&clockrate, &size, NULL, 0); |
38 |
|
39 |
+ return clockrate; |
40 |
+ } |
21 |
+#endif |
41 |
+#endif |
22 |
+ |
42 |
|
|
|
43 |
+#ifdef __linux__ |
44 |
/** |
45 |
* Detects the number of parallel hardware threads supported by |
46 |
* the CPU by parsing the cpuinfo. |
47 |
@@ -232,6 +257,27 @@ pocl_cpuinfo_detect_compute_unit_count() |
48 |
} |
49 |
return -1; |
50 |
} |
51 |
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
23 |
+/** |
52 |
+/** |
24 |
+ * Detects the number of parallel hardware threads supported by |
53 |
+ * Detects the number of parallel hardware threads supported by |
25 |
+ * the CPU. |
54 |
+ * the CPU. |
Lines 31-86
Link Here
|
31 |
+{ |
60 |
+{ |
32 |
+ int mib[2], nocpus; |
61 |
+ int mib[2], nocpus; |
33 |
+ size_t len; |
62 |
+ size_t len; |
34 |
|
63 |
+ |
35 |
+ mib[0] = CTL_HW; |
64 |
+ mib[0] = CTL_HW; |
36 |
+ mib[1] = HW_NCPU; |
65 |
+ mib[1] = HW_NCPU; |
37 |
+ len = sizeof(nocpus); |
66 |
+ len = sizeof(nocpus); |
38 |
+ sysctl(mib, 2, &nocpus, &len, NULL, 0); |
67 |
+ sysctl(mib, 2, &nocpus, &len, NULL, 0); |
39 |
|
68 |
+ |
40 |
+ return nocpus; |
69 |
+ return nocpus; |
41 |
+} |
70 |
+} |
42 |
+ |
|
|
43 |
+#if 0 |
44 |
/** |
45 |
* Detects the number of parallel hardware threads supported by |
46 |
* the CPU by parsing the cpuinfo. |
47 |
@@ -231,6 +256,27 @@ pocl_cpuinfo_detect_compute_unit_count() |
48 |
} |
49 |
return -1; |
50 |
} |
51 |
+#endif |
71 |
+#endif |
52 |
+ |
|
|
53 |
+/** |
54 |
+ * Detects the maximum clock frequency of the CPU. |
55 |
+ * |
56 |
+ * Assumes all cores have the same max clock freq. |
57 |
+ * |
58 |
+ * @return The clock frequency in MHz. |
59 |
+ */ |
60 |
+int |
61 |
+pocl_cpuinfo_detect_max_clock_frequency() |
62 |
+{ |
63 |
+ //XXX PLEASE NOTE, THIS IS NOT TOO PORTABLE (AND/OR ACCURATE)! |
64 |
+ const char mib[] = "hw.clockrate"; |
65 |
+ size_t size = sizeof(int); |
66 |
+ int clockrate; |
67 |
+ |
68 |
+ sysctlbyname(mib, (void *)&clockrate, &size, NULL, 0); |
69 |
+ |
70 |
+ return clockrate; |
71 |
+ } |
72 |
|
72 |
|
73 |
#ifdef POCL_ANDROID |
73 |
#ifdef POCL_ANDROID |
74 |
|
74 |
|
75 |
@@ -269,6 +315,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_ |
75 |
@@ -270,6 +316,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_ |
76 |
* short_name is in the .data anyways.*/ |
76 |
* short_name is in the .data anyways.*/ |
77 |
device->long_name = device->short_name; |
77 |
device->long_name = device->short_name; |
78 |
|
78 |
|
79 |
+#if 0 |
79 |
+#ifdef __linux__ |
80 |
/* default vendor and vendor_id, in case it cannot be found by other means */ |
80 |
/* default vendor and vendor_id, in case it cannot be found by other means */ |
81 |
device->vendor = cpuvendor_default; |
81 |
device->vendor = cpuvendor_default; |
82 |
if (device->vendor_id == 0) |
82 |
if (device->vendor_id == 0) |
83 |
@@ -317,6 +364,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_ |
83 |
@@ -318,6 +365,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_ |
84 |
char *new_name = (char*)malloc (len); |
84 |
char *new_name = (char*)malloc (len); |
85 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
85 |
snprintf (new_name, len, "%s-%s", device->short_name, start); |
86 |
device->long_name = new_name; |
86 |
device->long_name = new_name; |