Skip to content

Commit db932a5

Browse files
committed
misc fixes
1 parent 6e6152b commit db932a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llama.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,6 @@ struct llama_anonymous_mmap : llama_mmap {
16661666
align_to_next_page(&first, dwPageSize);
16671667
align_to_previous_page(&last, dwPageSize);
16681668

1669-
#if _WIN32_WINNT >= 0x603
16701669
DWORD (WINAPI *pOfferVirtualMemory) (PVOID, SIZE_T, DWORD);
16711670
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
16721671

@@ -1676,17 +1675,18 @@ struct llama_anonymous_mmap : llama_mmap {
16761675
if (pOfferVirtualMemory((char *) addr + first, last - first, 0x00000004 /* VMOfferPriorityNormal */)) {
16771676
LLAMA_LOG_WARN("warning: OfferVirtualMemory failed: %s\n", llama_format_win_err(GetLastError()).c_str());
16781677
}
1678+
} else {
1679+
LLAMA_LOG_WARN("warning: OfferVirtualMemory unavailable: %s\n", llama_format_win_err(GetLastError()).c_str());
1680+
if (VirtualAlloc((char *) addr + first, last - first, MEM_RESET, 0)) {
1681+
LLAMA_LOG_WARN("warning: VirtualAlloc(.., MEM_RESET) failed: %s\n", llama_format_win_err(GetLastError()).c_str());
1682+
}
16791683
}
1680-
#else
1681-
if (VirtualAlloc((char *) addr + first, last - first, MEM_RESET, PAGE_NOACCESS)) {
1682-
LLAMA_LOG_WARN("warning: VirtualAlloc(.., MEM_RESET) failed: %s\n", llama_format_win_err(GetLastError()).c_str());
1683-
}
1684-
#endif
16851684
}
16861685

16871686
#else
1688-
llama_anonymous_mmap(struct llama_file * file) {
1687+
llama_anonymous_mmap(struct llama_file * file, bool prefetch) {
16891688
GGML_UNUSED(file);
1689+
GGML_UNUSED(prefetch);
16901690

16911691
throw std::runtime_error("mmap not supported");
16921692
}

0 commit comments

Comments
 (0)