diff --git a/metal/include/metal_compat/cublas_v2.h b/metal/include/metal_compat/cublas_v2.h index dfc87e74..50a966fd 100644 --- a/metal/include/metal_compat/cublas_v2.h +++ b/metal/include/metal_compat/cublas_v2.h @@ -19,6 +19,7 @@ enum cublasStatus_t { CUBLAS_STATUS_SUCCESS = 0, CUBLAS_STATUS_NOT_INITIALIZED = CUBLAS_STATUS_INVALID_VALUE = 7, CUBLAS_STATUS_ARCH_MISMATCH = 8, CUBLAS_STATUS_NOT_SUPPORTED = 14 }; enum cublasOperation_t { CUBLAS_OP_N = 0, CUBLAS_OP_T = 1, CUBLAS_OP_C = 2 }; enum cublasComputeType_t { CUBLAS_COMPUTE_16F = 64, CUBLAS_COMPUTE_32F = 68, CUBLAS_COMPUTE_32F_FAST_16F = 74 }; +enum cublasGemmAlgo_t { CUBLAS_GEMM_DEFAULT = -1, CUBLAS_GEMM_DEFAULT_TENSOR_OP = 99 }; enum cudaDataType_t { CUDA_R_32F = 0, CUDA_R_16F = 2, CUDA_R_16BF = 14, CUDA_R_8F_E4M3 = 28 }; static inline cublasStatus_t cublasCreate(cublasHandle_t* h) { @@ -43,9 +44,9 @@ static inline cublasStatus_t cublasSgemm(cublasHandle_t, cublasOperation_t, cubl strata_metal_dense_gemm_missing("cublasSgemm"); } -// the mixed-precision form: the engine passes a compute type and a scale; on Metal the kernels read A/B by their own type -static inline cublasStatus_t cublasGemmEx(cublasHandle_t, cublasOperation_t, cublasOperation_t, int, int, int, - const void*, const void*, cudaDataType_t, int, const void*, cudaDataType_t, int, - const void*, void*, cudaDataType_t, cublasComputeType_t, int) { +// the mixed-precision form: any argument list, because the engine passes cuBLAS's full 19-argument spelling; the body +// names kernels/dense_mm.metal, which is where the real implementation goes. +template +static inline cublasStatus_t cublasGemmEx(A...) { strata_metal_dense_gemm_missing("cublasGemmEx"); } diff --git a/metal/include/metal_compat/cuda_runtime.h b/metal/include/metal_compat/cuda_runtime.h index dca9b6a7..04dd1949 100644 --- a/metal/include/metal_compat/cuda_runtime.h +++ b/metal/include/metal_compat/cuda_runtime.h @@ -1,3 +1,31 @@ +// The CUDA function-space qualifiers and the few launch/kernel spellings the shared sources use. On Metal they say +// nothing: a "kernel" here is an MSL function compiled at run time and dispatched by the host runtime, so the qualifiers +// are empty and __forceinline__ is plain inline. Part of the metal_compat layer (M5 Max, 2026-10-23). +#ifndef __host__ +#define __host__ +#endif +#ifndef __device__ +#define __device__ +#endif +#ifndef __global__ +#define __global__ +#endif +#ifndef __shared__ +#define __shared__ +#endif +#ifndef __constant__ +#define __constant__ +#endif +#ifndef __forceinline__ +#define __forceinline__ inline +#endif +#ifndef __launch_bounds__ +#define __launch_bounds__(...) +#endif +#ifndef __restrict__ +#define __restrict__ +#endif + // metal/include/metal_compat/cuda_runtime.h - the CUDA runtime names the host files use, on Metal. // // The HIP build's approach (include/strata/hip_compat/cuda_runtime.h maps every cudaX the host code calls to hipX), @@ -141,3 +169,10 @@ inline cudaError_t cudaGraphLaunch(cudaGraphExec_t x, cudaStream_t s) { return s inline cudaError_t cudaGraphUpload(cudaGraphExec_t x, cudaStream_t s) { return strata::gpu::graph_upload(x, s); } inline cudaError_t cudaGraphDestroy(cudaGraph_t g) { return strata::gpu::graph_destroy(g); } inline cudaError_t cudaGraphExecDestroy(cudaGraphExec_t x) { return strata::gpu::graph_exec_destroy(x); } + +// cudaMemcpy2D(dst, dpitch, src, spitch, width, height, kind): a strided copy, used by the vision tower's patch rows and +// the Engram tables' column slices. The Metal runtime has no pitched copy yet, so this reports failure rather than +// copying nothing silently. +inline strata::gpu::Error cudaMemcpy2D(void*, size_t, const void*, size_t, size_t, size_t, strata::gpu::CopyKind) { + return strata::gpu::kErrorUnsupported; // cudaMemcpy2D_unimplemented_marker +} diff --git a/src/dsv41/ds4_os_apple.h b/src/dsv41/ds4_os_apple.h index 37eb664e..c670a539 100644 --- a/src/dsv41/ds4_os_apple.h +++ b/src/dsv41/ds4_os_apple.h @@ -46,6 +46,10 @@ static inline long syscall(long, ...) { return -1; } // CPU affinity: macOS schedules on its own; the engine only uses this to pin the token thread. No-op, reported as success. typedef struct { unsigned long __bits[16]; } cpu_set_t; +#ifndef CPU_ZERO +#define CPU_ZERO(set) ((void) (set)) +#define CPU_SET(cpu, set) ((void) (set)) +#endif static inline int sched_setaffinity(pid_t, size_t, const cpu_set_t*) { return 0; } static inline int pthread_setaffinity_np(pthread_t, size_t, const cpu_set_t*) { return 0; }