macOS platform guards in the host files (C2): every host source under src/ now compiles for Metal

All under __APPLE__ / STRATA_GPU_METAL, so the Linux and Windows code is unchanged:
- direct_file.cpp: no O_DIRECT on macOS; F_NOCACHE after open keeps the reads out of the buffer cache
- memory.cpp: F_RDADVISE is the read-ahead hint where posix_fadvise(WILLNEED) is used
- expert_source.cpp: available memory from host_statistics64 (free + inactive + purgeable); the posix_fadvise of a
  released expert layer is skipped (the madvise before it already released the mapping)
- generate.cpp: <sys/sysmacros.h> is not on macOS (major/minor come from <sys/types.h>); the CUDA toolkit mismatch
  check is CUDA's
- vmm.cpp: the cuMem* virtual memory stays CUDA's (Metal takes the HIP branch: elastic K/V off)
- prefill.cpp: std::max<size_t> where size_t and uint64_t meet (the same type on Linux, distinct on macOS)
This commit is contained in:
Niko1221 committed 2026-10-12 12:29:27 +02:00
1 parent bf4b79abda
commit f1c5a6772c
6 files changed
+33 -4

No files matched your search

+7
View File
@@ -166,7 +166,14 @@ void advise_willneed(const void* p, uint64_t bytes) {
void advise_willneed(int fd, uint64_t offset, uint64_t bytes) {
if (fd < 0 || !read_ahead_enabled()) return;
for (uint64_t at = 0; at < bytes; at += kAdviseStep)
#if defined(__APPLE__) // macOS: F_RDADVISE is the read-ahead hint
{
radvisory ra{(off_t) (offset + at), (int) std::min(kAdviseStep, bytes - at)};
(void) fcntl(fd, F_RDADVISE, &ra);
}
#else
(void) posix_fadvise(fd, (off_t) (offset + at), (off_t) std::min(kAdviseStep, bytes - at), POSIX_FADV_WILLNEED);
#endif
}
#endif