1#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
2pub mod cuda_runtime;
3pub mod data_budget;
4pub mod deduper;
5pub mod discard;
6pub mod packet;
7pub mod perf_libs;
8pub mod recycler;
9pub mod recycler_cache;
10pub mod sigverify;
11pub mod test_tx;
12pub mod thread;
13
14#[macro_use]
15extern crate lazy_static;
16
17#[macro_use]
18extern crate log;
19
20#[cfg(test)]
21#[macro_use]
22extern crate assert_matches;
23
24#[macro_use]
25extern crate miraland_metrics;
26
27#[macro_use]
28extern crate miraland_frozen_abi_macro;
29
30fn is_rosetta_emulated() -> bool {
31 #[cfg(target_os = "macos")]
32 {
33 use std::str::FromStr;
34 std::process::Command::new("sysctl")
35 .args(["-in", "sysctl.proc_translated"])
36 .output()
37 .map_err(|_| ())
38 .and_then(|output| String::from_utf8(output.stdout).map_err(|_| ()))
39 .and_then(|stdout| u8::from_str(stdout.trim()).map_err(|_| ()))
40 .map(|enabled| enabled == 1)
41 .unwrap_or(false)
42 }
43 #[cfg(not(target_os = "macos"))]
44 {
45 false
46 }
47}
48
49pub fn report_target_features() {
50 warn!(
51 "CUDA is {}abled",
52 if crate::perf_libs::api().is_some() {
53 "en"
54 } else {
55 "dis"
56 }
57 );
58
59 if !is_rosetta_emulated() {
63 #[cfg(all(
64 any(target_arch = "x86", target_arch = "x86_64"),
65 build_target_feature_avx
66 ))]
67 {
68 if is_x86_feature_detected!("avx") {
69 info!("AVX detected");
70 } else {
71 error!(
72 "Incompatible CPU detected: missing AVX support. Please build from source on the target"
73 );
74 std::process::abort();
75 }
76 }
77
78 #[cfg(all(
79 any(target_arch = "x86", target_arch = "x86_64"),
80 build_target_feature_avx2
81 ))]
82 {
83 if is_x86_feature_detected!("avx2") {
84 info!("AVX2 detected");
85 } else {
86 error!(
87 "Incompatible CPU detected: missing AVX2 support. Please build from source on the target"
88 );
89 std::process::abort();
90 }
91 }
92 }
93}