Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ rustflags = ["-C", "target-cpu=native"]

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-cpu=native"]

[target.wasm32-unknown-unknown]
rustflags = [
"-C", "target-feature=+atomics,+bulk-memory,+simd128,+relaxed-simd",
"-C", "link-arg=--shared-memory",
"-C", "link-arg=--max-memory=1073741824",
"-C", "link-arg=--import-memory",
"-C", "link-arg=--export=__wasm_init_tls",
"-C", "link-arg=--export=__tls_size",
"-C", "link-arg=--export=__tls_align",
"-C", "link-arg=--export=__tls_base",
]
2 changes: 1 addition & 1 deletion .github/workflows/check_bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
shell: bash
run: |
echo "RUSTFLAGS:" $RUSTFLAGS
cargo +nightly -Z target-applies-to-host rustc --release -- --emit link=reckless
cargo +nightly -Z target-applies-to-host rustc --release --bin reckless -- --emit link=reckless
measured_bench=$("$SDE_PATH/sde" ${{ matrix.sde_flag }} -- ./reckless bench | tail -1 | cut "--delimiter= " -f 2 -)
echo "measured_bench=$measured_bench" >> $GITHUB_ENV
echo "Measured Bench: $measured_bench"
Expand Down
127 changes: 125 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2024"
build = "build/build.rs"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["syzygy"]
syzygy = []
Expand All @@ -26,3 +29,8 @@ bindgen = "0.71.1"

[dependencies]
libc = "0.2.175"
web-time = "1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
js-sys = "0.3"
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ endif
rule:
cargo rustc --release -- -C target-cpu=native --emit link=$(NAME)

wasm:
unset RUSTFLAGS && rustup run nightly \
cargo build -Z build-std=panic_abort,std \
--lib --target wasm32-unknown-unknown --release --no-default-features
wasm-bindgen target/wasm32-unknown-unknown/release/reckless.wasm --target web --out-dir pkg
wasm-opt -O3 --enable-simd --enable-threads --enable-relaxed-simd \
pkg/reckless_bg.wasm -o pkg/reckless_bg.wasm


x64-check:
RUSTFLAGS="-C target-cpu=x86-64" cargo check --target x86_64-unknown-linux-gnu --no-default-features
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo check --target x86_64-unknown-linux-gnu --no-default-features
Expand Down
4 changes: 3 additions & 1 deletion build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ fn main() {
generate_engine_version();

#[cfg(feature = "syzygy")]
generate_syzygy_binding();
if std::env::var("CARGO_CFG_TARGET_ARCH").as_deref() != Ok("wasm32") {
generate_syzygy_binding();
}

if !Path::new("networks").join(NETWORK_NAME).exists() && env::var("EVALFILE").is_err() {
download_network();
Expand Down
45 changes: 45 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#![allow(unsafe_op_in_unsafe_fn)]
#![warn(clippy::large_types_passed_by_value)]
#![warn(clippy::trivially_copy_pass_by_ref)]
#![warn(clippy::redundant_clone)]
#![cfg_attr(target_arch = "wasm32", allow(dead_code, unused_imports))]

mod board;
mod evaluation;
mod history;
mod lookup;
mod misc;
mod movepick;
mod nnue;
mod numa;
mod parameters;
mod search;
mod setwise;
mod stack;
mod thread;
mod threadpool;
mod time;
mod transposition;
mod types;

mod tools;

#[cfg(not(target_arch = "wasm32"))]
mod uci;

#[cfg(feature = "syzygy")]
mod tb;

#[cfg(feature = "syzygy")]
#[allow(warnings)]
mod bindings;

#[cfg(target_arch = "wasm32")]
pub mod wasm;

#[cfg(not(target_arch = "wasm32"))]
pub fn run(buffer: std::collections::VecDeque<String>) {
lookup::initialize();
nnue::initialize();
uci::message_loop(buffer);
}
41 changes: 3 additions & 38 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
#![allow(unsafe_op_in_unsafe_fn)]
#![warn(clippy::large_types_passed_by_value)]
#![warn(clippy::trivially_copy_pass_by_ref)]
#![warn(clippy::redundant_clone)]

mod board;
mod evaluation;
mod history;
mod lookup;
mod misc;
mod movepick;
mod nnue;
mod numa;
mod parameters;
mod search;
mod setwise;
mod stack;
mod thread;
mod threadpool;
mod time;
mod tools;
mod transposition;
mod types;
mod uci;

#[cfg(feature = "syzygy")]
mod tb;

#[cfg(feature = "syzygy")]
#[allow(warnings)]
mod bindings;

#[cfg(not(target_arch = "wasm32"))]
fn main() {
lookup::initialize();
nnue::initialize();

let buffer: std::collections::VecDeque<String> = std::env::args().skip(1).collect();

uci::message_loop(buffer);
let buffer = std::env::args().skip(1).collect();
reckless::run(buffer);
}
Loading