candle_gemm_common/
lib.rs

1#![cfg_attr(feature = "nightly", feature(stdsimd), feature(avx512_target_feature))]
2
3pub mod cache;
4
5pub mod gemm;
6pub mod gemv;
7pub mod gevv;
8
9pub mod microkernel;
10pub mod pack_operands;
11pub mod simd;
12
13#[derive(Copy, Clone, Debug)]
14pub enum Parallelism {
15    None,
16    Rayon(usize),
17}
18
19pub struct Ptr<T>(pub *mut T);
20
21impl<T> Clone for Ptr<T> {
22    fn clone(&self) -> Self {
23        *self
24    }
25}
26impl<T> Copy for Ptr<T> {}
27
28unsafe impl<T> Send for Ptr<T> {}
29unsafe impl<T> Sync for Ptr<T> {}
30
31impl<T> Ptr<T> {
32    #[inline(always)]
33    pub fn wrapping_offset(self, offset: isize) -> Self {
34        Ptr::<T>(self.0.wrapping_offset(offset))
35    }
36    #[inline(always)]
37    pub fn wrapping_add(self, offset: usize) -> Self {
38        Ptr::<T>(self.0.wrapping_add(offset))
39    }
40}
41
42#[cfg(not(feature = "std"))]
43#[macro_export]
44macro_rules! feature_detected {
45    ($tt: tt) => {
46        cfg!(feature = $tt)
47    };
48}
49
50#[cfg(all(feature = "std", any(target_arch = "x86", target_arch = "x86_64")))]
51#[macro_export]
52macro_rules! feature_detected {
53    ($tt: tt) => {
54        ::std::arch::is_x86_feature_detected!($tt)
55    };
56}
57#[cfg(all(feature = "std", target_arch = "aarch64"))]
58#[macro_export]
59macro_rules! feature_detected {
60    ($tt: tt) => {
61        ::std::arch::is_aarch64_feature_detected!($tt)
62    };
63}