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/aienux/blob/main/native/kernel/x86/model/host_probe.c # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. 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 `aienux / native / kernel / x86 / model / host_probe.c` 52 lines ยท 2370 bytes Raw Blame History 1 /* Test-only file/ABI adapter. All inference executes the compiled Omega blob. */ 2 #define _POSIX_C_SOURCE 200809L 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 13 uint64_t host_saved_sp, host_vtable[32]; 14 unsigned host_trap_code; 15 extern void host_trap(void); 16 extern uint64_t omega_run(void *, const uint64_t *, uint32_t *, uint64_t, const uint32_t *); 17 static void *map(const char *path, size_t *len, int prot) { 18 int fd = open(path, O_RDONLY); struct stat st; 19 if (fd < 0 || fstat(fd, &st) || st.st_size < 1) { perror(path); exit(2); } 20 *len = st.st_size; 21 void *p = mmap(NULL, *len, prot, MAP_PRIVATE, fd, 0); close(fd); 22 if (p == MAP_FAILED) { perror("mmap"); exit(2); } 23 return p; 24 } 25 int main(int argc, char **argv) { 26 if (argc < 5) { fputs("probe RAW WEIGHTS NEW OUT [PROMPT_ID...]\n", stderr); return 2; } 27 size_t nc, nw; 28 void *code = map(argv[1], &nc, PROT_READ | PROT_EXEC); 29 const uint32_t *weights = map(argv[2], &nw, PROT_READ); 30 uint32_t *work = calloc(`1048576`, 4); 31 if (!work || nw % 4 || nw > `64000000` || nc > 131072) return 2; 32 uint64_t args[512] = {1, strtoul(argv[3], NULL, 10), nw / 4, 1}; 33 if (argc > 5) { 34 args[0] = argc - 5; 35 for (int i = 5; i < argc; i++) args[i - 2] = strtoul(argv[i], NULL, 10); 36 } 37 for (unsigned i = 0; i < 32; i++) host_vtable[i] = (uintptr_t)host_trap; 38 struct timespec a, b; clock_gettime(CLOCK_MONOTONIC, &a); 39 uint64_t bytes = omega_run(code, args, work, (args[0] + 3) * 8, weights); 40 clock_gettime(CLOCK_MONOTONIC, &b); 41 double elapsed = b.tv_sec - a.tv_sec + (b.tv_nsec - a.tv_nsec) / 1e9; 42 printf("OMEGA_MODEL trap=%u bytes=%llu tokens=%u elapsed=%.6f ids=", host_trap_code, 43 (unsigned long long)bytes, work[0], elapsed); 44 if (host_trap_code || work[0] > 32 || bytes != 4 * (16 + work[0])) { puts("REFUSED"); return 1; } 45 for (unsigned i = 0; i < work[0]; i++) printf("%s%u", i ? "," : "", work[16+i]); 46 puts(""); 47 if (work[1] + work[2] > `1048576`) return 2; 48 int f_fd = open(argv[4], O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); 49 FILE *f = f_fd < 0 ? NULL : fdopen(f_fd, "wb"); 50 if (!f || fwrite(work + work[1], 4, work[2], f) != work[2] || fclose(f)) return 2; 51 return 0; 52 }