red-candle 1.0.0.pre.3 → 1.0.0.pre.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 375ffec5c2293170bdb0e78ffe2584c8a963968d3226b601d12ddcc040c256ec
4
- data.tar.gz: ea2490c59eca2480728afb7169fc3a24f4270e63491648c1d09fd111707dcb7e
3
+ metadata.gz: 53283961925b76f6fdc39634e01d3d08f58805584488053f7e82fbd484b96b21
4
+ data.tar.gz: 91d3dae0c3c1f6686980708fc898132178454712fe9adf2a79d59f75038c21f1
5
5
  SHA512:
6
- metadata.gz: 9011c72cbe2a065917f26774862bb1f82489e6d5354376cb616df7cea18646ca60ccd5e68282f39b23f89eead196ab41ce70cdaaca224f97aef61914559f653f
7
- data.tar.gz: 4a48101bdcffeecd1bc687dacc7eee7dc42ddbb417b05cce57b97abad83cefe90d965be5c0a8256b8f5c9ba90d80f1159c5392097558acf93a3095913a68a2ad
6
+ metadata.gz: 809ab126883fc6a0b706f46b34922ccbbb5eb18b6b153b703404d17bdd2626a0bafe5cebbdd9168389c44f7506b4f0dabd2b9ed7a6ad6348b7406a899e3e5484
7
+ data.tar.gz: 1d908b031b207bf43e65d81c3f8ac34cd1451cdd38d32476a30e83c23b34c6148a2aa7e235b804ad47041b0d781b1ca36585c2c83b0fa7cd1e9ba26d7cbfc377
@@ -0,0 +1,116 @@
1
+ use std::env;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ // Register our custom cfg flags with rustc
6
+ println!("cargo::rustc-check-cfg=cfg(force_cpu)");
7
+ println!("cargo::rustc-check-cfg=cfg(has_cuda)");
8
+ println!("cargo::rustc-check-cfg=cfg(has_metal)");
9
+ println!("cargo::rustc-check-cfg=cfg(has_mkl)");
10
+ println!("cargo::rustc-check-cfg=cfg(has_accelerate)");
11
+
12
+ println!("cargo:rerun-if-changed=build.rs");
13
+ println!("cargo:rerun-if-env-changed=CANDLE_FORCE_CPU");
14
+ println!("cargo:rerun-if-env-changed=CANDLE_CUDA_PATH");
15
+ println!("cargo:rerun-if-env-changed=CUDA_ROOT");
16
+ println!("cargo:rerun-if-env-changed=CUDA_PATH");
17
+ println!("cargo:rerun-if-env-changed=CANDLE_FEATURES");
18
+ println!("cargo:rerun-if-env-changed=CANDLE_ENABLE_CUDA");
19
+
20
+ // Check if we should force CPU only
21
+ if env::var("CANDLE_FORCE_CPU").is_ok() {
22
+ println!("cargo:rustc-cfg=force_cpu");
23
+ println!("cargo:warning=CANDLE_FORCE_CPU is set, disabling all acceleration");
24
+ return;
25
+ }
26
+
27
+ // Detect CUDA availability
28
+ let cuda_available = detect_cuda();
29
+ let cuda_enabled = env::var("CANDLE_ENABLE_CUDA").is_ok();
30
+
31
+ if cuda_available && cuda_enabled {
32
+ println!("cargo:rustc-cfg=has_cuda");
33
+ println!("cargo:warning=CUDA detected and enabled via CANDLE_ENABLE_CUDA");
34
+ } else if cuda_available && !cuda_enabled {
35
+ println!("cargo:warning=CUDA detected but not enabled. To enable CUDA support (coming soon), set CANDLE_ENABLE_CUDA=1");
36
+ }
37
+
38
+ // Detect Metal availability (macOS only)
39
+ #[cfg(target_os = "macos")]
40
+ {
41
+ println!("cargo:rustc-cfg=has_metal");
42
+ println!("cargo:warning=Metal detected (macOS), Metal acceleration will be available");
43
+ }
44
+
45
+ // Detect MKL availability
46
+ if detect_mkl() {
47
+ println!("cargo:rustc-cfg=has_mkl");
48
+ println!("cargo:warning=Intel MKL detected, MKL acceleration will be available");
49
+ }
50
+
51
+ // Detect Accelerate framework (macOS)
52
+ #[cfg(target_os = "macos")]
53
+ {
54
+ println!("cargo:rustc-cfg=has_accelerate");
55
+ println!("cargo:warning=Accelerate framework detected (macOS)");
56
+ }
57
+ }
58
+
59
+ fn detect_cuda() -> bool {
60
+ // Check environment variables first
61
+ if env::var("CANDLE_CUDA_PATH").is_ok() {
62
+ return true;
63
+ }
64
+
65
+ if env::var("CUDA_ROOT").is_ok() || env::var("CUDA_PATH").is_ok() {
66
+ return true;
67
+ }
68
+
69
+ // Check common CUDA installation paths
70
+ let cuda_paths = [
71
+ "/usr/local/cuda",
72
+ "/opt/cuda",
73
+ "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA",
74
+ "C:\\CUDA",
75
+ ];
76
+
77
+ for path in &cuda_paths {
78
+ if Path::new(path).exists() {
79
+ return true;
80
+ }
81
+ }
82
+
83
+ // Check if nvcc is in PATH
84
+ if let Ok(path_var) = env::var("PATH") {
85
+ for path in env::split_paths(&path_var) {
86
+ if path.join("nvcc").exists() || path.join("nvcc.exe").exists() {
87
+ return true;
88
+ }
89
+ }
90
+ }
91
+
92
+ false
93
+ }
94
+
95
+ fn detect_mkl() -> bool {
96
+ // Check environment variables
97
+ if env::var("MKLROOT").is_ok() || env::var("MKL_ROOT").is_ok() {
98
+ return true;
99
+ }
100
+
101
+ // Check common MKL installation paths
102
+ let mkl_paths = [
103
+ "/opt/intel/mkl",
104
+ "/opt/intel/oneapi/mkl/latest",
105
+ "C:\\Program Files (x86)\\Intel\\oneAPI\\mkl\\latest",
106
+ "C:\\Program Files\\Intel\\oneAPI\\mkl\\latest",
107
+ ];
108
+
109
+ for path in &mkl_paths {
110
+ if Path::new(path).exists() {
111
+ return true;
112
+ }
113
+ }
114
+
115
+ false
116
+ }
@@ -1,3 +1,3 @@
1
1
  module Candle
2
- VERSION = "1.0.0.pre.3"
2
+ VERSION = "1.0.0.pre.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-candle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.3
4
+ version: 1.0.0.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Petersen
@@ -43,6 +43,7 @@ files:
43
43
  - bin/console
44
44
  - bin/setup
45
45
  - ext/candle/Cargo.toml
46
+ - ext/candle/build.rs
46
47
  - ext/candle/extconf.rb
47
48
  - ext/candle/rustfmt.toml
48
49
  - ext/candle/src/lib.rs