-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6264496
commit 7a4fd91
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#[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() { | ||
let avx_supported = feature_info.has_avx(); | ||
let avx2_supported = cpuid | ||
.get_extended_feature_info() | ||
.map_or(false, |ext_info| ext_info.has_avx2()); | ||
let avx512_supported = cpuid | ||
.get_extended_feature_info() | ||
.map_or(false, |ext_info| ext_info.has_avx512f()); // AVX-512 Foundation | ||
if (!avx_supported || !avx2_supported) || !avx512_supported { | ||
MessageDialog::new() | ||
.set_type(native_dialog::MessageType::Error) | ||
.set_title("Compatibility Error") | ||
.set_text("Your CPU does not support AVX/AVX2/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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters