Skip to content

Commit

Permalink
add back pennant
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Sep 20, 2023
1 parent fd242e9 commit 46ca402
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/_static/data/metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,12 @@
"family": "solver",
"image": "ghcr.io/converged-computing/metric-nekbone:latest",
"url": "https://github.com/Nek5000/Nekbone"
},
{
"name": "app-pennant",
"description": "Unstructured mesh hydrodynamics for advanced architectures ",
"family": "simulation",
"image": "ghcr.io/converged-computing/metric-pennant:latest",
"url": "https://github.com/LLNL/pennant"
}
]
133 changes: 133 additions & 0 deletions pkg/metrics/app/pennant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
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 Pennant struct {
metrics.LauncherWorker

// Custom Options
command string
prefix string
}

// I think this is a simulation?
func (m Pennant) Family() string {
return metrics.SimulationFamily
}

func (m Pennant) Url() string {
return "https://github.com/LLNL/pennant"
}

// Set custom options / attributes for the metric
func (m *Pennant) 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 = "pennant /opt/pennant/test/sedovsmall/sedovsmall.pnt"
m.Workdir = "/opt/pennant/test"

// 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
}
}

// Exported options and list options
func (m Pennant) 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 Pennant) ListOptions() map[string][]intstr.IntOrString {
return map[string][]intstr.IntOrString{}
}

func (m Pennant) 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-pennant",
Summary: "Unstructured mesh hydrodynamics for advanced architectures ",
Container: "ghcr.io/converged-computing/metric-pennant:latest",
WorkerScript: "/metrics_operator/pennant-worker.sh",
LauncherScript: "/metrics_operator/pennant-launcher.sh",
}
Pennant := Pennant{LauncherWorker: launcher}
metrics.Register(&Pennant)
}

0 comments on commit 46ca402

Please sign in to comment.