omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / src / omega_gpu_platform_linux.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* omega_gpu_platform_linux.h -- the Linux REFERENCE implementation of OmegaGpuPlatform (ABI 1.1). |
| 18 | * |
| 19 | * REFERENCE ONLY (native v1 P07 cut C, session part; aienos#286). This is today's GB10 path under Linux |
| 20 | * (physics nvrm + m16_native, the open NVIDIA kernel driver), wrapped in the platform contract so the |
| 21 | * portable session (src/omega_gpu_session.c) runs the same launch words it always ran. It is NOT the |
| 22 | * native platform and is not part of the freestanding closure: it includes Linux headers, takes pthread |
| 23 | * mutexes, reads CLOCK_MONOTONIC and calls malloc. The AIENOS platform implements the same table over its |
| 24 | * own device ownership (cut B); nothing in the session may depend on anything this file does beyond the |
| 25 | * contract in src/omega_gpu_platform.h. |
| 26 | * |
| 27 | * What it provides: TIME, WAIT, LOCK, DMA, SYNC, COMPLETION (polling: m16_native_wait_marker, a 50 us |
| 28 | * sleep-poll), DEVICE, QUEUE, CLOCK_NS, HOST_MEM. Not MMIO (the RM driver owns the registers) and not IRQ |
| 29 | * (polling is never claimed as interrupt support). One device (ordinal 0), one queue (the m16 channel, |
| 30 | * GPFIFO entries carrying the method words copied into the BUF_QUEUE ring), every buffer GPU-uncached |
| 31 | * (nvrm_alloc_gpu_uncached; a GPU_CACHED request is refused with REFUSED_CACHE_POLICY because nothing here |
| 32 | * would flush it). The bus address is reported as 0: the RM driver owns the IOMMU mapping and does not |
| 33 | * expose it. Closing the device makes every buffer and queue handle of it stale (generation bump); the RM |
| 34 | * client close releases the driver objects, as the session always did. |
| 35 | * |
| 36 | * Tested by tests/test_omega_gpu_platform_linux.c on the simulated driver (tests/fake_m16_native.c); |
| 37 | * GB10 execution through it is the same driver calls as before this cut and is NOT re-run here. |
| 38 | */ |
| 39 | #ifndef OMEGA_GPU_PLATFORM_LINUX_H |
| 40 | #define OMEGA_GPU_PLATFORM_LINUX_H |
| 41 | |
| 42 | #include "omega_gpu_platform.h" |
| 43 | |
| 44 | #ifdef __cplusplus |
| 45 | extern "C" { |
| 46 | #endif |
| 47 | |
| 48 | #define OMEGA_GPU_PLATFORM_LINUX_LOCKS 4u /* lock ids 0..3 */ |
| 49 | |
| 50 | /* The process-wide Linux reference platform and its caps (written to *caps when caps is not NULL). */ |
| 51 | const OmegaGpuPlatform *omega_gpu_platform_linux(OmegaGpuPlatformCaps *caps); |
| 52 | |
| 53 | /* L136: channels (GPFIFO queues) the next device_open creates, from env AIEN_OMEGA_GPU_CHANNELS: 1 (unset, empty, "1" or |
| 54 | * anything not 2..4) is today's single channel exactly; 2..4 adds that many minus one channels in the same channel group |
| 55 | * (nvrm_channel_n). Queue i (0-based, in queue_open order) submits on channel i. Read at every device_open. */ |
| 56 | uint32_t omega_gpu_platform_linux_channels_env(void); |
| 57 | |
| 58 | #ifdef __cplusplus |
| 59 | } |
| 60 | #endif |
| 61 | #endif |