From 95094855f3869c4d0a3d3ff929f27c26a9dfd5bb Mon Sep 17 00:00:00 2001 From: scafe3 Date: Wed, 3 Jul 2024 17:11:15 +0800 Subject: [PATCH 1/4] Show blst hardware support in lighthouse --version --- lighthouse/src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index abee30737cf..0a422691951 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -26,12 +26,14 @@ lazy_static! { pub static ref LONG_VERSION: String = format!( "{}\n\ BLS library: {}\n\ + BLS hardware acceleration: {}\n\ SHA256 hardware acceleration: {}\n\ Allocator: {}\n\ Profile: {}\n\ Specs: mainnet (true), minimal ({}), gnosis ({})", SHORT_VERSION.as_str(), bls_library_name(), + bls_hardware_acceleration(), have_sha_extensions(), allocator_name(), build_profile_name(), @@ -50,6 +52,10 @@ fn bls_library_name() -> &'static str { } } +fn bls_hardware_acceleration() -> bool { + !cfg!(feature = "portable") +} + fn allocator_name() -> &'static str { if cfg!(feature = "jemalloc") { "jemalloc" From 19660cbbcce108a3a5ef3e71f6077ecdf0e9a78b Mon Sep 17 00:00:00 2001 From: scafe3 Date: Wed, 3 Jul 2024 23:15:46 +0800 Subject: [PATCH 2/4] fix: detect adx extension in runtime --- lighthouse/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 0a422691951..46c5212e90f 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -52,8 +52,14 @@ fn bls_library_name() -> &'static str { } } +#[inline(always)] +#[allow(unreachable_code)] fn bls_hardware_acceleration() -> bool { - !cfg!(feature = "portable") + #[cfg(feature = "portable")] + return false; + + #[cfg(target_arch = "x86_64")] + return std::is_x86_feature_detected!("adx"); } fn allocator_name() -> &'static str { From 4a72b57ff508b0dff9a8279662934f1d6939c25b Mon Sep 17 00:00:00 2001 From: scafe3 Date: Wed, 3 Jul 2024 23:24:55 +0800 Subject: [PATCH 3/4] fix --- lighthouse/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 46c5212e90f..6ecacdb8621 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -60,6 +60,8 @@ fn bls_hardware_acceleration() -> bool { #[cfg(target_arch = "x86_64")] return std::is_x86_feature_detected!("adx"); + + false } fn allocator_name() -> &'static str { From 6dbb0f9dc856ca6dfac758cc16c943e8951a4e4a Mon Sep 17 00:00:00 2001 From: scafe3 Date: Thu, 4 Jul 2024 10:28:55 +0800 Subject: [PATCH 4/4] add arm detect --- lighthouse/src/main.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 6ecacdb8621..be419148f32 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -53,15 +53,12 @@ fn bls_library_name() -> &'static str { } #[inline(always)] -#[allow(unreachable_code)] fn bls_hardware_acceleration() -> bool { - #[cfg(feature = "portable")] - return false; - #[cfg(target_arch = "x86_64")] return std::is_x86_feature_detected!("adx"); - false + #[cfg(target_arch = "aarch64")] + return std::arch::is_aarch64_feature_detected!("neon"); } fn allocator_name() -> &'static str {