1#![cfg_attr(feature = "frozen-abi", 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;
11#[cfg(feature = "dev-context-only-utils")]
12pub mod test_tx;
13pub mod thread;
14
15#[macro_use]
16extern crate log;
17
18#[cfg(test)]
19#[macro_use]
20extern crate assert_matches;
21
22#[macro_use]
23extern crate atlas_metrics;
24
25#[cfg_attr(feature = "frozen-abi", macro_use)]
26#[cfg(feature = "frozen-abi")]
27extern crate atlas_frozen_abi_macro;
28
29fn is_rosetta_emulated() -> bool {
30 #[cfg(target_os = "macos")]
31 {
32 use std::str::FromStr;
33 std::process::Command::new("sysctl")
34 .args(["-in", "sysctl.proc_translated"])
35 .output()
36 .map_err(|_| ())
37 .and_then(|output| String::from_utf8(output.stdout).map_err(|_| ()))
38 .and_then(|stdout| u8::from_str(stdout.trim()).map_err(|_| ()))
39 .map(|enabled| enabled == 1)
40 .unwrap_or(false)
41 }
42 #[cfg(not(target_os = "macos"))]
43 {
44 false
45 }
46}
47
48pub fn report_target_features() {
49 warn!(
50 "CUDA is {}abled",
51 if crate::perf_libs::api().is_some() {
52 "en"
53 } else {
54 "dis"
55 }
56 );
57
58 if !is_rosetta_emulated() {
62 #[cfg(all(
63 any(target_arch = "x86", target_arch = "x86_64"),
64 build_target_feature_avx
65 ))]
66 {
67 if is_x86_feature_detected!("avx") {
68 info!("AVX detected");
69 } else {
70 error!(
71 "Incompatible CPU detected: missing AVX support. Please build from source on \
72 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 \
88 the target"
89 );
90 std::process::abort();
91 }
92 }
93 }
94}