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/omega-mv/blob/main/seed/ng/bench/kernels/arith.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / bench / kernels / arith.c` 23 lines ยท 1081 bytes Raw Blame History 1 /* arith.c -- REFERENCE TWIN ONLY (gcc oracle) of kernels/arith.om: same loop, same output. */ 2 #include 3 #include 4 #include 5 static void putnum(uint64_t v) { printf("%llu\n", (unsigned long long)v); } 6 /* OMC-EFF-2: the computation is timed in process with CLOCK_MONOTONIC and the nanoseconds go to stderr. 7 The empty asm statements are compiler barriers: they keep the timed work between the two clock reads. */ 8 static uint64_t nowns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (uint64_t)t.tv_sec * 1000000000u + (uint64_t)t.tv_nsec; } 9 static void putns(uint64_t t0, uint64_t t1) { fprintf(stderr, "%llu\n", (unsigned long long)(t1 - t0)); } 10 int main(void) { 11 uint64_t t0 = nowns(); 12 uint64_t h = 0, s = 0; 13 __asm__ volatile("" : "+r"(h), "+r"(s)); 14 for (uint64_t i = 0; i < 40000000u; i++) { 15 h = h * 31u + i; 16 uint64_t t = (i * i) ^ (i >> 3); 17 s += t % 1000003u; 18 } 19 __asm__ volatile("" : : "r"(h), "r"(s) : "memory"); 20 putns(t0, nowns()); 21 putnum(h); putnum(s); 22 return 0; 23 }