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/CUDApp/blob/main/src/omega_codegen_rest_wire.h # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / src / omega_codegen_rest_wire.h` 132 lines · 5522 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #ifndef OMEGA_CODEGEN_REST_WIRE_H 3 #define OMEGA_CODEGEN_REST_WIRE_H 4 /* Memory-only adapters: widen fields without packing, then invoke the seeded unit. 5 * The root copies the input prefix before replacing it with IR records. */ 6 #include "cudapp_native.h" 7 #include "omega_gpu_om_ir.h" 8 #include "omega_blackwell_codegen_attn256.h" 9 #include "omega_blackwell_codegen_pattn256.h" 10 #include "omega_blackwell_codegen_router.h" 11 #include "omega_blackwell_codegen_gemm.h" 12 #include "omega_blackwell_codegen_bf16.h" 13 #include "omega_blackwell_codegen_qg.h" 14 static inline uint32_t omega_rest_attn256_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 15 void *words, uint64_t nw, void *metadata, uint64_t nm) { 16 uint64_t *w = words; 17 (void)c; 18 w[15] = a != 0; 19 w[16] = b != 0; 20 if (a) { 21 const OmegaDecodeAttn256Spec *s = (const OmegaDecodeAttn256Spec *)(uintptr_t)a; 22 w[0] = (uint64_t)s->depth; 23 w[1] = (uint64_t)(int64_t)s->mutant; 24 w[2] = (uint64_t)s->prep; 25 w[3] = (uint64_t)s->q_heads; 26 w[4] = (uint64_t)s->kv_heads; 27 w[5] = (uint64_t)s->q_per_cta; 28 w[6] = (uint64_t)s->multi; 29 } 30 return omega_cg_attn256(result, kind, 0, 0, 0, words, nw, metadata, nm); 31 } 32 static inline uint32_t omega_rest_pattn256_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 33 void *words, uint64_t nw, void *metadata, uint64_t nm) { 34 uint64_t *w = words; 35 (void)c; 36 w[15] = a != 0; 37 w[16] = b != 0; 38 if (a) { 39 const OmegaPrefillAttn256Spec *s = (const OmegaPrefillAttn256Spec *)(uintptr_t)a; 40 w[0] = (uint64_t)(int64_t)s->mutant; 41 w[1] = (uint64_t)s->q_heads; 42 w[2] = (uint64_t)s->kv_heads; 43 } 44 return omega_cg_pattn256(result, kind, 0, 0, 0, words, nw, metadata, nm); 45 } 46 static inline uint32_t omega_rest_router_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 47 void *words, uint64_t nw, void *metadata, uint64_t nm) { 48 uint64_t *w = words; 49 (void)c; 50 w[15] = a != 0; 51 w[16] = b != 0; 52 if (a) { 53 const OmegaRouterSpec *s = (const OmegaRouterSpec *)(uintptr_t)a; 54 w[0] = (uint64_t)s->warps; 55 w[1] = (uint64_t)s->depth; 56 w[2] = (uint64_t)(int64_t)s->mutant; 57 w[3] = (uint64_t)s->experts; 58 w[4] = (uint64_t)s->shared; 59 w[5] = (uint64_t)s->xstride; 60 w[6] = (uint64_t)s->lbstride; 61 } 62 return omega_cg_router(result, kind, 0, 0, 0, words, nw, metadata, nm); 63 } 64 static inline uint32_t omega_rest_gemm_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 65 void *words, uint64_t nw, void *metadata, uint64_t nm) { 66 uint64_t *w = words; 67 (void)c; 68 w[15] = a != 0; 69 w[16] = b != 0; 70 if (a) { 71 const OmegaFp8GemmSpec *s = (const OmegaFp8GemmSpec *)(uintptr_t)a; 72 w[0] = (uint64_t)s->k; 73 w[1] = (uint64_t)s->lane_bytes; 74 w[2] = (uint64_t)s->mt; 75 w[3] = (uint64_t)s->warps; 76 w[4] = (uint64_t)(int64_t)s->mutant; 77 w[5] = (uint64_t)s->rowmap; 78 } 79 return omega_cg_gemm(result, kind, 0, 0, 0, words, nw, metadata, nm); 80 } 81 static inline uint32_t omega_rest_bf16_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 82 void *words, uint64_t nw, void *metadata, uint64_t nm) { 83 uint64_t *w = words; 84 (void)c; 85 w[15] = a != 0; 86 w[16] = b != 0; 87 if (a) { 88 const OmegaBf16GemvSpec *s = (const OmegaBf16GemvSpec *)(uintptr_t)a; 89 w[0] = (uint64_t)s->k; 90 w[1] = (uint64_t)s->rows; 91 w[2] = (uint64_t)s->warps; 92 w[3] = (uint64_t)s->depth; 93 w[4] = (uint64_t)(int64_t)s->mutant; 94 w[5] = (uint64_t)s->ystride; 95 w[6] = (uint64_t)s->xbatch; 96 w[7] = (uint64_t)s->mask; 97 } 98 return omega_cg_bf16(result, kind, 0, 0, 0, words, nw, metadata, nm); 99 } 100 static inline uint32_t omega_rest_qg_wire(uint64_t *result, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 101 void *words, uint64_t nw, void *metadata, uint64_t nm) { 102 uint64_t *w = words; 103 (void)c; 104 w[15] = a != 0; 105 w[16] = b != 0; 106 if (a && kind <= 1) { 107 const OmegaPqSpec *s = (const OmegaPqSpec *)(uintptr_t)a; 108 w[0] = (uint64_t)s->k; 109 w[1] = (uint64_t)s->in_type; 110 w[2] = (uint64_t)(int64_t)s->mutant; 111 w[3] = (uint64_t)s->groups; 112 } else if (a) { 113 const OmegaQgSpec *s = (const OmegaQgSpec *)(uintptr_t)a; 114 w[0] = (uint64_t)s->k; 115 w[1] = (uint64_t)s->rt; 116 w[2] = (uint64_t)s->warps; 117 w[3] = (uint64_t)s->epi; 118 w[4] = (uint64_t)s->direct; 119 w[5] = (uint64_t)s->n; 120 w[6] = (uint64_t)s->wait; 121 w[7] = (uint64_t)(int64_t)s->mutant; 122 w[8] = (uint64_t)s->group; 123 } 124 return omega_cg_qg(result, kind, 0, 0, 0, words, nw, metadata, nm); 125 } 126 static inline int omega_rest_query(OmegaOmIrUnit unit, uint64_t kind, const void *spec, void *out, 127 uint64_t meta[OMEGA_OM_IR_META]) { 128 uint64_t wire[OMEGA_OM_IR_WORDS] = {0}, result = 0; 129 return unit(&result, kind, (uintptr_t)spec, (uintptr_t)out, 0, wire, OMEGA_OM_IR_WORDS, 130 meta, OMEGA_OM_IR_META) == OMEGA_OK && result == 0 ? 0 : -1; 131 } 132 #endif