Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llama-cpp-2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sampler = []
# Only has an impact on Android.
android-shared-stdcxx = ["llama-cpp-sys-2/shared-stdcxx"]
mtmd = ["llama-cpp-sys-2/mtmd"]
opencl = ["llama-cpp-sys-2/opencl"]


[target.'cfg(all(target_os = "macos", any(target_arch = "aarch64", target_arch = "arm64")))'.dependencies]
Expand Down
2 changes: 2 additions & 0 deletions llama-cpp-sys-2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ include = [
"/llama.cpp/ggml/src/ggml-cuda/**/*",
"/llama.cpp/ggml/src/ggml-metal/**/*",
"/llama.cpp/ggml/src/ggml-vulkan/**/*",
"/llama.cpp/ggml/src/ggml-opencl/**/*",

"/llama.cpp/ggml/src/llamafile/sgemm.h",
"/llama.cpp/ggml/src/llamafile/sgemm.cpp",
Expand Down Expand Up @@ -81,3 +82,4 @@ openmp = []
# Only has an impact on Android.
shared-stdcxx = []
mtmd = []
opencl = []
2 changes: 1 addition & 1 deletion llama-cpp-sys-2/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# llama-cpp-sys

Raw bindings to llama.cpp with cuda support.
Raw bindings to llama.cpp with cuda and opencl support.

See [llama-cpp-2](https://crates.io/crates/llama-cpp-2) for a safe API.
21 changes: 21 additions & 0 deletions llama-cpp-sys-2/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,27 @@ fn main() {
}
}

// OpenCL backend
if cfg!(feature = "opencl") {
config.define("GGML_OPENCL", "ON");
// Explicit for clarity; upstream defaults are ON
config.define("GGML_OPENCL_USE_ADRENO_KERNELS", "ON");
config.define("GGML_OPENCL_EMBED_KERNELS", "ON");

match target_os {
TargetOs::Apple(_) => {
println!("cargo:rustc-link-lib=framework=OpenCL");
}
TargetOs::Windows(_) => {
println!("cargo:rustc-link-lib=OpenCL");
}
TargetOs::Linux | TargetOs::Android => {
println!("cargo:rustc-link-lib=OpenCL");
}
_ => (),
}
}

// Android doesn't have OpenMP support AFAICT and openmp is a default feature. Do this here
// rather than modifying the defaults in Cargo.toml just in case someone enables the OpenMP feature
// and tries to build for Android anyway.
Expand Down
Loading