Skip to content

Commit c54ba21

Browse files
committed
zen4
1 parent 45fc188 commit c54ba21

File tree

1 file changed

+102
-18
lines changed

1 file changed

+102
-18
lines changed

src/js/main.js

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ const timeFormat = d3.timeFormat('%Y-%m-%dT%H:%M:%S-05:00');
99
let Layout = {
1010
data: {},
1111
}
12-
12+
const NODE_RANGES = [
13+
'10.101.91.[1-20]',
14+
'10.101.92.[1-20]',
15+
'10.101.94.[1-20]',
16+
'10.101.95.[1-10]',
17+
'10.101.96.[1-20]',
18+
'10.101.97.[1-20]',
19+
];
1320
let serviceSelected = 0;
1421

1522
// let request = new Simulation('../HiperView/data/742020.json');
@@ -157,7 +164,8 @@ if (mode === 'realTime') {
157164
d3.select('#processBtn').style('display', 'none');
158165

159166
// Bind action to process button
160-
d3.select('#processBtn').on('click', loadHistoricalData);
167+
// d3.select('#processBtn').on('click', loadHistoricalData);
168+
d3.select('#processBtn').on('click', loadHistoricalAcrossRanges);
161169

162170
// Handle time range changes
163171
d3.select('#realTimeRange')
@@ -227,6 +235,58 @@ function buildRealTimeParams(rangeValue, intervalValue) {
227235
compression: false
228236
};
229237
}
238+
function combineResults(resultsArray) {
239+
const combined = {
240+
time_stamp: [],
241+
nodes_info: {},
242+
jobs_info: {}
243+
};
244+
console.log('Combining results:', resultsArray.length, 'results');
245+
console.log(resultsArray);
246+
247+
for (const result of resultsArray) {
248+
// Merge time stamps
249+
combined.time_stamp.push(...(result.time_stamp ?? []));
250+
251+
// Merge nodes_info
252+
for (const [node, info] of Object.entries(result.nodes_info)) {
253+
if (!combined.nodes_info[node]) {
254+
combined.nodes_info[node] = info;
255+
}
256+
}
257+
258+
// Merge jobs_info
259+
for (const [jid, job] of Object.entries(result.jobs_info)) {
260+
if (!combined.jobs_info[jid]) {
261+
combined.jobs_info[jid] = job;
262+
}
263+
}
264+
}
265+
266+
// Remove duplicate time_stamps and sort
267+
combined.time_stamp = Array.from(new Set(combined.time_stamp)).sort((a, b) => a - b);
268+
269+
return combined;
270+
}
271+
272+
async function fetchAllNodeRanges(startStr, endStr, isRealTime = false) {
273+
const allResults = [];
274+
275+
for (const range of NODE_RANGES) {
276+
// const nodes = expandBrackets(range);
277+
const params = {
278+
...(isRealTime
279+
? buildRealTimeParams(Date.now() - 1 * 60 * 60 * 1000, Date.now()) // if needed
280+
: buildHistoricalParams(startStr, endStr)),
281+
nodelist: range,
282+
};
283+
284+
const result = await fetchDataAndProcess(params, true);
285+
allResults.push(result);
286+
}
287+
288+
return combineResults(allResults);
289+
}
230290

231291
function buildHistoricalParams(startStr, endStr) {
232292
const parse = d3.timeParse('%Y-%m-%dT%H:%M');
@@ -244,19 +304,24 @@ function buildHistoricalParams(startStr, endStr) {
244304
end: format(end),
245305
interval: interval,
246306
aggregation: "max",
247-
nodelist: "10.101.93.[1-8]",
307+
nodelist: "10.101.91.[1-20]",
248308
metrics: [
249-
"GPU_Usage", "GPU_PowerConsumption", "GPU_MemoryUsage", "GPU_Temperature",
250-
"CPU_Usage", "CPU_PowerConsumption", "CPU_Temperature",
251-
"DRAM_Usage", "DRAM_PowerConsumption",
252-
"System_PowerConsumption", "Jobs_Info", "NodeJobs_Correlation", "Nodes_State"
309+
"CPU_Usage",
310+
"CPU_PowerConsumption",
311+
"CPU_Temperature",
312+
"DRAM_Usage",
313+
"DRAM_PowerConsumption",
314+
"System_PowerConsumption",
315+
"Jobs_Info",
316+
"NodeJobs_Correlation",
317+
"Nodes_State"
253318
],
254319
compression: false
255320
};
256321
}
257322

