Skip to content

Commit 64409eb

Browse files
authored
Merge pull request #404 from babichjacob/simplify-cpu-features
2 parents a8a71a5 + 049245b commit 64409eb

File tree

3 files changed

+19
-50
lines changed

3 files changed

+19
-50
lines changed

llama-cpp-2/Cargo.toml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,6 @@ vulkan = ["llama-cpp-sys-2/vulkan"]
2222
native = ["llama-cpp-sys-2/native"]
2323
sampler = []
2424

25-
[target.'cfg(target_feature = "avx")'.dependencies]
26-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
27-
"avx",
28-
] }
29-
[target.'cfg(target_feature = "avx2")'.dependencies]
30-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
31-
"avx2",
32-
] }
33-
[target.'cfg(target_feature = "avx512f")'.dependencies]
34-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
35-
"avx512",
36-
] }
37-
[target.'cfg(target_feature = "avx512vbmi")'.dependencies]
38-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
39-
"avx512_vmbi",
40-
] }
41-
[target.'cfg(target_feature = "avx512vnni")'.dependencies]
42-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
43-
"avx512_vnni",
44-
] }
45-
[target.'cfg(target_feature = "f16c")'.dependencies]
46-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
47-
"f16c",
48-
] }
49-
[target.'cfg(target_feature = "fma")'.dependencies]
50-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
51-
"fma",
52-
] }
53-
5425
[target.'cfg(all(target_os = "macos", any(target_arch = "aarch64", target_arch = "arm64")))'.dependencies]
5526
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
5627
"metal",

llama-cpp-sys-2/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,7 @@ cc = { workspace = true, features = ["parallel"] }
5353
once_cell = "1.19.0"
5454

5555
[features]
56-
avx = []
57-
avx2 = []
58-
avx512 = []
59-
avx512_vmbi = []
60-
avx512_vnni = []
6156
cuda = []
62-
f16c = []
63-
fma = []
6457
metal = []
6558
dynamic_link = []
6659
vulkan = []

llama-cpp-sys-2/build.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,59 +259,64 @@ fn push_feature_flags(cx: &mut Build, cxx: &mut Build) {
259259
cxx.flag("-march=native");
260260
}
261261

262-
if cfg!(feature = "fma") && cfg!(target_family = "unix") {
262+
if cfg!(target_feature = "fma") && cfg!(target_family = "unix") {
263263
cx.flag("-mfma");
264264
cxx.flag("-mfma");
265265
}
266266

267-
if cfg!(feature = "f16c") && cfg!(target_family = "unix") {
267+
if cfg!(target_feature = "f16c") && cfg!(target_family = "unix") {
268268
cx.flag("-mf16c");
269269
cxx.flag("-mf16c");
270270
}
271271

272272
if cfg!(target_family = "unix") {
273-
if cfg!(feature = "avx512") {
274-
cx.flag("-mavx512f").flag("-mavx512bw");
275-
cxx.flag("-mavx512f").flag("-mavx512bw");
273+
if cfg!(target_feature = "avx512f") {
274+
cx.flag("-mavx512f");
275+
cxx.flag("-mavx512f");
276276

277-
if cfg!(feature = "avx512_vmbi") {
277+
if cfg!(target_feature = "avx512bw") {
278+
cx.flag("-mavx512bw");
279+
cxx.flag("-mavx512bw");
280+
}
281+
282+
if cfg!(target_feature = "avx512vbmi") {
278283
cx.flag("-mavx512vbmi");
279284
cxx.flag("-mavx512vbmi");
280285
}
281286

282-
if cfg!(feature = "avx512_vnni") {
287+
if cfg!(target_feature = "avx512vnni") {
283288
cx.flag("-mavx512vnni");
284289
cxx.flag("-mavx512vnni");
285290
}
286291
}
287292

288-
if cfg!(feature = "avx2") {
293+
if cfg!(target_feature = "avx2") {
289294
cx.flag("-mavx2");
290295
cxx.flag("-mavx2");
291296
}
292297

293-
if cfg!(feature = "avx") {
298+
if cfg!(target_feature = "avx") {
294299
cx.flag("-mavx");
295300
cxx.flag("-mavx");
296301
}
297302
} else if cfg!(target_family = "windows") {
298-
if cfg!(feature = "avx512") {
303+
if cfg!(target_feature = "avx512f") {
299304
cx.flag("/arch:AVX512");
300305
cxx.flag("/arch:AVX512");
301306

302-
if cfg!(feature = "avx512_vmbi") {
307+
if cfg!(target_feature = "avx512vbmi") {
303308
cx.define("__AVX512VBMI__", None);
304309
cxx.define("__AVX512VBMI__", None);
305310
}
306311

307-
if cfg!(feature = "avx512_vnni") {
312+
if cfg!(target_feature = "avx512vnni") {
308313
cx.define("__AVX512VNNI__", None);
309314
cxx.define("__AVX512VNNI__", None);
310315
}
311-
} else if cfg!(feature = "avx2") {
316+
} else if cfg!(target_feature = "avx2") {
312317
cx.flag("/arch:AVX2");
313318
cxx.flag("/arch:AVX2");
314-
} else if cfg!(feature = "avx") {
319+
} else if cfg!(target_feature = "avx") {
315320
cx.flag("/arch:AVX");
316321
cxx.flag("/arch:AVX");
317322
}

0 commit comments

Comments
 (0)