aboutsummaryrefslogtreecommitdiff
path: root/llama-util.h
diff options
context:
space:
mode:
authorHoward Su <howard0su@gmail.com>2023-07-13 21:58:25 +0800
committerGitHub <noreply@github.com>2023-07-13 21:58:25 +0800
commit32c54116318929c90fd7ae814cf9b5232cd44c36 (patch)
tree3b9126e3fb387ef1aa53d7461f9a41e1ce2965ed /llama-util.h
parentff5d58faecf1f02b05bd015bdfc6a394cf2bc9ba (diff)
Revert "Support using mmap when applying LoRA (#2095)" (#2206)
Has perf regression when mlock is used. This reverts commit 2347463201a9f4159ae95b737e1544dd300569c8.
Diffstat (limited to 'llama-util.h')
-rw-r--r--llama-util.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/llama-util.h b/llama-util.h
index 43b6f05..042ebe4 100644
--- a/llama-util.h
+++ b/llama-util.h
@@ -175,13 +175,13 @@ struct llama_mmap {
llama_mmap(struct llama_file * file, size_t prefetch = (size_t) -1 /* -1 = max value */, bool numa = false) {
size = file->size;
int fd = fileno(file->fp);
- int flags = MAP_PRIVATE;
+ int flags = MAP_SHARED;
// prefetch/readahead impairs performance on NUMA systems
if (numa) { prefetch = 0; }
#ifdef __linux__
if (prefetch) { flags |= MAP_POPULATE; }
#endif
- addr = mmap(NULL, file->size, PROT_READ | PROT_WRITE, flags, fd, 0);
+ addr = mmap(NULL, file->size, PROT_READ, flags, fd, 0);
if (addr == MAP_FAILED) {
throw std::runtime_error(format("mmap failed: %s", strerror(errno)));
}
@@ -223,7 +223,7 @@ struct llama_mmap {
throw std::runtime_error(format("CreateFileMappingA failed: %s", llama_format_win_err(error).c_str()));
}
- addr = MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+ addr = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
error = GetLastError();
CloseHandle(hMapping);