Skip to content

Commit 55cfca9

Browse files
committed
feat: add openmp feature
1 parent 8512391 commit 55cfca9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

llama-cpp-2/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ tracing = { workspace = true }
1818
encoding_rs = { workspace = true }
1919

2020
[features]
21+
default = ["openmp"]
2122
cuda = ["llama-cpp-sys-2/cuda"]
2223
metal = ["llama-cpp-sys-2/metal"]
2324
dynamic-link = ["llama-cpp-sys-2/dynamic-link"]
2425
vulkan = ["llama-cpp-sys-2/vulkan"]
2526
native = ["llama-cpp-sys-2/native"]
27+
openmp = ["llama-cpp-sys-2/openmp"]
2628
sampler = []
2729

30+
2831
[target.'cfg(all(target_os = "macos", any(target_arch = "aarch64", target_arch = "arm64")))'.dependencies]
2932
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.69", features = [
3033
"metal",

llama-cpp-sys-2/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ metal = []
6969
dynamic-link = []
7070
vulkan = []
7171
native = []
72+
openmp = []

llama-cpp-sys-2/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ fn main() {
245245
config.define("GGML_CUDA", "ON");
246246
}
247247

248+
if cfg!(feature = "openmp") {
249+
config.define("GGML_OPENMP", "ON");
250+
}
251+
248252
// General
249253
config
250254
.profile(&profile)
@@ -272,6 +276,13 @@ fn main() {
272276
);
273277
}
274278

279+
// OpenMP
280+
if cfg!(feature = "openmp") {
281+
if target.contains("gnu") {
282+
println!("cargo:rustc-link-lib=gomp");
283+
}
284+
}
285+
275286
// Windows debug
276287
if cfg!(all(debug_assertions, windows)) {
277288
println!("cargo:rustc-link-lib=dylib=msvcrtd");

0 commit comments

Comments
 (0)