Skip to content

Commit

Permalink
add back nekbone
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 92d93ff commit fd242e9
Show file tree
Hide file tree
Showing 2 changed files with 135 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 @@ -47,5 +47,12 @@
"family": "performance",
"image": "ghcr.io/converged-computing/metric-ovis-hpc:latest",
"url": "https://github.com/ovis-hpc/ovis"
},
{
"name": "app-nekbone",
"description": "A mini-app derived from the Nek5000 CFD code which is a high order, incompressible Navier-Stokes CFD solver based on the spectral element method. The conjugate gradiant solve is compute intense, contains small messages and frequent allreduces.",
"family": "solver",
"image": "ghcr.io/converged-computing/metric-nekbone:latest",
"url": "https://github.com/Nek5000/Nekbone"
}
]
128 changes: 128 additions & 0 deletions pkg/metrics/app/nekbone.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
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 Nekbone struct {
metrics.LauncherWorker

// Custom Options
command string
prefix string
}

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

func (m Nekbone) Url() string {
return "https://github.com/Nek5000/Nekbone"
}

// Set custom options / attributes for the metric
func (m *Nekbone) SetOptions(metric *api.Metric) {
m.ResourceSpec = &metric.Resources
m.AttributeSpec = &metric.Attributes

// Set user defined values or fall back to defaults
m.prefix = "/bin/bash"
m.command = "mpiexec --hostfile ./hostlist.txt -np 2 ./nekbone"
m.Workdir = "/root/nekbone-3.0/test/example2"

// 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
}
prefix, ok := metric.Options["prefix"]
if ok {
m.prefix = prefix.StrVal
}
}

// Exported options and list options
func (m Nekbone) Options() map[string]intstr.IntOrString {
return map[string]intstr.IntOrString{
"command": intstr.FromString(m.command),
"prefix": intstr.FromString(m.prefix),
"workdir": intstr.FromString(m.Workdir),
}
}

func (m Nekbone) 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-nekbone",
Summary: "A mini-app derived from the Nek5000 CFD code which is a high order, incompressible Navier-Stokes CFD solver based on the spectral element method. The conjugate gradiant solve is compute intense, contains small messages and frequent allreduces.",
Container: "ghcr.io/converged-computing/metric-nekbone:latest",
}
Nekbone := Nekbone{LauncherWorker: launcher}
metrics.Register(&Nekbone)
}

0 comments on commit fd242e9

Please sign in to comment.