-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgcloud.sh
More file actions
executable file
·60 lines (50 loc) · 1.34 KB
/
gcloud.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.34 KB
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
#!/bin/bash
# You probably want to have your keychain already set up before running this
# script, or you'll have to enter your SSH key password 4x.
set -e
INSTANCE_NAME=parallel-sort-bench
ZONE=us-west1-a
function build {
bazelisk build -c opt --cxxopt=-march=icelake-server --cxxopt=-DENABLE_INTEL_X86_SIMD_SORT "$@"
}
function start {
gcloud beta compute instances create ${INSTANCE_NAME} \
--zone ${ZONE} \
--provisioning-model=SPOT \
--instance-termination-action=DELETE \
--min-cpu-platform='Intel Ice Lake' \
--image=ubuntu-minimal-2210-kinetic-amd64-v20230214 \
--image-project=ubuntu-os-cloud \
--machine-type=n2-standard-8 \
--max-run-duration=10m
}
function delete {
gcloud compute instances delete ${INSTANCE_NAME} -q --zone ${ZONE}
}
function ssh {
gcloud compute ssh ${INSTANCE_NAME} --zone ${ZONE} -- "$@"
}
function run-bench {
build :bench
gcloud compute scp bazel-bin/bench ${INSTANCE_NAME}:/tmp --zone ${ZONE}
ssh bash -eufx <<EOF
/tmp/bench --benchmark_counters_tabular=true
rm -f /tmp/bench
EOF
}
function run-test {
build :test
gcloud compute scp bazel-bin/test ${INSTANCE_NAME}:/tmp --zone ${ZONE}
ssh bash -c "/tmp/test; rm -f /tmp/test"
}
if [[ $# -eq 0 ]]; then
build :bench :test ## Build first
start
run-test
run-bench
delete
else
for cmd in "$@"; do
"${cmd}"
done
fi