From 412217a055500d8458b55aed3ce5ad62a406dc83 Mon Sep 17 00:00:00 2001 From: vsoch Date: Tue, 19 Sep 2023 23:40:13 -0600 Subject: [PATCH] add back kripke Signed-off-by: vsoch --- .github/workflows/main.yaml | 2 +- docs/_static/data/metrics.json | 8 ++ pkg/metrics/app/kripke.go | 139 +++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 pkg/metrics/app/kripke.go diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4aa3f63..7924163 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -75,7 +75,7 @@ jobs: #["app-nekbone", "ghcr.io/converged-computing/metric-nekbone:latest", 120], # ["app-ldms", "ghcr.io/converged-computing/metric-ovis-hpc:latest", 120], ["app-amg", "ghcr.io/converged-computing/metric-amg:latest", 120], - #["app-kripke", "ghcr.io/converged-computing/metric-kripke:latest", 120], + ["app-kripke", "ghcr.io/converged-computing/metric-kripke:latest", 120], #["app-pennant", "ghcr.io/converged-computing/metric-pennant:latest", 120], ["app-bdas", "ghcr.io/converged-computing/metric-bdas:latest", 120]] #["app-quicksilver", "ghcr.io/converged-computing/metric-quicksilver:latest", 120], diff --git a/docs/_static/data/metrics.json b/docs/_static/data/metrics.json index 330f37b..0716676 100644 --- a/docs/_static/data/metrics.json +++ b/docs/_static/data/metrics.json @@ -23,6 +23,14 @@ "image": "ghcr.io/converged-computing/metric-hpl-spack:latest", "url": "https://www.netlib.org/benchmark/hpl/" }, + { + "name": "app-kripke", + "description": "parallel algebraic multigrid solver for linear systems arising from problems on unstructured grids", + "family": "solver", + "type": "", + "image": "ghcr.io/converged-computing/metric-kripke:latest", + "url": "https://github.com/LLNL/Kripke" + }, { "name": "app-lammps", "description": "LAMMPS molecular dynamic simulation", diff --git a/pkg/metrics/app/kripke.go b/pkg/metrics/app/kripke.go new file mode 100644 index 0000000..273be2b --- /dev/null +++ b/pkg/metrics/app/kripke.go @@ -0,0 +1,139 @@ +/* +Copyright 2023 Lawrence Livermore National Security, LLC + (c.f. AUTHORS, NOTICE.LLNS, COPYING) + +SPDX-License-Identifier: MIT +*/ + +package application + +import ( + "fmt" + + api "github.com/converged-computing/metrics-operator/api/v1alpha1" + "k8s.io/apimachinery/pkg/util/intstr" + + "github.com/converged-computing/metrics-operator/pkg/metadata" + metrics "github.com/converged-computing/metrics-operator/pkg/metrics" + "github.com/converged-computing/metrics-operator/pkg/specs" +) + +type Kripke struct { + metrics.LauncherWorker + + // Options + command string + prefix string +} + +func (m Kripke) Url() string { + return "https://github.com/LLNL/Kripke" +} + +// I think this is a simulation? +func (m Kripke) Family() string { + return metrics.SolverFamily +} + +// Set custom options / attributes for the metric +func (m *Kripke) SetOptions(metric *api.Metric) { + m.ResourceSpec = &metric.Resources + m.AttributeSpec = &metric.Attributes + + // Set user defined values or fall back to defaults + m.prefix = "mpirun --hostfile ./hostlist.txt" + m.command = "kripke" + m.Workdir = "/opt/kripke" + + // This could be improved :) + command, ok := metric.Options["command"] + if ok { + m.command = command.StrVal + } + workdir, ok := metric.Options["workdir"] + if ok { + m.Workdir = workdir.StrVal + } + mpirun, ok := metric.Options["mpirun"] + if ok { + m.prefix = mpirun.StrVal + } +} + +// Validate that we can run Kripke +func (n Kripke) Validate(spec *api.MetricSet) bool { + return spec.Spec.Pods >= 2 +} + +// Exported options and list options +func (m Kripke) Options() map[string]intstr.IntOrString { + return map[string]intstr.IntOrString{ + "command": intstr.FromString(m.command), + "mpirun": intstr.FromString(m.prefix), + "workdir": intstr.FromString(m.Workdir), + } +} +func (n Kripke) ListOptions() map[string][]intstr.IntOrString { + return map[string][]intstr.IntOrString{} +} + +func (m Kripke) PrepareContainers( + spec *api.MetricSet, + metric *metrics.Metric, +) []*specs.ContainerSpec { + + // Metadata to add to beginning of run + meta := metrics.Metadata(spec, metric) + hosts := m.GetHostlist(spec) + prefix := m.GetCommonPrefix(meta, m.command, hosts) + + preBlock := ` +echo "%s" +` + + postBlock := ` +echo "%s" +%s +` + command := fmt.Sprintf("%s ./problem.sh", m.prefix) + interactive := metadata.Interactive(spec.Spec.Logging.Interactive) + preBlock = prefix + fmt.Sprintf(preBlock, metadata.Separator) + postBlock = fmt.Sprintf(postBlock, metadata.CollectionEnd, interactive) + + // Entrypoint for the launcher + launcherEntrypoint := specs.EntrypointScript{ + Name: specs.DeriveScriptKey(m.LauncherScript), + Path: m.LauncherScript, + Pre: preBlock, + Command: command, + Post: postBlock, + } + + // Entrypoint for the worker + workerEntrypoint := specs.EntrypointScript{ + Name: specs.DeriveScriptKey(m.WorkerScript), + Path: m.WorkerScript, + Pre: prefix, + Command: "sleep infinity", + } + + // Container spec for the launcher + launcherContainer := m.GetLauncherContainerSpec(launcherEntrypoint) + workerContainer := m.GetWorkerContainerSpec(workerEntrypoint) + + // Return the script templates for each of launcher and worker + return []*specs.ContainerSpec{&launcherContainer, &workerContainer} + +} + +func init() { + launcher := metrics.LauncherWorker{ + Identifier: "app-kripke", + Summary: "parallel algebraic multigrid solver for linear systems arising from problems on unstructured grids", + Container: "ghcr.io/converged-computing/metric-kripke:latest", + WorkerScript: "/metrics_operator/kripke-worker.sh", + LauncherScript: "/metrics_operator/kripke-launcher.sh", + } + kripke := Kripke{LauncherWorker: launcher} + metrics.Register(&kripke) +}