Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/omega_numeric_lifecycle.h # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / omega_numeric_lifecycle.h` 47 lines ยท 2084 bytes Raw Blame History 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 #ifndef OMEGA_NUMERIC_LIFECYCLE_H 18 #define OMEGA_NUMERIC_LIFECYCLE_H 19 20 #include 21 22 /* One owner across the SIMT, reduction and DIV/SQRT launchers. Defined in 23 * omega_numeric.c, which all three already link. No reset API: an uncertain 24 * completion requires ending the process and investigating the device. This 25 * does not assert that process exit itself resets or recovers the GPU. */ 26 enum { OMEGA_NUMERIC_NATIVE_IDLE, OMEGA_NUMERIC_NATIVE_BUSY, 27 OMEGA_NUMERIC_NATIVE_UNCERTAIN }; 28 extern atomic_int omega_numeric_native_state; 29 30 static inline int omega_numeric_native_acquire(void) { 31 int expected = OMEGA_NUMERIC_NATIVE_IDLE; 32 return atomic_compare_exchange_strong(&omega_numeric_native_state, &expected, 33 OMEGA_NUMERIC_NATIVE_BUSY) ? 0 : -1; 34 } 35 static inline int omega_numeric_native_uncertain(void) { 36 return atomic_load(&omega_numeric_native_state) == OMEGA_NUMERIC_NATIVE_UNCERTAIN; 37 } 38 static inline void omega_numeric_native_poison(void) { 39 atomic_store(&omega_numeric_native_state, OMEGA_NUMERIC_NATIVE_UNCERTAIN); 40 } 41 static inline void omega_numeric_native_release(void) { 42 int expected = OMEGA_NUMERIC_NATIVE_BUSY; 43 /* Never clear a poison latch, even if a cleanup caller arrives late. */ 44 (void)atomic_compare_exchange_strong(&omega_numeric_native_state, &expected, 45 OMEGA_NUMERIC_NATIVE_IDLE); 46 } 47 #endif