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 / tests / moe / incumbent.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* Verification oracle only: compile the actual incumbent pf_group unchanged. |
| 3 | * Function sections + linker GC exclude the rest of the graph; no GPU object is linked. */ |
| 4 | #include "../../src/omega_gpu_q36_graph.c" |
| 5 | int omega_gpu_fp8_tensor_entry(const OmegaGpuFp8Tensor *t, uint32_t expert, uint64_t *w, uint64_t *s) { |
| 6 | (void)t; *w = (uint64_t)expert * 256 + 4096; *s = *w + 128; return 0; |
| 7 | } |
| 8 | uint32_t moe_incumbent(uint32_t n, const uint32_t *ids, uint32_t *x, uint32_t *y, uint32_t *seg) { |
| 9 | OmegaGpuQ36Graph g; memset(&g, 0, sizeof g); |
| 10 | _Alignas(16) unsigned char mem[32768]; memset(mem, 0, sizeof mem); |
| 11 | g.pf.hb.cpu = mem; g.lo.lb_stride = 32; |
| 12 | g.pf.rlb = 0; g.pf.sgu = 4096; g.pf.sdn = 12288; |
| 13 | g.pf.sgu2 = 20480; g.pf.sdn2 = 20512; |
| 14 | g.pf.xmap = 20544; g.pf.ymap = 24672; |
| 15 | g.pf.xmap2 = 28800; g.pf.ymap2 = 29344; |
| 16 | memcpy(mem, ids, n * 8 * sizeof *ids); |
| 17 | uint32_t ns = pf_group(&g, 0, n, 0); |
| 18 | memcpy(x, mem + g.pf.xmap, n * 8 * sizeof *x); |
| 19 | memcpy(y, mem + g.pf.ymap, n * 8 * sizeof *y); |
| 20 | memcpy(x + n * 8, mem + g.pf.xmap2, n * sizeof *x); |
| 21 | memcpy(y + n * 8, mem + g.pf.ymap2, n * sizeof *y); |
| 22 | const Seg32 *s = (const Seg32 *)(mem + g.pf.sgu); |
| 23 | for (uint32_t j = 0; j < ns; j++) { |
| 24 | seg[j * 4] = (uint32_t)((s[j].w_va - 4096) / 256); |
| 25 | seg[j * 4 + 1] = s[j].row0; seg[j * 4 + 2] = s[j].cnt; seg[j * 4 + 3] = 0; |
| 26 | } |
| 27 | if (n) { seg[ns * 4] = 256; seg[ns * 4 + 1] = n * 8; seg[ns * 4 + 2] = n; seg[ns * 4 + 3] = 1; ns++; } |
| 28 | return ns; |
| 29 | } |