-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbolt.sh
More file actions
executable file
·191 lines (169 loc) · 5.21 KB
/
bolt.sh
File metadata and controls
executable file
·191 lines (169 loc) · 5.21 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
set -e
setup_rust(){
echo "[INFO] Installing build essential"
sudo apt-get update -y
sudo apt-get install -y build-essential
echo "[INFO] Checking Rust installation..."
if command -v rustc >/dev/null 2>&1; then
CURRENT_VERSION=$(rustc --version | awk '{print $2}')
echo "[INFO] Found Rust version $CURRENT_VERSION"
if [ "$CURRENT_VERSION" != "1.92.0" ]; then
echo "[INFO] Updating Rust to 1.92.0..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.92.0
else
echo "[OK] Rust is already 1.92.0"
fi
else
echo "[INFO] Rust not found. Installing Rust 1.92.0..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.92.0
fi
source "$HOME/.cargo/env"
export PATH="$HOME/.cargo/bin:$PATH"
rustc --version
cargo --version
echo "[INFO] Installing cargo-nextest if missing..."
if ! cargo nextest --version >/dev/null 2>&1; then
cargo install cargo-nextest
fi
cargo nextest --version
}
setup_cuda() {
sudo apt-get -y install clang-format
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-13-0
sudo apt-get -y install cuda-drivers
}
setup() {
setup_rust
setup_cuda
}
format() {
cargo +nightly fmt;
clang-format -i ./tachyon/gpu/src/ffi/kernels/*
}
check_rust() {
echo "[INFO] Running cargo check..."
cargo check
echo "[OK] Cargo check passed!"
echo "[INFO] Checking code formatting..."
cargo fmt -- --check
echo "[OK] Code is properly formatted!"
echo "[INFO] Running clippy lints..."
cargo clippy -- -D warnings
echo "[OK] Clippy checks passed!"
}
check_miri() {
echo "[INFO] Running cargo miri..."
rustup +nightly component add miri
export MIRIFLAGS="-Zmiri-disable-isolation"
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then
echo "[INFO] CUDA GPU detected — but miri not supported for FFI( unsupported operation: can't call foreign function `cudaMalloc` on OS `linux`)..."
// cargo +nightly miri nextest run --features gpu --no-fail-fast --test-threads=4
else
echo "[INFO] Running CPU tests with miri..."
cargo +nightly miri nextest run --no-default-features --no-fail-fast --test-threads=4
echo "[WARN] CUDA GPU not detected — skipping GPU tests."
echo "[INFO] (CUDA toolkit may be installed, but no working GPU/driver found)"
fi
echo "[OK] Miri checks passed!"
}
check_cpp() {
echo "[INFO] Checking CPP"
files=$(find . -type f \( -name "*.cpp" -o -name "*.cc" -o -name "*.cxx" -o -name "*.hpp" -o -name "*.h" -o -name "*.cu" -o -name "*.cuh" \))
if [ -z "$files" ]; then
echo "No C++ files to check."
exit 0
fi
echo "$files"
set +e
unformatted=$(clang-format --dry-run --Werror $files 2>&1)
status=$?
set -e
echo "$unformatted"
if [ $status -ne 0 ]; then
echo "[ERROR] Formatting errors found in the following files:"
echo "$unformatted"
echo ""
echo "Run the following to fix formatting:"
echo "clang-format -i $files"
exit 1
fi
echo "[OK] CPP check passed!"
}
check() {
check_rust
check_cpp
}
build() {
echo "[INFO] Building..."
cargo build --release
echo "[OK] Build completed!"
}
test() {
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then
echo "[INFO] CUDA GPU detected — running GPU tests..."
cargo nextest run --features gpu --test-threads=4 || return 1
else
echo "[INFO] Running CPU tests..."
cargo nextest run --no-default-features --test-threads=4 || return 1
echo "[WARN] CUDA GPU not detected — skipping GPU tests."
echo "[INFO] (CUDA toolkit may be installed, but no working GPU/driver found)"
fi
echo "[OK] Testing completed!"
}
coverage(){
cargo llvm-cov --workspace --summary-only
}
help() {
echo "Usage: $0 [setup|format|check|build|test|coverage|all|help]"
echo
echo "Commands:"
echo " setup - Install Rust and cargo-nextest"
echo " format - Format code"
echo " check - Run cargo check, fmt, and clippy"
echo " build - Only build the workspace (runs check first)"
echo " test - Only run tests"
echo " miri - Run miri checks"
echo " coverage - Run coverage"
echo " all - Run check, build, and test"
echo " help - Show this help message"
}
main() {
cmd="$1"
case "$cmd" in
setup)
setup
;;
format)
format
;;
check)
check
;;
build)
build
;;
test)
test
;;
miri)
check_miri
;;
coverage)
coverage
;;
all)
setup
check
build
deploy
;;
help|""|*)
help
;;
esac
}
main "$@"