1 | <?php |
||
2 | // This file is part of BOINC. |
||
3 | // http://boinc.berkeley.edu |
||
4 | // Copyright (C) 2008 University of California |
||
5 | // |
||
6 | // BOINC is free software; you can redistribute it and/or modify it |
||
7 | // under the terms of the GNU Lesser General Public License |
||
8 | // as published by the Free Software Foundation, |
||
9 | // either version 3 of the License, or (at your option) any later version. |
||
10 | // |
||
11 | // BOINC is distributed in the hope that it will be useful, |
||
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
14 | // See the GNU Lesser General Public License for more details. |
||
15 | // |
||
16 | // You should have received a copy of the GNU Lesser General Public License |
||
17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
||
18 | |||
19 | // script for studying NVIDIA GPUs on hosts |
||
20 | |||
21 | $cli_only = true; |
||
22 | require_once("../inc/util_ops.inc"); |
||
23 | |||
24 | ini_set ("memory_limit", "8000M"); |
||
25 | set_time_limit(0); |
||
26 | |||
27 | error_reporting(E_ALL); |
||
28 | ini_set('display_errors', true); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
29 | ini_set('display_startup_errors', true); |
||
30 | |||
31 | function inc(&$ar, $ind) { |
||
32 | if (array_key_exists($ind, $ar)) { |
||
33 | $ar[$ind]++; |
||
34 | } else { |
||
35 | $ar[$ind] = 1; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | function parse_vers($x) { |
||
40 | $y = strstr($x, 'BOINC'); |
||
41 | if (!$y) return ''; |
||
42 | $y = substr($y, 6); |
||
43 | $z = explode("]", $y, 2); |
||
44 | $y = explode(".", $z[0]); |
||
45 | $v->major = $y[0]; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
46 | $v->minor = $y[1]; |
||
47 | return $v; |
||
48 | } |
||
49 | |||
50 | function parse_cuda($x) { |
||
51 | $y = strstr($x, 'CUDA'); |
||
52 | if (!$y) return ''; |
||
53 | $y = substr($y, 5); |
||
54 | $z = explode("]", $y, 2); |
||
55 | $y = explode("|", $z[0]); |
||
56 | $g->model = $y[0]; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
57 | $g->ngpus = $y[1]; |
||
58 | $ram = (int)$y[2]; |
||
59 | $ram += 63; |
||
60 | $ram /= 64; |
||
61 | $ram = (int)$ram; |
||
62 | $ram *= 64; |
||
63 | $g->ram = (int)($ram); |
||
64 | $d = $y[3]; |
||
65 | $d /= 100; |
||
66 | $g->driver = (int)$d; |
||
67 | return $g; |
||
68 | } |
||
69 | |||
70 | function analyze_nvidia() { |
||
71 | $hosts_total = 0; // number of hosts 6.2 or better |
||
72 | $hosts_gpu = 0; // number with an nvidia gpu |
||
73 | $rac_total =0; |
||
74 | $rac_gpu = 0; |
||
75 | $linux_total = 0; |
||
76 | $linux_gpus = 0; |
||
77 | $windows_total = 0; |
||
78 | $windows_gpus = 0; |
||
79 | $model = array(); // name -> count |
||
80 | $ram = array(); // size -> count |
||
81 | $driver = array(); // vers -> count |
||
82 | $ngpus = array(); // ngpus -> count |
||
83 | |||
84 | $hosts = BoincHost::enum("expavg_credit > 10 and serialnum<>''"); |
||
85 | foreach($hosts as $host) { |
||
86 | $boinc_vers = parse_vers($host->serialnum); |
||
87 | if (!$boinc_vers) continue; |
||
88 | if ($boinc_vers->major < 6) continue; |
||
0 ignored issues
–
show
|
|||
89 | $is_linux = false; |
||
90 | if (strstr($host->os_name, "Linux")) { |
||
91 | $linux_total++; |
||
92 | $is_linux = true; |
||
93 | } else if (strstr($host->os_name, "Windows")) { |
||
94 | $windows_total++; |
||
95 | } else { |
||
96 | continue; |
||
97 | } |
||
98 | $hosts_total++; |
||
99 | $rac_total += $host->expavg_credit; |
||
100 | $gpu = parse_cuda($host->serialnum); |
||
101 | if (!$gpu) { |
||
102 | continue; |
||
103 | } |
||
104 | $hosts_gpu++; |
||
105 | $rac_gpu += $host->expavg_credit; |
||
106 | if ($is_linux) { |
||
107 | $linux_gpus++; |
||
108 | } else { |
||
109 | $windows_gpus++; |
||
110 | } |
||
111 | inc($model, $gpu->model); |
||
0 ignored issues
–
show
|
|||
112 | inc($ram, $gpu->ram); |
||
0 ignored issues
–
show
|
|||
113 | inc($driver, $gpu->driver); |
||
0 ignored issues
–
show
|
|||
114 | inc($ngpus, $gpu->ngpus); |
||
0 ignored issues
–
show
|
|||
115 | } |
||
116 | |||
117 | $pct = 100*($hosts_gpu/$hosts_total); |
||
118 | echo "ntotal: $hosts_total ngpus: $hosts_gpu ($pct %)\n"; |
||
119 | $pct = 100*($windows_gpus/$windows_total); |
||
120 | echo "Windows: total $windows_total gpus $windows_gpus ($pct %)\n"; |
||
121 | $pct = 100*($linux_gpus/$linux_total); |
||
122 | echo "Linux: total $linux_total gpus $linux_gpus ($pct %)\n"; |
||
123 | |||
124 | $rac_non_gpu = $rac_total - $rac_gpu; |
||
125 | $hosts_non_gpu = $hosts_total - $hosts_gpu; |
||
126 | $a = $rac_gpu/$hosts_gpu; |
||
127 | $b = $rac_non_gpu/$hosts_non_gpu; |
||
128 | echo "Avg RAC: GPU: $a non-GPU: $b\n"; |
||
129 | |||
130 | arsort($model); |
||
131 | foreach($model as $m=>$c) { |
||
0 ignored issues
–
show
|
|||
132 | echo "$m $c\n"; |
||
133 | } |
||
134 | print_r($ram); |
||
135 | print_r($driver); |
||
136 | print_r($ngpus); |
||
137 | } |
||
138 | |||
139 | function analyze_all() { |
||
140 | $total = 0; |
||
141 | $nnv = 0; |
||
142 | $nati = 0; |
||
143 | $nboth = 0; |
||
144 | $hosts = BoincHost::enum("expavg_credit > 10 and serialnum<>''"); |
||
145 | foreach($hosts as $host) { |
||
146 | $boinc_vers = parse_vers($host->serialnum); |
||
147 | if (!$boinc_vers) continue; |
||
148 | if ($boinc_vers->major < 6) continue; |
||
0 ignored issues
–
show
|
|||
149 | if ($boinc_vers->major == 6 && $boinc_vers->minor < 10) continue; |
||
0 ignored issues
–
show
|
|||
150 | $total++; |
||
151 | $has_nv = strstr($host->serialnum, 'CUDA'); |
||
152 | $has_ati = strstr($host->serialnum, 'ATI'); |
||
153 | if ($has_nv) $nnv++; |
||
154 | if ($has_ati) $nati++; |
||
155 | if ($has_nv && $has_ati) $nboth++; |
||
156 | } |
||
157 | echo "total: $total NVIDIA: $nnv ATI: $nati both: $nboth\n"; |
||
158 | } |
||
159 | |||
160 | analyze_all(); |
||
161 | |||
162 | ?> |
||
163 |