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:
1 parent
bf4b79abda
commit
f1c5a6772c
6 files changed
+33
-4
No files matched your search
@@ -306,7 +306,12 @@ DirectFile::~DirectFile() { close(); delete impl_; }
|
||||
|
||||
bool DirectFile::open(const std::string& path, std::string& err) {
|
||||
close();
|
||||
#if defined(__APPLE__) // macOS has no O_DIRECT: F_NOCACHE keeps the reads out of the unified buffer cache
|
||||
impl_->fd = ::open(path.c_str(), O_RDONLY);
|
||||
if (impl_->fd >= 0 && fcntl(impl_->fd, F_NOCACHE, 1) != 0) { ::close(impl_->fd); impl_->fd = -1; }
|
||||
#else
|
||||
impl_->fd = ::open(path.c_str(), O_RDONLY | O_DIRECT);
|
||||
#endif
|
||||
if (impl_->fd < 0) { err = "DirectFile: cannot open " + path; return false; }
|
||||
struct stat st;
|
||||
if (fstat(impl_->fd, &st) != 0) { err = "DirectFile: cannot size " + path; close(); return false; }
|
||||
|
||||
Reference in new issue
Block a user