Passed
Pull Request — master (#5960)
by David
20:50 queued 10:39
created

do_plan_class()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 22
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 7
eloc 21
c 1
b 0
f 1
nc 7
nop 2
dl 0
loc 22
rs 8.6506
1
<?php
2
// This file is part of BOINC.
3
// https://boinc.berkeley.edu
4
// Copyright (C) 2024 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
// code to get list of app types (CPU/GPU) supported by project
20
21
require_once("../inc/boinc_db.inc");
22
23
// return a structure indicating whether project can use
24
// various resource types, and a count of apps.
25
// Include both non-deprecated app versions and BUDA app variants.
26
//
27
function get_app_types() {
28
    $t = new StdClass;
29
    $t->cpu = false;
30
    $t->cuda = false;
31
    $t->ati = false;
32
    $t->intel_gpu = false;
33
    $t->apple_gpu = false;
34
    $t->count = 0;
35
36
    $avs = BoincAppVersion::enum("deprecated=0");
37
    foreach ($avs as $av) {
38
        do_plan_class($av->plan_class, $t);
39
    }
40
41
    $pcs = file('../../buda_plan_classes');
42
    foreach ($pcs as $pc) {
43
        do_plan_class($pc, $t);
44
    }
45
    return $t;
46
}
47
48
function do_plan_class($plan_class, &$t) {
49
    if (strstr($plan_class, "ati")) {
50
        $t->ati = true;
51
        $t->count++;
52
    } else if (strstr($plan_class, "amd")) {
53
        $t->ati = true;
54
        $t->count++;
55
    } else if (strstr($plan_class, "cuda")) {
56
        $t->cuda = true;
57
        $t->count++;
58
    } else if (strstr($plan_class, "nvidia")) {
59
        $t->cuda = true;
60
        $t->count++;
61
    } else if (strstr($plan_class, "intel_gpu")) {
62
        $t->intel_gpu = true;
63
        $t->count++;
64
    } else if (strstr($plan_class, "apple_gpu")) {
65
        $t->apple_gpu = true;
66
        $t->count++;
67
    } else {
68
        $t->cpu = true;
69
        $t->count++;
70
    }
71
}
72
73
?>
74