Merge pull request #191 from ClusterCockpit/138_show_core_accelerator_scope_statstable

138 show core accelerator scope statstable
This commit is contained in:
Jan Eitzinger 2023-08-11 10:27:52 +02:00 committed by GitHub
commit 8910a612ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 4 deletions

View File

@ -33,6 +33,9 @@
export let authlevel;
export let roles;
const accMetrics = ['acc_utilization', 'acc_mem_used', 'acc_power', 'nv_mem_util', 'nv_sm_clock', 'nv_temp'];
let accNodeOnly
const { query: initq } = init(`
job(id: "${dbid}") {
id, jobId, user, project, cluster, startTime,
@ -76,8 +79,7 @@
]);
// Select default Scopes to load: Check before if accelerator metrics are not on accelerator scope by default
const accMetrics = ['acc_utilization', 'acc_mem_used', 'acc_power', 'nv_mem_util', 'nv_sm_clock', 'nv_temp']
const accNodeOnly = [...toFetch].some(function(m) {
accNodeOnly = [...toFetch].some(function(m) {
if (accMetrics.includes(m)) {
const mc = metrics(job.cluster, m)
return mc.scope !== 'accelerator'
@ -397,6 +399,8 @@
bind:this={statsTable}
job={$initq.data.job}
jobMetrics={$jobMetrics.data.jobMetrics}
accMetrics={accMetrics}
accNodeOnly={accNodeOnly}
/>
{/key}
{/if}

View File

@ -7,6 +7,8 @@
export let job
export let jobMetrics
export let accMetrics
export let accNodeOnly
const allMetrics = [...new Set(jobMetrics.map(m => m.name))].sort(),
scopesForMetric = (metric) => jobMetrics
@ -21,7 +23,17 @@
|| getContext('cc-config')['job_view_nodestats_selectedMetrics']
for (let metric of allMetrics) {
selectedScopes[metric] = maxScope(scopesForMetric(metric))
// Not Exclusive or Single Node: Get maxScope()
// No Accelerators in Job and not Acc-Metric: Use 'core'
// Accelerator Metric available on accelerator scope: Use 'accelerator'
// Accelerator Metric only on node scope: Fallback to 'node'
selectedScopes[metric] = (job.exclusive != 1 || job.numNodes == 1) ?
(job.numAccs != 0 && accMetrics.includes(metric)) ?
accNodeOnly ?
'node'
: 'accelerator'
: 'core'
: maxScope(scopesForMetric(metric))
sorting[metric] = {
min: { dir: 'up', active: false },
avg: { dir: 'up', active: false },

View File

@ -1,12 +1,49 @@
<script>
import { Icon } from 'sveltestrap'
export let host
export let metric
export let scope
export let jobMetrics
function compareNumbers(a, b) {
return a.id - b.id;
}
function sortByField(field) {
let s = sorting[field]
if (s.active) {
s.dir = s.dir == 'up' ? 'down' : 'up'
} else {
for (let field in sorting)
sorting[field].active = false
s.active = true
}
sorting = {...sorting}
series = series.sort((a, b) => {
if (a == null || b == null)
return -1
if (field === 'id') {
return s.dir != 'up' ? a[field] - b[field] : b[field] - a[field]
} else {
return s.dir != 'up' ? a.statistics[field] - b.statistics[field] : b.statistics[field] - a.statistics[field]
}
})
}
let sorting = {
id: { dir: 'down', active: true },
min: { dir: 'up', active: false },
avg: { dir: 'up', active: false },
max: { dir: 'up', active: false },
}
$: series = jobMetrics
.find(jm => jm.name == metric && jm.scope == scope)
?.metric.series.filter(s => s.hostname == host && s.statistics != null)
?.sort(compareNumbers)
</script>
{#if series == null || series.length == 0}
@ -24,6 +61,14 @@
{:else}
<td colspan="4">
<table style="width: 100%;">
<tr>
{#each ['id', 'min', 'avg', 'max'] as field}
<th on:click={() => sortByField(field)}>
Sort
<Icon name="caret-{sorting[field].dir}{sorting[field].active ? '-fill' : ''}" />
</th>
{/each}
</tr>
{#each series as s, i}
<tr>
<th>{s.id ?? i}</th>