You've already forked pgvecto.rs
mirror of
https://github.com/tensorchord/pgvecto.rs.git
synced 2025-07-30 19:23:05 +03:00
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -439,16 +439,6 @@ dependencies = [
|
|||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ctor"
|
|
||||||
version = "0.2.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.48",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cty"
|
name = "cty"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -472,7 +462,6 @@ dependencies = [
|
|||||||
name = "detect"
|
name = "detect"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctor",
|
|
||||||
"rustix",
|
"rustix",
|
||||||
"std_detect",
|
"std_detect",
|
||||||
]
|
]
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_v_f16_cosine() {
|
fn test_v_f16_cosine() {
|
||||||
|
detect::initialize();
|
||||||
const EPSILON: f32 = f16::EPSILON.to_f32_const();
|
const EPSILON: f32 = f16::EPSILON.to_f32_const();
|
||||||
use half::f16;
|
use half::f16;
|
||||||
unsafe fn v_f16_cosine(a: *const u16, b: *const u16, n: usize) -> f32 {
|
unsafe fn v_f16_cosine(a: *const u16, b: *const u16, n: usize) -> f32 {
|
||||||
@ -46,6 +47,7 @@ fn test_v_f16_cosine() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_v_f16_dot() {
|
fn test_v_f16_dot() {
|
||||||
|
detect::initialize();
|
||||||
const EPSILON: f32 = 1.0f32;
|
const EPSILON: f32 = 1.0f32;
|
||||||
use half::f16;
|
use half::f16;
|
||||||
unsafe fn v_f16_dot(a: *const u16, b: *const u16, n: usize) -> f32 {
|
unsafe fn v_f16_dot(a: *const u16, b: *const u16, n: usize) -> f32 {
|
||||||
@ -86,6 +88,7 @@ fn test_v_f16_dot() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_v_f16_sl2() {
|
fn test_v_f16_sl2() {
|
||||||
|
detect::initialize();
|
||||||
const EPSILON: f32 = 1.0f32;
|
const EPSILON: f32 = 1.0f32;
|
||||||
use half::f16;
|
use half::f16;
|
||||||
unsafe fn v_f16_sl2(a: *const u16, b: *const u16, n: usize) -> f32 {
|
unsafe fn v_f16_sl2(a: *const u16, b: *const u16, n: usize) -> f32 {
|
||||||
|
@ -5,5 +5,4 @@ edition.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std_detect = { git = "https://github.com/tensorchord/stdarch.git", branch = "avx512fp16" }
|
std_detect = { git = "https://github.com/tensorchord/stdarch.git", branch = "avx512fp16" }
|
||||||
ctor = "0.2.6"
|
|
||||||
rustix.workspace = true
|
rustix.workspace = true
|
||||||
|
@ -1,2 +1,19 @@
|
|||||||
|
#[cfg(target_os = "linux")]
|
||||||
pub mod linux;
|
pub mod linux;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub mod x86_64;
|
pub mod x86_64;
|
||||||
|
|
||||||
|
pub fn initialize() {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
self::linux::ctor_memfd();
|
||||||
|
}
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
{
|
||||||
|
self::x86_64::ctor_avx512fp16();
|
||||||
|
self::x86_64::ctor_v2();
|
||||||
|
self::x86_64::ctor_v3();
|
||||||
|
self::x86_64::ctor_v4();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![cfg(target_os = "linux")]
|
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
static ATOMIC_MEMFD: AtomicBool = AtomicBool::new(false);
|
static ATOMIC_MEMFD: AtomicBool = AtomicBool::new(false);
|
||||||
@ -14,8 +12,7 @@ pub fn test_memfd() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ctor::ctor]
|
pub fn ctor_memfd() {
|
||||||
fn ctor_memfd() {
|
|
||||||
ATOMIC_MEMFD.store(test_memfd(), Ordering::Relaxed);
|
ATOMIC_MEMFD.store(test_memfd(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![cfg(target_arch = "x86_64")]
|
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
static ATOMIC_AVX512FP16: AtomicBool = AtomicBool::new(false);
|
static ATOMIC_AVX512FP16: AtomicBool = AtomicBool::new(false);
|
||||||
@ -8,8 +6,7 @@ pub fn test_avx512fp16() -> bool {
|
|||||||
std_detect::is_x86_feature_detected!("avx512fp16") && test_v4()
|
std_detect::is_x86_feature_detected!("avx512fp16") && test_v4()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ctor::ctor]
|
pub fn ctor_avx512fp16() {
|
||||||
fn ctor_avx512fp16() {
|
|
||||||
ATOMIC_AVX512FP16.store(test_avx512fp16(), Ordering::Relaxed);
|
ATOMIC_AVX512FP16.store(test_avx512fp16(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +25,7 @@ pub fn test_v4() -> bool {
|
|||||||
&& test_v3()
|
&& test_v3()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ctor::ctor]
|
pub fn ctor_v4() {
|
||||||
fn ctor_v4() {
|
|
||||||
ATOMIC_V4.store(test_v4(), Ordering::Relaxed);
|
ATOMIC_V4.store(test_v4(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +48,7 @@ pub fn test_v3() -> bool {
|
|||||||
&& test_v2()
|
&& test_v2()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ctor::ctor]
|
pub fn ctor_v3() {
|
||||||
fn ctor_v3() {
|
|
||||||
ATOMIC_V3.store(test_v3(), Ordering::Relaxed);
|
ATOMIC_V3.store(test_v3(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +70,7 @@ pub fn test_v2() -> bool {
|
|||||||
&& std_detect::is_x86_feature_detected!("ssse3")
|
&& std_detect::is_x86_feature_detected!("ssse3")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ctor::ctor]
|
pub fn ctor_v2() {
|
||||||
fn ctor_v2() {
|
|
||||||
ATOMIC_V2.store(test_v2(), Ordering::Relaxed);
|
ATOMIC_V2.store(test_v2(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print() {
|
fn print() {
|
||||||
|
detect::initialize();
|
||||||
assert_eq!(detect::linux::test_memfd(), detect::linux::detect_memfd());
|
assert_eq!(detect::linux::test_memfd(), detect::linux::detect_memfd());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print() {
|
fn print() {
|
||||||
|
detect::initialize();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
detect::x86_64::test_avx512fp16(),
|
detect::x86_64::test_avx512fp16(),
|
||||||
detect::x86_64::detect_avx512fp16()
|
detect::x86_64::detect_avx512fp16()
|
||||||
|
@ -24,6 +24,7 @@ unsafe extern "C" fn _PG_init() {
|
|||||||
SessionError::BadInit.friendly();
|
SessionError::BadInit.friendly();
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
detect::initialize();
|
||||||
self::gucs::init();
|
self::gucs::init();
|
||||||
self::index::init();
|
self::index::init();
|
||||||
self::ipc::init();
|
self::ipc::init();
|
||||||
|
Reference in New Issue
Block a user