Browse Source

win rm openmp

Thomas 3 weeks ago
parent
commit
72afaddbd7
2 changed files with 43 additions and 2 deletions
  1. 6 1
      Cargo.toml
  2. 37 1
      src/uniqueness/suffix.rs

+ 6 - 1
Cargo.toml

@@ -61,9 +61,14 @@ chainfile = "0.3.0"
 omics = "0.2.0"
 filetime = "0.2.27"
 pandora_lib_smb = { git = "https://git.t0m4.fr/Thomas/pandora_lib_smb" }
-libsais = { version = "0.2.0", features = ["openmp"] }
 memmap2 = "0.9.9"
 
+[target.'cfg(not(target_os = "windows"))'.dependencies]
+libsais = { version = "0.2.0", features = ["openmp"] }
+
+[target.'cfg(target_os = "windows")'.dependencies]
+libsais = { version = "0.2.0" }
+
 [profile.dev]
 opt-level = 0
 debug = false

+ 37 - 1
src/uniqueness/suffix.rs

@@ -1,5 +1,7 @@
 use super::{GenomeCoord, UniqueLen};
-use libsais::{SuffixArrayConstruction, ThreadCount};
+use libsais::SuffixArrayConstruction;
+#[cfg(not(target_os = "windows"))]
+use libsais::ThreadCount;
 use log::info;
 use std::time::Instant;
 
@@ -13,17 +15,34 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
         return (Vec::new(), Vec::new());
     }
 
+    #[cfg(not(target_os = "windows"))]
     let thread_count = rayon::current_num_threads().min(u16::MAX as usize) as u16;
+
+    #[cfg(not(target_os = "windows"))]
     info!(
         "[uniqueness] building suffix array with libsais ({:.1} Mbp, {thread_count} thread(s))",
         n as f64 / 1e6
     );
+    #[cfg(target_os = "windows")]
+    info!(
+        "[uniqueness] building suffix array with libsais ({:.1} Mbp, single-threaded)",
+        n as f64 / 1e6
+    );
+
     let started = Instant::now();
+
+    #[cfg(not(target_os = "windows"))]
     let sa_result = SuffixArrayConstruction::for_text(genome)
         .in_owned_buffer64()
         .multi_threaded(ThreadCount::fixed(thread_count))
         .run()
         .expect("libsais failed to construct suffix array");
+    #[cfg(target_os = "windows")]
+    let sa_result = SuffixArrayConstruction::for_text(genome)
+        .in_owned_buffer64()
+        .run()
+        .expect("libsais failed to construct suffix array");
+
     info!(
         "[uniqueness] suffix array built in {:.1}s",
         started.elapsed().as_secs_f64()
@@ -44,11 +63,19 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
 
     info!("[uniqueness] building PLCP array with libsais");
     let started = Instant::now();
+
+    #[cfg(not(target_os = "windows"))]
     let sa_with_plcp = sa_result
         .plcp_construction()
         .multi_threaded(ThreadCount::fixed(thread_count))
         .run()
         .expect("libsais failed to construct PLCP array");
+    #[cfg(target_os = "windows")]
+    let sa_with_plcp = sa_result
+        .plcp_construction()
+        .run()
+        .expect("libsais failed to construct PLCP array");
+
     info!(
         "[uniqueness] PLCP array built in {:.1}s",
         started.elapsed().as_secs_f64()
@@ -56,6 +83,8 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
 
     info!("[uniqueness] building LCP array with libsais");
     let started = Instant::now();
+
+    #[cfg(not(target_os = "windows"))]
     let (lcp64, _plcp64) = sa_with_plcp
         .lcp_construction()
         .replace_suffix_array()
@@ -63,6 +92,13 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
         .run()
         .expect("libsais failed to construct LCP array")
         .into_parts();
+    #[cfg(target_os = "windows")]
+    let (lcp64, _plcp64) = sa_with_plcp
+        .lcp_construction()
+        .replace_suffix_array()
+        .run()
+        .expect("libsais failed to construct LCP array")
+        .into_parts();
 
     let lcp = lcp64
         .into_iter()