|
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
|
|
|
DEPRECATED: we don't use host.serialnum anymore |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
$cli_only = true; |
|
24
|
|
|
require_once("../inc/util_ops.inc"); |
|
25
|
|
|
|
|
26
|
|
|
ini_set ("memory_limit", "8000M"); |
|
27
|
|
|
set_time_limit(0); |
|
28
|
|
|
|
|
29
|
|
|
error_reporting(E_ALL); |
|
30
|
|
|
ini_set('display_errors', true); |
|
31
|
|
|
ini_set('display_startup_errors', true); |
|
32
|
|
|
|
|
33
|
|
|
function inc(&$ar, $ind) { |
|
34
|
|
|
if (array_key_exists($ind, $ar)) { |
|
35
|
|
|
$ar[$ind]++; |
|
36
|
|
|
} else { |
|
37
|
|
|
$ar[$ind] = 1; |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function parse_vers($x) { |
|
42
|
|
|
$y = strstr($x, 'BOINC'); |
|
43
|
|
|
if (!$y) return ''; |
|
44
|
|
|
$y = substr($y, 6); |
|
45
|
|
|
$z = explode("]", $y, 2); |
|
46
|
|
|
$y = explode(".", $z[0]); |
|
47
|
|
|
$v->major = $y[0]; |
|
48
|
|
|
$v->minor = $y[1]; |
|
49
|
|
|
return $v; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
function parse_cuda($x) { |
|
53
|
|
|
$y = strstr($x, 'CUDA'); |
|
54
|
|
|
if (!$y) return ''; |
|
55
|
|
|
$y = substr($y, 5); |
|
56
|
|
|
$z = explode("]", $y, 2); |
|
57
|
|
|
$y = explode("|", $z[0]); |
|
58
|
|
|
$g->model = $y[0]; |
|
59
|
|
|
$g->ngpus = $y[1]; |
|
60
|
|
|
$ram = (int)$y[2]; |
|
61
|
|
|
$ram += 63; |
|
62
|
|
|
$ram /= 64; |
|
63
|
|
|
$ram = (int)$ram; |
|
64
|
|
|
$ram *= 64; |
|
65
|
|
|
$g->ram = (int)($ram); |
|
66
|
|
|
$d = $y[3]; |
|
67
|
|
|
$d /= 100; |
|
68
|
|
|
$g->driver = (int)$d; |
|
69
|
|
|
return $g; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
function analyze_nvidia() { |
|
73
|
|
|
$hosts_total = 0; // number of hosts 6.2 or better |
|
74
|
|
|
$hosts_gpu = 0; // number with an nvidia gpu |
|
75
|
|
|
$rac_total =0; |
|
76
|
|
|
$rac_gpu = 0; |
|
77
|
|
|
$linux_total = 0; |
|
78
|
|
|
$linux_gpus = 0; |
|
79
|
|
|
$windows_total = 0; |
|
80
|
|
|
$windows_gpus = 0; |
|
81
|
|
|
$model = array(); // name -> count |
|
82
|
|
|
$ram = array(); // size -> count |
|
83
|
|
|
$driver = array(); // vers -> count |
|
84
|
|
|
$ngpus = array(); // ngpus -> count |
|
85
|
|
|
|
|
86
|
|
|
$hosts = BoincHost::enum("expavg_credit > 10 and serialnum<>''"); |
|
87
|
|
|
foreach($hosts as $host) { |
|
88
|
|
|
$boinc_vers = parse_vers($host->serialnum); |
|
89
|
|
|
if (!$boinc_vers) continue; |
|
90
|
|
|
if ($boinc_vers->major < 6) continue; |
|
91
|
|
|
$is_linux = false; |
|
92
|
|
|
if (strstr($host->os_name, "Linux")) { |
|
93
|
|
|
$linux_total++; |
|
94
|
|
|
$is_linux = true; |
|
95
|
|
|
} else if (strstr($host->os_name, "Windows")) { |
|
96
|
|
|
$windows_total++; |
|
97
|
|
|
} else { |
|
98
|
|
|
continue; |
|
99
|
|
|
} |
|
100
|
|
|
$hosts_total++; |
|
101
|
|
|
$rac_total += $host->expavg_credit; |
|
102
|
|
|
$gpu = parse_cuda($host->serialnum); |
|
103
|
|
|
if (!$gpu) { |
|
104
|
|
|
continue; |
|
105
|
|
|
} |
|
106
|
|
|
$hosts_gpu++; |
|
107
|
|
|
$rac_gpu += $host->expavg_credit; |
|
108
|
|
|
if ($is_linux) { |
|
109
|
|
|
$linux_gpus++; |
|
110
|
|
|
} else { |
|
111
|
|
|
$windows_gpus++; |
|
112
|
|
|
} |
|
113
|
|
|
inc($model, $gpu->model); |
|
114
|
|
|
inc($ram, $gpu->ram); |
|
115
|
|
|
inc($driver, $gpu->driver); |
|
116
|
|
|
inc($ngpus, $gpu->ngpus); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
$pct = 100*($hosts_gpu/$hosts_total); |
|
120
|
|
|
echo "ntotal: $hosts_total ngpus: $hosts_gpu ($pct %)\n"; |
|
121
|
|
|
$pct = 100*($windows_gpus/$windows_total); |
|
122
|
|
|
echo "Windows: total $windows_total gpus $windows_gpus ($pct %)\n"; |
|
123
|
|
|
$pct = 100*($linux_gpus/$linux_total); |
|
124
|
|
|
echo "Linux: total $linux_total gpus $linux_gpus ($pct %)\n"; |
|
125
|
|
|
|
|
126
|
|
|
$rac_non_gpu = $rac_total - $rac_gpu; |
|
127
|
|
|
$hosts_non_gpu = $hosts_total - $hosts_gpu; |
|
128
|
|
|
$a = $rac_gpu/$hosts_gpu; |
|
129
|
|
|
$b = $rac_non_gpu/$hosts_non_gpu; |
|
130
|
|
|
echo "Avg RAC: GPU: $a non-GPU: $b\n"; |
|
131
|
|
|
|
|
132
|
|
|
arsort($model); |
|
133
|
|
|
foreach($model as $m=>$c) { |
|
134
|
|
|
echo "$m $c\n"; |
|
135
|
|
|
} |
|
136
|
|
|
print_r($ram); |
|
137
|
|
|
print_r($driver); |
|
138
|
|
|
print_r($ngpus); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
function analyze_all() { |
|
142
|
|
|
$total = 0; |
|
143
|
|
|
$nnv = 0; |
|
144
|
|
|
$nati = 0; |
|
145
|
|
|
$nboth = 0; |
|
146
|
|
|
$hosts = BoincHost::enum("expavg_credit > 10 and serialnum<>''"); |
|
147
|
|
|
foreach($hosts as $host) { |
|
148
|
|
|
$boinc_vers = parse_vers($host->serialnum); |
|
149
|
|
|
if (!$boinc_vers) continue; |
|
150
|
|
|
if ($boinc_vers->major < 6) continue; |
|
151
|
|
|
if ($boinc_vers->major == 6 && $boinc_vers->minor < 10) continue; |
|
152
|
|
|
$total++; |
|
153
|
|
|
$has_nv = strstr($host->serialnum, 'CUDA'); |
|
154
|
|
|
$has_ati = strstr($host->serialnum, 'ATI'); |
|
155
|
|
|
if ($has_nv) $nnv++; |
|
156
|
|
|
if ($has_ati) $nati++; |
|
157
|
|
|
if ($has_nv && $has_ati) $nboth++; |
|
158
|
|
|
} |
|
159
|
|
|
echo "total: $total NVIDIA: $nnv ATI: $nati both: $nboth\n"; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
analyze_all(); |
|
163
|
|
|
|
|
164
|
|
|
?> |
|
165
|
|
|
|