forked from davidpanderson/science_united
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_digest.php
111 lines (102 loc) · 3.16 KB
/
project_digest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2018 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// read projects.xml and, for each project in our DB, make
// - a list of (keyword_id, frac)
// - a list of (platform, GPU type, is_vbox)
// and write these, serialized, to projects.ser
// DO THIS WHENEVER THE BOINC PROJECT LIST CHANGES
//
// Should also do it whenever a project releases an app for
// a new GPU type or vbox; i.e. should do it periodically
//
// Run this in projects/scienceunited/html/ops
// Also run project_init.php
// first:
// wget https://boinc.berkeley.edu/project_list.php
// and put it in projects.xml
require_once("../inc/su_db.inc");
function get_avs($p) {
$avs = array();
foreach ($p->platforms->name as $x) {
$y = explode("[", (string)$x);
$z = new StdClass;
$z->platform = $y[0];
$z->gpu = "";
$z->vbox = false;
if (count($y) > 1) {
if (strstr($y[1], "cuda")) {
$z->gpu = "nvidia";
}
if (strstr($y[1], "nvidia")) {
$z->gpu = "nvidia";
}
if (strstr($y[1], "amd")) {
$z->gpu = "amd";
}
if (strstr($y[1], "ati")) {
$z->gpu = "amd";
}
if (strstr($y[1], "intel_gpu")) {
$z->gpu = "intel_gpu";
}
if (strstr($y[1], "vbox")) {
$z->vbox = true;
}
}
$avs[] = $z;
}
return array_unique($avs, SORT_REGULAR);
}
function get_kws($p) {
$kws = array();
$x = trim((string)$p->keywords);
$y = explode(" ", $x);
foreach ($y as $z) {
$a = new StdClass;
$w = explode(":", $z);
if (count($w) > 1) {
$a->keyword_id = $w[0];
$a->fraction = $w[1];
} else {
$a->keyword_id = $w[0];
$a->fraction = 1;
}
$kws[] = $a;
}
return $kws;
}
function main() {
$x = simplexml_load_file("projects.xml");
$y = array();
foreach ($x->project as $p) {
$x = new StdClass;
$x->id = (int)$p->id;
$x->url = (string)$p->url;
$sup = SUProject::lookup_id($x->id);
if (!$sup) continue;
$x->name = (string)$p->name;
$x->description = (string)$p->description;
$x->avs = get_avs($p);
$x->kws = get_kws($p);
$y[$x->id] = $x;
echo "processed $x->id: $x->name\n";
}
file_put_contents("../user/projects.ser", serialize($y));
}
main();
?>