1#![cfg_attr(not(feature = "std"), no_std)]
2
3use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
4
5#[cfg(feature = "wasm-simd128-enable")]
6pub const DEFAULT_WASM_SIMD128: bool = true;
7
8#[cfg(not(feature = "wasm-simd128-enable"))]
9pub const DEFAULT_WASM_SIMD128: bool = false;
10
11static WASM_SIMD128: AtomicBool = AtomicBool::new(DEFAULT_WASM_SIMD128);
12
13#[inline]
14pub fn get_wasm_simd128() -> bool {
15 WASM_SIMD128.load(Relaxed)
16}
17#[inline]
18pub fn set_wasm_simd128(enable: bool) {
19 WASM_SIMD128.store(enable, Relaxed)
20}
21
22extern crate alloc;
23
24pub mod cache;
25
26pub mod gemm;
27pub mod gemv;
28pub mod gevv;
29
30pub mod horizontal_microkernel;
31pub mod microkernel;
32
33pub mod pack_operands;
34pub mod packed_cache;
35pub mod simd;
36
37pub use pulp;
38
39#[derive(Copy, Clone, Debug)]
40pub enum Parallelism {
41 None,
42 #[cfg(feature = "rayon")]
43 Rayon(usize),
44}
45
46pub struct Ptr<T: ?Sized>(pub *mut T);
47
48impl<T: ?Sized> Clone for Ptr<T> {
49 #[inline]
50 fn clone(&self) -> Self {
51 *self
52 }
53}
54impl<T: ?Sized> Copy for Ptr<T> {}
55
56unsafe impl<T: ?Sized> Send for Ptr<T> {}
57unsafe impl<T: ?Sized> Sync for Ptr<T> {}
58
59impl<T> Ptr<T> {
60 #[inline(always)]
61 pub fn wrapping_offset(self, offset: isize) -> Self {
62 Ptr::<T>(self.0.wrapping_offset(offset))
63 }
64 #[inline(always)]
65 pub fn wrapping_add(self, offset: usize) -> Self {
66 Ptr::<T>(self.0.wrapping_add(offset))
67 }
68}
69
70#[cfg(not(feature = "std"))]
71#[macro_export]
72macro_rules! feature_detected {
73 ($tt: tt) => {
74 cfg!(feature = $tt)
75 };
76}
77
78#[cfg(all(feature = "std", any(target_arch = "x86", target_arch = "x86_64")))]
79#[macro_export]
80macro_rules! feature_detected {
81 ($tt: tt) => {
82 ::std::arch::is_x86_feature_detected!($tt)
83 };
84}
85#[cfg(all(feature = "std", target_arch = "aarch64"))]
86#[macro_export]
87macro_rules! feature_detected {
88 ($tt: tt) => {
89 ::std::arch::is_aarch64_feature_detected!($tt)
90 };
91}
92#[cfg(all(feature = "std", target_family = "wasm"))]
93#[macro_export]
94macro_rules! feature_detected {
95 ("simd128") => {
96 $crate::get_wasm_simd128()
97 };
98}