1
0
mirror of https://github.com/tensorchord/pgvecto.rs.git synced 2025-07-30 19:23:05 +03:00

fix: remove ctor (#339)

Signed-off-by: usamoi <usamoi@outlook.com>
This commit is contained in:
Usamoi
2024-02-02 18:37:07 +08:00
committed by GitHub
parent 7ec3c88c1e
commit 4eb1f87ae6
9 changed files with 28 additions and 26 deletions

View File

@ -5,5 +5,4 @@ edition.workspace = true
[dependencies]
std_detect = { git = "https://github.com/tensorchord/stdarch.git", branch = "avx512fp16" }
ctor = "0.2.6"
rustix.workspace = true

View File

@ -1,2 +1,19 @@
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_arch = "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();
}
}

View File

@ -1,5 +1,3 @@
#![cfg(target_os = "linux")]
use std::sync::atomic::{AtomicBool, Ordering};
static ATOMIC_MEMFD: AtomicBool = AtomicBool::new(false);
@ -14,8 +12,7 @@ pub fn test_memfd() -> bool {
}
}
#[ctor::ctor]
fn ctor_memfd() {
pub fn ctor_memfd() {
ATOMIC_MEMFD.store(test_memfd(), Ordering::Relaxed);
}

View File

@ -1,5 +1,3 @@
#![cfg(target_arch = "x86_64")]
use std::sync::atomic::{AtomicBool, Ordering};
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()
}
#[ctor::ctor]
fn ctor_avx512fp16() {
pub fn ctor_avx512fp16() {
ATOMIC_AVX512FP16.store(test_avx512fp16(), Ordering::Relaxed);
}
@ -28,8 +25,7 @@ pub fn test_v4() -> bool {
&& test_v3()
}
#[ctor::ctor]
fn ctor_v4() {
pub fn ctor_v4() {
ATOMIC_V4.store(test_v4(), Ordering::Relaxed);
}
@ -52,8 +48,7 @@ pub fn test_v3() -> bool {
&& test_v2()
}
#[ctor::ctor]
fn ctor_v3() {
pub fn ctor_v3() {
ATOMIC_V3.store(test_v3(), Ordering::Relaxed);
}
@ -75,8 +70,7 @@ pub fn test_v2() -> bool {
&& std_detect::is_x86_feature_detected!("ssse3")
}
#[ctor::ctor]
fn ctor_v2() {
pub fn ctor_v2() {
ATOMIC_V2.store(test_v2(), Ordering::Relaxed);
}

View File

@ -2,5 +2,6 @@
#[test]
fn print() {
detect::initialize();
assert_eq!(detect::linux::test_memfd(), detect::linux::detect_memfd());
}

View File

@ -2,6 +2,7 @@
#[test]
fn print() {
detect::initialize();
assert_eq!(
detect::x86_64::test_avx512fp16(),
detect::x86_64::detect_avx512fp16()