-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdas.go
139 lines (115 loc) · 3.66 KB
/
bdas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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/v1alpha2"
"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"
)
const (
bdasIdentifier = "app-bdas"
bdasSummary = "The big data analytic suite contains the K-Means observation label, PCA, and SVM benchmarks."
bdasContainer = "ghcr.io/converged-computing/metric-bdas:latest"
)
type BDAS struct {
metrics.LauncherWorker
}
// I think this is a simulation?
func (m BDAS) Family() string {
return metrics.MachineLearningFamily
}
func (m BDAS) Url() string {
return "https://asc.llnl.gov/sites/asc/files/2020-09/BDAS_Summary_b4bcf27_0.pdf"
}
// Set custom options / attributes for the metric
func (m *BDAS) SetOptions(metric *api.Metric) {
// Metadatqa
m.Identifier = bdasIdentifier
m.Summary = bdasSummary
m.Container = bdasContainer
// Set user defined values or fall back to defaults
m.Prefix = "/bin/bash"
m.Command = "mpirun --allow-run-as-root -np 4 --hostfile ./hostlist.txt Rscript /opt/bdas/benchmarks/r/princomp.r 250 50"
m.Workdir = "/opt/bdas/benchmarks/r"
// Examples from guide
// mpirun -np num_ranks Rscript princomp.r num_local_rows num_global_cols
// mpirun -np 16 Rscript princomp.r 1000 250
m.SetDefaultOptions(metric)
}
// Exported options and list options
func (m BDAS) 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 BDAS) 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"
# We need ip addresses for openmpi
mv ./hostlist.txt ./hostnames.txt
for h in $(cat ./hostnames.txt); do
if [[ "${h}" != "" ]]; then
if [[ "${h}" == "$(hostname)" ]]; then
hostname -I | awk '{print $1}' >> hostlist.txt
else
host $h | cut -d ' ' -f 4 >> hostlist.txt
fi
fi
done
echo "Hostlist"
cat ./hostlist.txt
`
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() {
base := metrics.BaseMetric{
Identifier: bdasIdentifier,
Summary: bdasSummary,
Container: bdasContainer,
}
launcher := metrics.LauncherWorker{BaseMetric: base}
BDAS := BDAS{LauncherWorker: launcher}
metrics.Register(&BDAS)
}