@@ -1666,7 +1666,6 @@ struct llama_anonymous_mmap : llama_mmap {
1666
1666
align_to_next_page(&first, dwPageSize);
1667
1667
align_to_previous_page(&last, dwPageSize);
1668
1668
1669
- #if _WIN32_WINNT >= 0x603
1670
1669
DWORD (WINAPI *pOfferVirtualMemory) (PVOID, SIZE_T, DWORD);
1671
1670
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
1672
1671
@@ -1676,17 +1675,18 @@ struct llama_anonymous_mmap : llama_mmap {
1676
1675
if (pOfferVirtualMemory((char *) addr + first, last - first, 0x00000004 /* VMOfferPriorityNormal */)) {
1677
1676
LLAMA_LOG_WARN("warning: OfferVirtualMemory failed: %s\n", llama_format_win_err(GetLastError()).c_str());
1678
1677
}
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
+ }
1679
1683
}
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
1685
1684
}
1686
1685
1687
1686
#else
1688
- llama_anonymous_mmap(struct llama_file * file) {
1687
+ llama_anonymous_mmap(struct llama_file * file, bool prefetch ) {
1689
1688
GGML_UNUSED(file);
1689
+ GGML_UNUSED(prefetch);
1690
1690
1691
1691
throw std::runtime_error("mmap not supported");
1692
1692
}
0 commit comments