Skip to content
Projets

À propos

CUDA compiler and runtime for Apple Silicon

Langages et environnements d’exécution

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
+4
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

CuMetal

CuMetal is a CUDA compiler and runtime for Apple Silicon. It compiles supported CUDA C++ and PTX into Metal kernels, so you can run existing CUDA code on your Mac’s GPU without rewriting it in Metal.

The project is experimental and supports a tested subset of CUDA and its libraries. See verified results for what runs today and known gaps for the remaining limits.

The LAMMPS/Kokkos GPU demo compiles unmodified LAMMPS and passes the stock 32,000-atom, 100-step full/half-neighbour numerical gate. See demos for more workloads.

Install

Requires Apple Silicon and macOS 14 or newer. See the installation guide for compiler and Apple toolchain requirements.

brew install lulzx/tap/cumetal
cumetal doctor

If cumetal doctor reports a missing or placeholder Metal toolchain, see checking the toolchain.

Compile and run your CUDA source:

cumetalc kernel.cu -o kernel
./kernel

Build from source

FP64 arithmetic comes from the third_party/VF64-metal submodule; initialize it with git submodule update --init --recursive.

From a checkout with the build prerequisites installed:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j"$(sysctl -n hw.ncpu)"

build/cumetalc samples/vectorAdd/vectorAdd.cu -o vectorAdd
./vectorAdd

See testing for validation commands.

How it works

CUDA C++ / PTX → CuMetal compiler → Metal Shading Language → Apple tools → metallib
  • Direct CUDA C++, compiled ahead of time. cumetalc compiles CUDA C++ through typed CuMetal IR and embeds the Metal library in the executable, so there is no first-launch PTX JIT. CuMetal uses no private Apple APIs.
  • PTX import with SSA and pointer-provenance recovery. PTX registers become typed SSA values, and addresses stay real pointers in their Metal address space. Bounded proofs recover pointer arithmetic; a Metal pointer is never turned into an integer, and what cannot be proved is rejected, not guessed.
  • FP64 emulation with VF64-metal. Apple GPUs have no native FP64. double runs in a selectable emulation mode: fast48 by default, ieee64 for correctly rounded results (FP64 policy).
  • 64-bit atomics and scoped memory (Metal 3.2+). Typed lock-backed 64-bit atomics use device-coherent payload pointers and device fences, covering binary64 atomicAdd and cross-block scan descriptors.

The proof rules behind the PTX path are in the "PTX memory proof rules" section of compiler architecture; known gaps lists memory-provenance and legacy-backend limits.

Limits

  • CUDA and library APIs are tested subsets, not drop-in replacements.
  • SASS execution is unsupported. The optional binary shim is disabled in Release builds unless explicitly enabled.
  • SIMD/warp width is fixed at 32. Multi-GPU, peer access, and graphics-API interop are unsupported.
  • FP64 uses emulation with mode-dependent precision; it is not native Metal FP64.
  • Cooperative grids, dynamic launch, graphs, and textures have bounded or incomplete support. See known gaps for exact limits.
  • Device pointers the host writes directly into managed or mapped memory, or passes as plain integers, need CUMETAL_USE_METAL_DEVICE_ADDRESSES=1, which serializes work across streams. Pointers stored by kernels or copied in with cudaMemcpy* need nothing (details).

Documentation

License

Apache 2.0 · Legal notice

Explorer des projets similaires

Chargement…