Skip to content

Commit a38f4a2

Browse files
committed
llama : avoid ggml include in llama-util.h
1 parent 0fe4b00 commit a38f4a2

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

llama-util.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <vector>
1717
#include <stdexcept>
1818

19-
#include "ggml.h"
20-
2119
#ifdef __has_include
2220
#if __has_include(<unistd.h>)
2321
#include <unistd.h>
@@ -174,12 +172,12 @@ struct llama_mmap {
174172
#ifdef _POSIX_MAPPED_FILES
175173
static constexpr bool SUPPORTED = true;
176174

177-
llama_mmap(struct llama_file * file, size_t prefetch = (size_t) -1 /* -1 = max value */) {
175+
llama_mmap(struct llama_file * file, size_t prefetch = (size_t) -1 /* -1 = max value */, bool numa = false) {
178176
size = file->size;
179177
int fd = fileno(file->fp);
180178
int flags = MAP_SHARED;
181179
// prefetch/readahead impairs performance on NUMA systems
182-
if (ggml_is_numa()) { prefetch = 0; }
180+
if (numa) { prefetch = 0; }
183181
#ifdef __linux__
184182
if (prefetch) { flags |= MAP_POPULATE; }
185183
#endif
@@ -195,7 +193,7 @@ struct llama_mmap {
195193
strerror(errno));
196194
}
197195
}
198-
if (ggml_is_numa()) {
196+
if (numa) {
199197
// advise the kernel not to use readahead
200198
// (because the next page might not belong on the same node)
201199
if (madvise(addr, file->size, MADV_RANDOM)) {

llama.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ struct llama_model_loader {
774774
}
775775

776776
if (use_mmap) {
777-
mapping.reset(new llama_mmap(&file_loaders.at(0)->file, prefetch_size));
777+
mapping.reset(new llama_mmap(&file_loaders.at(0)->file, prefetch_size, ggml_is_numa()));
778778
if (lmlock) {
779779
lmlock->init(mapping->addr);
780780
}
@@ -2903,7 +2903,7 @@ int llama_apply_lora_from_file_internal(const struct llama_model & model, const
29032903

29042904
// maybe this should in llama_model_loader
29052905
if (model_loader->use_mmap) {
2906-
model_loader->mapping.reset(new llama_mmap(&model_loader->file_loaders.at(0)->file, /* prefetch */ 0));
2906+
model_loader->mapping.reset(new llama_mmap(&model_loader->file_loaders.at(0)->file, /* prefetch */ 0, ggml_is_numa()));
29072907
}
29082908
}
29092909

0 commit comments

Comments
 (0)