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
CUDApp / om / cache / artifact.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Concatenate QuantSchema quant.om, Composer realize.om, and cache digest.om before this unit. |
| 3 | note Portable storage remains omega_native_artifact export/admit. No second manifest or identity schema. |
| 4 | note Cache key is SHA256 of Composer exact canonical used bytes, never structs or device addresses. |
| 5 | note Caller owns immutable admitted bytes; session-resident handle policy is residency.om. |
| 6 | note -1 invalid bounds, -10 canonical realization refusal, -11 code id, -12 launch id, -13 store key. |
| 7 | fn kc_equal a view uchar 32 b view uchar 32 to bool |
| 8 | for i ulong 32 |
| 9 | if ne get a i get b i |
| 10 | ret false |
| 11 | end |
| 12 | end |
| 13 | ret true |
| 14 | end |
| 15 | fn kc_key rec view uchar 4096 n ulong out edit uchar 32 to int |
| 16 | if ne compose_check rec n 0 |
| 17 | ret -10 |
| 18 | end |
| 19 | ret kc_sha rec n out |
| 20 | end |
| 21 | note sizes4 = canonical used bytes, encoded code used bytes, canonical relocatable launch used bytes, reserved0. |
| 22 | note Validate every immutable payload on read; a filename or prior validation is not admission. |
| 23 | fn kc_validate rec view uchar 4096 sizes view ulong 4 code view uchar 16384 launch view uchar 4096 expected view uchar 32 out edit uchar 32 to int |
| 24 | hash = new uchar 32 0 |
| 25 | if or eq get sizes 1 0 gt get sizes 1 16384 |
| 26 | ret -1 |
| 27 | end |
| 28 | if or eq get sizes 2 0 gt get sizes 2 4096 |
| 29 | ret -1 |
| 30 | end |
| 31 | if ne get sizes 3 0 |
| 32 | ret -1 |
| 33 | end |
| 34 | if ne compose_check rec get sizes 0 0 |
| 35 | ret -10 |
| 36 | end |
| 37 | if ne compose_launchread rec launch get sizes 2 0 |
| 38 | ret -12 |
| 39 | end |
| 40 | if ne kc_codesha code get sizes 1 hash 0 |
| 41 | ret -1 |
| 42 | end |
| 43 | if not compose_codeid rec hash |
| 44 | ret -11 |
| 45 | end |
| 46 | if ne kc_sha launch get sizes 2 hash 0 |
| 47 | ret -1 |
| 48 | end |
| 49 | if not compose_launchid rec hash |
| 50 | ret -12 |
| 51 | end |
| 52 | if ne kc_sha rec get sizes 0 hash 0 |
| 53 | ret -1 |
| 54 | end |
| 55 | if not kc_equal hash expected |
| 56 | ret -13 |
| 57 | end |
| 58 | for i ulong 32 |
| 59 | put out i get hash i |
| 60 | end |
| 61 | ret 0 |
| 62 | end |
| 63 | fn kc_request rec view uchar 4096 n ulong req edit ulong 16 to int |
| 64 | hash = new uchar 32 0 |
| 65 | if ne kc_key rec n hash 0 |
| 66 | ret -10 |
| 67 | end |
| 68 | for i ulong 4 |
| 69 | word = ulong 0 |
| 70 | for j ulong 8 |
| 71 | word = or word shl ulong get hash add mul i 8 j mul j 8 |
| 72 | end |
| 73 | put req add 3 i word |
| 74 | end |
| 75 | ret 0 |
| 76 | end |