mirror of
https://github.com/Lizonghang/prima.cpp.git
synced 2025-09-10 07:04:34 +00:00
increase prefetch dense
This commit is contained in:
parent
65ad14140a
commit
6a50d494d2
1 changed files with 5 additions and 2 deletions
|
@ -17823,13 +17823,16 @@ static void manage_graph_tensors(struct ggml_cgraph * cgraph, int advice, bool f
|
|||
}
|
||||
|
||||
for (const auto & segment : merged_segments) {
|
||||
size_t prefetch_dense = 4;
|
||||
size_t len = std::max(segment.end - segment.start, static_cast<size_t>(page_size));
|
||||
posix_madvise(reinterpret_cast<void *>(segment.start), len, advice); // hint to load into memory
|
||||
// force to prefetch data
|
||||
if (force && advice == POSIX_MADV_WILLNEED) {
|
||||
volatile char * ptr = reinterpret_cast<volatile char *>(segment.start);
|
||||
for (size_t off = 0; off < len; off += page_size) {
|
||||
(void)ptr[off];
|
||||
for (size_t off = 0; off < len; off += prefetch_dense * page_size) {
|
||||
for (size_t i = 0; i < prefetch_dense; i++) {
|
||||
if (off + i * page_size < len) (void)ptr[off + i * page_size];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue