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

+3 -1
View File
@@ -92,8 +92,10 @@
#include <unistd.h>
#include <cerrno>
#include <sys/stat.h>
#if !defined(__APPLE__) // major() / minor(): <sys/types.h> on macOS
#include <sys/sysmacros.h>
#endif
#endif
#include <cuda_runtime.h>
@@ -4651,7 +4653,7 @@ int main(int argc, char** argv) {
std::fprintf(stderr, "strata generate: GPU %d: %s, compute capability %d.%d%s\n", dev, name,
strata::cc_major_of(p.major), strata::cc_minor_of(p.minor),
strata::emulated_cc() ? " (STRATA_EMULATE_CC: a test mode, the card is emulated)" : "");
#if !defined(STRATA_HIP_GFX906) // a CUDA toolkit mismatch; the gfx906 HIP build has no CUDART_VERSION
#if !defined(STRATA_HIP_GFX906) && !defined(STRATA_GPU_METAL) // a CUDA toolkit mismatch; the gfx906 HIP build has no CUDART_VERSION
{ // #542: a build whose libcudart is older than its headers (a CUDA 13 kit with a dangling libcudart.so that
// CMake resolved to the system's CUDA 12 one) reads cudaDeviceProp shifted - silently, and slowly
int rt = 0;