258323
function fetchDataAndProcess_old(Params) {
259-
return fetch('http://narumuu.ttu.edu/api/h100/', {
324+
return fetch('http://narumuu.ttu.edu/api/zen4/', {
260325
method: 'POST',
261326
headers: { 'Content-Type': 'application/json' },
262327
body: JSON.stringify(Params)
@@ -418,7 +483,7 @@ async function fetchDataAndProcess(Params, isRealTime = true) {
418483

419484
if (isRealTime) {
420485
// Real-time: Fetch from API
421-
apiData = await fetch('http://narumuu.ttu.edu/api/h100/', {
486+
apiData = await fetch('http://narumuu.ttu.edu/api/zen4/', {
422487
method: 'POST',
423488
headers: { 'Content-Type': 'application/json' },
424489
body: JSON.stringify(Params)
@@ -445,10 +510,11 @@ async function fetchDataAndProcess(Params, isRealTime = true) {
445510
cpus: Array(len).fill().map(() => []),
446511
job_id: Array(len).fill().map(() => []),
447512
system_power: Array(len).fill().map(() => []),
448-
gpu_power: Array(len).fill().map(() => []),
513+
// gpu_power: Array(len).fill().map(() => []),
449514
cpu_power: Array(len).fill().map(() => []),
450-
gpu_mem: Array(len).fill().map(() => []),
451-
gpu_usage: Array(len).fill().map(() => []),
515+
// gpu_mem: Array(len).fill().map(() => []),
516+
// gpu_usage: Array(len).fill().map(() => []),
517+
temperature: Array(len).fill().map(() => []),
452518
cpu_usage: Array(len).fill().map(() => []),
453519
dram_usage: Array(len).fill().map(() => []),
454520
dram_power: Array(len).fill().map(() => []),
@@ -460,10 +526,11 @@ async function fetchDataAndProcess(Params, isRealTime = true) {
460526
nodes_info[node].cpus[idx] = entry.cores ?? [];
461527
nodes_info[node].job_id[idx] = entry.jobs ?? [];
462528
nodes_info[node].system_power[idx] = entry.system_power_consumption ?? [];
463-
nodes_info[node].gpu_power[idx] = (entry.gpu_power_consumption ?? []).map(v => v / 1000);
529+
// nodes_info[node].gpu_power[idx] = (entry.gpu_power_consumption ?? []).map(v => v / 1000);
464530
nodes_info[node].cpu_power[idx] = entry.cpu_power_consumption ?? [];
465-
nodes_info[node].gpu_mem[idx] = entry.gpu_memory_usage ?? [];
466-
nodes_info[node].gpu_usage[idx] = entry.gpu_usage ?? [];
531+
// nodes_info[node].gpu_mem[idx] = entry.gpu_memory_usage ?? [];
532+
// nodes_info[node].gpu_usage[idx] = entry.gpu_usage ?? [];
533+
nodes_info[node].temperature[idx] = entry.temperature ?? [];
467534
nodes_info[node].cpu_usage[idx] = entry.cpu_usage ?? [];
468535
nodes_info[node].dram_usage[idx] = entry.dram_usage ?? [];
469536
nodes_info[node].dram_power[idx] = (entry.dram_power_consumption ?? []).map(v => v / 1000);
@@ -593,6 +660,20 @@ function startRealTimePolling(isRealTime = true) {
593660
initTimeElement();
594661
realTimeIntervalId = setInterval(fetchAndUpdate, intervalMs);
595662
}
663+
664+
async function loadHistoricalAcrossRanges() {
665+
const start = document.getElementById('startTime')?.value;
666+
const end = document.getElementById('endTime')?.value;
667+
if (!start || !end) {
668+
console.warn('Start or End time is missing.');
669+
return;
670+
}
671+
672+
const data = await fetchAllNodeRanges(start, end);
673+
request = new Simulation(Promise.resolve(data)); // you might need to adapt Simulation constructor
674+
initdraw();
675+
initTimeElement();
676+
}
596677
function loadHistoricalData() {
597678
if (realTimeIntervalId) clearInterval(realTimeIntervalId);
598679

@@ -662,9 +743,12 @@ $(document).ready(function () {
662743
serviceSelected = +command.service;
663744
if (command.metric !== undefined && _.isNumber(+command.metric))
664745
serviceSelected = +command.metric;
746+
// serviceListattr = [
747+
// "system_power", "gpu_power", "cpu_power", "dram_power",
748+
// "gpu_mem", "gpu_usage", "cpu_usage", "dram_usage",
749+
// ];
665750
serviceListattr = [
666-
"system_power", "gpu_power", "cpu_power", "dram_power",
667-
"gpu_mem", "gpu_usage", "cpu_usage", "dram_usage",
751+
"system_power","cpu_power", "dram_power", "temperature", "cpu_usage", "dram_usage",
668752
];
669753

670754
serviceLists = serviceListattr.map((key, index) => ({
@@ -677,7 +761,7 @@ $(document).ready(function () {
677761
enable: true,
678762
idroot: index,
679763
angle: 0,
680-
range: [0, 3000]
764+
range: index == 3 ? [0, 100] : [0, 3000],
681765
}]
682766
}));
683767
serviceFullList = [];

0 commit comments

Comments
 (0)