-
Notifications
You must be signed in to change notification settings - Fork 6
/
gpu_types_usage.awk
171 lines (139 loc) · 4.81 KB
/
gpu_types_usage.awk
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/awk -f
@include "mycolors.awk"
BEGIN {
FS="[ :|=,]";
}
{
if ($1 == "G>") {
# for overcap jobs, assign lab arbitrarily
if ($14 == "overcap") {
lab=user_to_lab[$2]
}
else {
lab=$13
}
# $8 : # of nodes
# $15: gpu or N/A. if N/A grab the # of GPUs from tres-alloc
# $16: #GPU per nodes
# $17+: list of nodes
if ($15 == "N/A") {
num_gpus = $12;
node_name = $16;
if (node_name in node_to_type) {
node_type = node_to_type[node_name];
} else {
node_type="";
}
if (node_type!="") {
# GPU Counts
gpu_counts[lab][$2][node_type][$3]+=num_gpus;
gpu_counts[lab][$2][node_type][$3,$4]+=num_gpus;
lab_gpu_totals[lab][node_type][$3]+=num_gpus;
lab_gpu_totals[lab][node_type][$3,$4]+=num_gpus;
}
} else {
i = 17;
i_max = i + $8;
while (i < i_max) {
num_gpus = $16;
node_name = $i;
if (node_name in node_to_type) {
node_type = node_to_type[node_name];
} else {
node_type="";
}
if (node_type!="") {
# GPU Counts
gpu_counts[lab][$2][node_type][$3]+=num_gpus;
gpu_counts[lab][$2][node_type][$3,$4]+=num_gpus;
lab_gpu_totals[lab][node_type][$3]+=num_gpus;
lab_gpu_totals[lab][node_type][$3,$4]+=num_gpus;
}
i=i+1;
}
}
for (t in all_types) {
gpu_counts[lab][$2][t]["R"]+=0;
gpu_counts[lab][$2][t]["PD"]+=0;
gpu_counts[lab][$2][t]["CG"]+=0;
gpu_counts[lab][$2][t]["R","normal"]+=0;
gpu_counts[lab][$2][t]["PD","normal"]+=0;
gpu_counts[lab][$2][t]["CG","normal"]+=0;
gpu_counts[lab][$2][t]["R","overcap"]+=0;
gpu_counts[lab][$2][t]["PD","overcap"]+=0;
gpu_counts[lab][$2][t]["CG","overcap"]+=0;
lab_gpu_totals[lab][t]["R"]+=0;
lab_gpu_totals[lab][t]["PD"]+=0;
lab_gpu_totals[lab][t]["CG"]+=0;
lab_gpu_totals[lab][t]["R","normal"]+=0;
lab_gpu_totals[lab][t]["PD","normal"]+=0;
lab_gpu_totals[lab][t]["CG","normal"]+=0;
lab_gpu_totals[lab][t]["R","overcap"]+=0;
lab_gpu_totals[lab][t]["PD","overcap"]+=0;
lab_gpu_totals[lab][t]["CG","overcap"]+=0;
}
labs_to_gpus[lab]=0;
} else {
if (($1 != "AVAIL_FEATURES") && ($1 != "(null)")) {
all_types[$1] = 0;
node_to_type[$2] = $1;
}
}
}
END {
printf("| %14s |","--------------");
printf(" %86s |", " Breakdown of GPUs usage per GPU type. Includes both Overcap and Normal.")
printf("\n");
printf("| %14s |","Username");
for (type in all_types) {
printf(" %15s |", type);
}
printf("\n");
printf("| %14s |","--------------");
for (type in all_types) {
printf(" %3s | %3s | %3s |", "R", "PD", "CG");
}
printf("\n");
printf("| %14s |","--------------");
for (type in all_types) {
printf(" %3s + %3s + %3s |", "---", "---", "---");
}
printf("\n");
for (lab in labs_to_gpus) {
if (lab == "guest-lab") {
continue;
}
if (lab == "") {
continue;
}
printf("| %14s == %86s |\n", lab, "----------------------------------------------------------------------------------");
if (lab in gpu_counts) {
for (name in gpu_counts[lab]) {
printf("| %14s |",name);
for (type in gpu_counts[lab][name]) {
printf(" %s |",colour_int(gpu_counts[lab][name][type]["R"]));
printf(" %s |",colour_int(gpu_counts[lab][name][type]["PD"]));
printf(" %s |",colour_int(gpu_counts[lab][name][type]["CG"]));
}
printf("\n");
}
}
printf("| %14s |","--------------");
for (type in all_types) {
printf(" %3s + %3s + %3s |", "---", "---", "---");
}
printf("\n");
printf("| %14s :","totals");
for (type in all_types) {
printf(" %3d |",lab_gpu_totals[lab][type]["R"]);
printf(" %3d |",lab_gpu_totals[lab][type]["PD"]);
printf(" %3d |",lab_gpu_totals[lab][type]["CG"]);
}
printf("\n");
printf("| %14s |","--------------");
for (type in all_types) {
printf(" %3s + %3s + %3s |", "---", "---", "---");
}
printf("\n");
}
}