Address undeclared identifiers by adding conditional compilation
This commit is contained in:
parent
11bff29045
commit
57a8f146a0
1 changed files with 18 additions and 0 deletions
18
llama.cpp
18
llama.cpp
|
@ -735,19 +735,37 @@ struct llama_mmap {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefetch > 0) {
|
if (prefetch > 0) {
|
||||||
|
#ifdef __USE_XOPEN2K
|
||||||
// Advise the kernel to preload the mapped memory
|
// Advise the kernel to preload the mapped memory
|
||||||
if (posix_madvise(addr, std::min(file->size, prefetch), POSIX_MADV_WILLNEED)) {
|
if (posix_madvise(addr, std::min(file->size, prefetch), POSIX_MADV_WILLNEED)) {
|
||||||
fprintf(stderr, "warning: posix_madvise(.., POSIX_MADV_WILLNEED) failed: %s\n",
|
fprintf(stderr, "warning: posix_madvise(.., POSIX_MADV_WILLNEED) failed: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Advise the kernel to preload the mapped memory
|
||||||
|
if (madvise(addr, std::min(file->size, prefetch), MADV_WILLNEED)) {
|
||||||
|
fprintf(stderr, "warning: madvise(.., MADV_WILLNEED) failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
if (numa) {
|
if (numa) {
|
||||||
|
#ifdef __USE_XOPEN2K
|
||||||
// advise the kernel not to use readahead
|
// advise the kernel not to use readahead
|
||||||
// (because the next page might not belong on the same node)
|
// (because the next page might not belong on the same node)
|
||||||
if (posix_madvise(addr, file->size, POSIX_MADV_RANDOM)) {
|
if (posix_madvise(addr, file->size, POSIX_MADV_RANDOM)) {
|
||||||
fprintf(stderr, "warning: posix_madvise(.., POSIX_MADV_RANDOM) failed: %s\n",
|
fprintf(stderr, "warning: posix_madvise(.., POSIX_MADV_RANDOM) failed: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// advise the kernel not to use readahead
|
||||||
|
// (because the next page might not belong on the same node)
|
||||||
|
if (madvise(addr, file->size, MADV_RANDOM)) {
|
||||||
|
fprintf(stderr, "warning: madvise(.., MADV_RANDOM) failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue