CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 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_VECTOR_H |
| 18 | #define OMEGA_VECTOR_H |
| 19 | |
| 20 | #include "omega_types.h" |
| 21 | #include <stdbool.h> |
| 22 | #include <stddef.h> |
| 23 | #include <stdint.h> |
| 24 | |
| 25 | /* Poison value used to verify buffers are truly written by device execution */ |
| 26 | #define OMEGA_VECTOR_POISON_VALUE 0xdeadbeefU |
| 27 | |
| 28 | typedef struct { |
| 29 | SemanticId spec_id; |
| 30 | char name[64]; |
| 31 | TypeTag element_type; |
| 32 | uint16_t element_width; |
| 33 | uint32_t element_count; |
| 34 | OverflowPolicy overflow; |
| 35 | uint8_t spec_digest[32]; |
| 36 | } OmegaVectorSpec; |
| 37 | |
| 38 | /* Initialize an OmegaVectorSpec for 32-bit unsigned addition modulo 2^32 */ |
| 39 | int omega_vector_spec_init(OmegaVectorSpec *spec, const char *name, uint32_t n); |
| 40 | |
| 41 | /* Machine-independent semantic oracle: C[i] = (A[i] + B[i]) mod 2^32 */ |
| 42 | void omega_vector_oracle_u32(const uint32_t *a, const uint32_t *b, uint32_t *c, uint32_t n); |
| 43 | |
| 44 | /* Compare device output with semantic oracle. Returns 0 on exact match, -1 on mismatch */ |
| 45 | int omega_vector_verify_oracle(const uint32_t *a, const uint32_t *b, const uint32_t *actual_c, |
| 46 | uint32_t n, size_t *first_mismatch_idx); |
| 47 | |
| 48 | /* Populate deterministic fixed inputs A and B, initialize C with poison pattern */ |
| 49 | void omega_vector_generate_deterministic(uint32_t *a, uint32_t *b, uint32_t *c_poison, uint32_t n); |
| 50 | |
| 51 | /* Construct canonical OmegaGraph representation of the vector addition specification */ |
| 52 | int omega_vector_build_spec_graph(OmegaGraph *g, uint32_t n, SemanticId *out_spec_id); |
| 53 | |
| 54 | #endif /* OMEGA_VECTOR_H */ |