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 authlevel;
export let roles; 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(` const { query: initq } = init(`
job(id: "${dbid}") { job(id: "${dbid}") {
id, jobId, user, project, cluster, startTime, 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 // 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'] accNodeOnly = [...toFetch].some(function(m) {
const accNodeOnly = [...toFetch].some(function(m) {
if (accMetrics.includes(m)) { if (accMetrics.includes(m)) {
const mc = metrics(job.cluster, m) const mc = metrics(job.cluster, m)
return mc.scope !== 'accelerator' return mc.scope !== 'accelerator'
@ -397,6 +399,8 @@
bind:this={statsTable} bind:this={statsTable}
job={$initq.data.job} job={$initq.data.job}
jobMetrics={$jobMetrics.data.jobMetrics} jobMetrics={$jobMetrics.data.jobMetrics}
accMetrics={accMetrics}
accNodeOnly={accNodeOnly}
/> />
{/key} {/key}
{/if} {/if}

View File

@ -7,6 +7,8 @@
export let job export let job
export let jobMetrics export let jobMetrics
export let accMetrics
export let accNodeOnly
const allMetrics = [...new Set(jobMetrics.map(m => m.name))].sort(), const allMetrics = [...new Set(jobMetrics.map(m => m.name))].sort(),
scopesForMetric = (metric) => jobMetrics scopesForMetric = (metric) => jobMetrics
@ -19,9 +21,19 @@
isMetricSelectionOpen = false, isMetricSelectionOpen = false,
selectedMetrics = getContext('cc-config')[`job_view_nodestats_selectedMetrics:${job.cluster}`] selectedMetrics = getContext('cc-config')[`job_view_nodestats_selectedMetrics:${job.cluster}`]
|| getContext('cc-config')['job_view_nodestats_selectedMetrics'] || getContext('cc-config')['job_view_nodestats_selectedMetrics']
for (let metric of allMetrics) { 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] = { sorting[metric] = {
min: { dir: 'up', active: false }, min: { dir: 'up', active: false },
avg: { dir: 'up', active: false }, avg: { dir: 'up', active: false },

View File

@ -1,12 +1,49 @@
<script> <script>
import { Icon } from 'sveltestrap'
export let host export let host
export let metric export let metric
export let scope export let scope
export let jobMetrics 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 $: series = jobMetrics
.find(jm => jm.name == metric && jm.scope == scope) .find(jm => jm.name == metric && jm.scope == scope)
?.metric.series.filter(s => s.hostname == host && s.statistics != null) ?.metric.series.filter(s => s.hostname == host && s.statistics != null)
?.sort(compareNumbers)
</script> </script>
{#if series == null || series.length == 0} {#if series == null || series.length == 0}
@ -24,6 +61,14 @@
{:else} {:else}
<td colspan="4"> <td colspan="4">
<table style="width: 100%;"> <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} {#each series as s, i}
<tr> <tr>
<th>{s.id ?? i}</th> <th>{s.id ?? i}</th>