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/matmul.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 / matmul.c` 36 lines ยท 1605 bytes Raw Blame History 1 /* matmul.c -- REFERENCE TWIN ONLY (gcc oracle) of kernels/matmul.om: same matrices, 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 static uint64_t ma[90000], mb[90000], mc[90000]; 11 int main(void) { 12 uint64_t t0 = nowns(); 13 __asm__ volatile("" : : : "memory"); 14 for (uint64_t i = 0; i < 300; i++) 15 for (uint64_t j = 0; j < 300; j++) { 16 ma[i * 300 + j] = (i + j * 2) % 13; 17 mb[i * 300 + j] = (i * 3 + j) % 11; 18 } 19 for (uint64_t i = 0; i < 300; i++) { 20 uint64_t r = i * 300; 21 for (uint64_t j = 0; j < 300; j++) { 22 uint64_t s = 0, q = j; 23 for (uint64_t k = 0; k < 300; k++) { s += ma[r + k] * mb[q]; q += 300; } 24 mc[r + j] = s; 25 } 26 } 27 uint64_t tot = 0, tr = 0; 28 for (uint64_t i = 0; i < 300; i++) { 29 for (uint64_t j = 0; j < 300; j++) tot += mc[i * 300 + j]; 30 tr += mc[i * 301]; 31 } 32 __asm__ volatile("" : : "r"(tot), "r"(tr) : "memory"); 33 putns(t0, nowns()); 34 putnum(tot); putnum(tr); 35 return 0; 36 }