mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-10 15:57:04 +00:00
* add build to .dockerignore * test: only build one arch * add build to .gitignore * fix ccache path * filter amdgpu targets * only filter if autodetecting * Don't clobber gpu list for default runner This ensures the GPU specific environment variables are set properly * explicitly set CXX compiler for HIP * Update build_windows.ps1 This isn't complete, but is close. Dependencies are missing, and it only builds the "default" preset. * build: add ollama subdir * add .git to .dockerignore * docs: update development.md * update build_darwin.sh * remove unused scripts * llm: add cwd and build/lib/ollama to library paths * default DYLD_LIBRARY_PATH to LD_LIBRARY_PATH in runner on macOS * add additional cmake output vars for msvc * interim edits to make server detection logic work with dll directories like lib/ollama/cuda_v12 * remove unncessary filepath.Dir, cleanup * add hardware-specific directory to path * use absolute server path * build: linux arm * cmake install targets * remove unused files * ml: visit each library path once * build: skip cpu variants on arm * build: install cpu targets * build: fix workflow * shorter names * fix rocblas install * docs: clean up development.md * consistent build dir removal in development.md * silence -Wimplicit-function-declaration build warnings in ggml-cpu * update readme * update development readme * llm: update library lookup logic now that there is one runner (#8587) * tweak development.md * update docs * add windows cuda/rocm tests --------- Co-authored-by: jmorganca <jmorganca@gmail.com> Co-authored-by: Daniel Hiltgen <daniel@ollama.com>
83 lines
3.2 KiB
Diff
83 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Michael Yang <mxyng@pm.me>
|
|
Date: Tue, 14 Jan 2025 12:01:24 -0800
|
|
Subject: [PATCH] sort devices by score
|
|
|
|
---
|
|
ggml/src/ggml-backend-reg.cpp | 21 +++++++++++++--------
|
|
1 file changed, 13 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp
|
|
index 899d16f2..ac5cda07 100644
|
|
--- a/ggml/src/ggml-backend-reg.cpp
|
|
+++ b/ggml/src/ggml-backend-reg.cpp
|
|
@@ -150,7 +150,7 @@ struct ggml_backend_reg_entry {
|
|
|
|
struct ggml_backend_registry {
|
|
std::vector<ggml_backend_reg_entry> backends;
|
|
- std::vector<ggml_backend_dev_t> devices;
|
|
+ std::vector<std::pair<ggml_backend_dev_t, int>> devices;
|
|
|
|
ggml_backend_registry() {
|
|
#ifdef GGML_USE_CUDA
|
|
@@ -195,7 +195,7 @@ struct ggml_backend_registry {
|
|
}
|
|
}
|
|
|
|
- void register_backend(ggml_backend_reg_t reg, dl_handle_ptr handle = nullptr) {
|
|
+ void register_backend(ggml_backend_reg_t reg, int score = -1, dl_handle_ptr handle = nullptr) {
|
|
if (!reg) {
|
|
return;
|
|
}
|
|
@@ -206,15 +206,15 @@ struct ggml_backend_registry {
|
|
#endif
|
|
backends.push_back({ reg, std::move(handle) });
|
|
for (size_t i = 0; i < ggml_backend_reg_dev_count(reg); i++) {
|
|
- register_device(ggml_backend_reg_dev_get(reg, i));
|
|
+ register_device(ggml_backend_reg_dev_get(reg, i), score);
|
|
}
|
|
}
|
|
|
|
- void register_device(ggml_backend_dev_t device) {
|
|
+ void register_device(ggml_backend_dev_t device, int score = -1) {
|
|
#ifndef NDEBUG
|
|
GGML_LOG_DEBUG("%s: registered device %s (%s)\n", __func__, ggml_backend_dev_name(device), ggml_backend_dev_description(device));
|
|
#endif
|
|
- devices.push_back(device);
|
|
+ devices.push_back({device, score});
|
|
}
|
|
|
|
ggml_backend_reg_t load_backend(const std::wstring & path, bool silent) {
|
|
@@ -257,7 +257,7 @@ struct ggml_backend_registry {
|
|
|
|
GGML_LOG_INFO("%s: loaded %s backend from %s\n", __func__, ggml_backend_reg_name(reg), utf16_to_utf8(path).c_str());
|
|
|
|
- register_backend(reg, std::move(handle));
|
|
+ register_backend(reg, score_fn ? score_fn() : -1, std::move(handle));
|
|
|
|
return reg;
|
|
}
|
|
@@ -280,7 +280,7 @@ struct ggml_backend_registry {
|
|
// remove devices
|
|
devices.erase(
|
|
std::remove_if(devices.begin(), devices.end(),
|
|
- [reg](ggml_backend_dev_t dev) { return ggml_backend_dev_backend_reg(dev) == reg; }),
|
|
+ [reg](std::pair<ggml_backend_dev_t, int> dev) { return ggml_backend_dev_backend_reg(dev.first) == reg; }),
|
|
devices.end());
|
|
|
|
// remove backend
|
|
@@ -338,7 +338,12 @@ size_t ggml_backend_dev_count() {
|
|
|
|
ggml_backend_dev_t ggml_backend_dev_get(size_t index) {
|
|
GGML_ASSERT(index < ggml_backend_dev_count());
|
|
- return get_reg().devices[index];
|
|
+ auto devices = get_reg().devices;
|
|
+ if (!std::is_heap(devices.begin(), devices.end())) {
|
|
+ std::make_heap(devices.begin(), devices.end(), [](const auto & a, const auto & b) { return a.second < b.second; });
|
|
+ }
|
|
+
|
|
+ return devices[index].first;
|
|
}
|
|
|
|
ggml_backend_dev_t ggml_backend_dev_by_name(const char * name) {
|