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
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ edition = "2021"
default-run = "dash-evo-tool"
rust-version = "1.81"

[build]
rustflags = [
"-C", "target-feature=+avx,-avx2,-avx512f,-avx512cd,-avx512er,-avx512pf,-avx512bw,-avx512dq,-avx512vl"
]

[dependencies]
bip39 = { version = "2.1.0", features = ["all-languages", "rand"] }
derive_more = "1.0.0"
Expand Down Expand Up @@ -59,4 +64,8 @@ regex = "1.11"
zmq = "0.10"

[target.'cfg(target_os = "windows")'.dependencies]
zeromq = "0.4.1"
zeromq = "0.4.1"

[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
native-dialog = "0.7.0"
raw-cpuid = "11.2.0"
55 changes: 55 additions & 0 deletions src/cpu_compatibility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use native_dialog::MessageDialog;

pub fn check_cpu_compatibility() {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
use raw_cpuid::CpuId;

let cpuid = CpuId::new();

if let Some(feature_info) = cpuid.get_feature_info() {
if !feature_info.has_avx() {
MessageDialog::new()
.set_type(native_dialog::MessageType::Error)
.set_title("Compatibility Error")
.set_text("Your CPU does not support AVX instructions. Please use a compatible CPU.")
.show_alert()
.unwrap();
std::process::exit(1);
}
let avx2_supported = cpuid
.get_extended_feature_info()
.map_or(false, |ext_info| ext_info.has_avx2());
if !avx2_supported {
MessageDialog::new()
.set_type(native_dialog::MessageType::Error)
.set_title("Compatibility Error")
.set_text("Your CPU does not support AVX2 instructions. Please use a compatible CPU.")
.show_alert()
.unwrap();
std::process::exit(1);
}
let avx512_supported = cpuid
.get_extended_feature_info()
.map_or(false, |ext_info| ext_info.has_avx512f()); // AVX-512 Foundation
if !avx512_supported {
MessageDialog::new()
.set_type(native_dialog::MessageType::Error)
.set_title("Compatibility Error")
.set_text("Your CPU does not support AVX512 instructions. Please use a compatible CPU.")
.show_alert()
.unwrap();
std::process::exit(1);
}
} else {
MessageDialog::new()
.set_type(native_dialog::MessageType::Error)
.set_title("Compatibility Error")
.set_text("Unable to determine CPU features.")
.show_alert()
.unwrap();
std::process::exit(1);
}
}
}
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use crate::cpu_compatibility::check_cpu_compatibility;

mod app;
mod app_dir;
mod backend_task;
mod components;
mod config;
mod context;
mod context_provider;
mod cpu_compatibility;
mod database;
mod logging;
mod model;
mod sdk_wrapper;
mod ui;

fn main() -> eframe::Result<()> {
check_cpu_compatibility();
// Initialize the Tokio runtime
let runtime = tokio::runtime::Builder::new_multi_thread()
.worker_threads(40)
Expand Down