interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / evidence / 2026-11-06-costmodel-rest / cm_oracle.c.gcov

111 lines · 5568 bytes Raw Blame History
1 -: 0:Source:tests/runtime/cm_oracle.c
2 -: 0:Graph:/tmp/cm-full-cov-v5qvhlky/oracle.gcno
3 -: 0:Data:/tmp/cm-full-cov-v5qvhlky/oracle.gcda
4 -: 0:Runs:2
5 -: 1:/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
6 -: 2:#define omega_cm_math oracle_cm_math_trace
7 -: 3:#define CUDAPP_MIGRATION_PENDING_C_CM_SORT 1
8 -: 4:/* Omega's per-operation binary64 and first-party libm are canonical. This
9 -: 5: * retained C algorithm is compiled with -ffp-contract=off; its math calls bind
10 -: 6: * the same canonical routines. cm_math_unit independently measures glibc drift. */
11 -: 7:#define CUDAPP_MIGRATION_PENDING_C_CM_MATH 0
12 -: 8:#define CUDAPP_MIGRATION_PENDING_C_CM_FIT 1
13 -: 9:#define CUDAPP_MIGRATION_PENDING_C_CM_STATS 1
14 -: 10:#define CUDAPP_MIGRATION_PENDING_C_CM_FEATURES 1
15 -: 11:#define CUDAPP_MIGRATION_PENDING_C_CM_QUANTILE 1
16 -: 12:#define CUDAPP_MIGRATION_PENDING_C_CM_DECISION 1
17 -: 13:#define rx_cm_t_quantile oracle_cm_t_quantile
18 -: 14:#define CUDAPP_MIGRATION_PENDING_C_CM_PREDICTION 1
19 -: 15:#define CUDAPP_MIGRATION_PENDING_C_CM_CALIBRATION 1
20 -: 16:#define CUDAPP_MIGRATION_PENDING_C_CM_BLOB 1
21 -: 17:#define CUDAPP_MIGRATION_PENDING_C_CM_DIGEST 1
22 -: 18:#define CUDAPP_MIGRATION_PENDING_C_CM_ROUTE 1
23 -: 19:#define rx_cm_default_policy oracle_cm_default_policy
24 -: 20:#define rx_cm_init oracle_cm_init
25 -: 21:#define rx_cm_observe oracle_cm_observe
26 -: 22:#define rx_cm_predict oracle_cm_predict
27 -: 23:#define rx_cm_decide oracle_cm_decide
28 -: 24:#define rx_cm_calibrate oracle_cm_calibrate
29 -: 25:#define rx_cm_charge oracle_cm_charge
30 -: 26:#define rx_cm_blob_size oracle_cm_blob_size
31 -: 27:#define rx_cm_serialize oracle_cm_serialize
32 -: 28:#define rx_cm_deserialize oracle_cm_deserialize
33 -: 29:#define rx_cm_digest oracle_cm_digest
34 -: 30:#define rx_cm_basis oracle_cm_basis
35 -: 31:#define rx_cm_cell oracle_cm_cell
36 -: 32:#include "../../src/runtime/rx_costmodel.c"
37 -: 33:#undef omega_cm_math
38 -: 34:#undef log
39 -: 35:#undef log2
40 -: 36:#undef ceil
41 -: 37:#undef exp
42 -: 38:#undef exp2
43 -: 39:#undef sqrt
44 -: 40:#undef erfc
45 -: 41:#undef fabs
46 -: 42:#include <stdio.h>
47 -: 43:uint32_t omega_cm_math(uint64_t *, uint64_t, uint64_t);
48 -: 44:static uint64_t math_calls[8], math_ulp[8], math_input[8], math_got[8], math_reference[8];
49function oracle_cm_math_trace called 807499 returned 100% blocks executed 85%
50 807499: 45:uint32_t oracle_cm_math_trace(uint64_t *result, uint64_t mode, uint64_t input) {
51 807499: 46: uint32_t status=omega_cm_math(result,mode,input);
52call 0 returned 807499
53 807499*: 47: if (status!=OMEGA_OK || mode>=8) return status;
54branch 0 taken 807499 (fallthrough)
55branch 1 taken 0
56branch 2 taken 0 (fallthrough)
57branch 3 taken 807499
58 -: 48: double x, reference;
59 807499: 49: memcpy(&x,&input,sizeof x);
60 807499: 50: switch (mode) {
61branch 0 taken 0
62branch 1 taken 332606
63branch 2 taken 1
64branch 3 taken 14025
65branch 4 taken 20931
66branch 5 taken 411586
67branch 6 taken 28050
68branch 7 taken 300
69 #####: 51: case 0: reference=log(x); break;
70 332606: 52: case 1: reference=log2(x); break;
71 1: 53: case 2: reference=ceil(x); break;
72 14025: 54: case 3: reference=exp(x); break;
73 20931: 55: case 4: reference=exp2(x); break;
74 411586: 56: case 5: reference=sqrt(x); break;
75 28050: 57: case 6: reference=erfc(x); break;
76 300: 58: default: reference=fabs(x); break;
77 -: 59: }
78 -: 60: uint64_t bits;
79 807499: 61: memcpy(&bits,&reference,sizeof bits);
80 807499: 62: uint64_t a=*result, b=bits;
81 807499*: 63: a=a>>63 ? ~a : a|UINT64_C(0x8000000000000000);
82branch 0 taken 0 (fallthrough)
83branch 1 taken 807499
84 807499*: 64: b=b>>63 ? ~b : b|UINT64_C(0x8000000000000000);
85branch 0 taken 0 (fallthrough)
86branch 1 taken 807499
87 807499: 65: uint64_t distance=a>b ? a-b : b-a;
88branch 0 taken 1774 (fallthrough)
89branch 1 taken 805725
90 807499: 66: ++math_calls[mode];
91 807499: 67: if (distance>math_ulp[mode]) {
92branch 0 taken 5 (fallthrough)
93branch 1 taken 807494
94 5: 68: math_ulp[mode]=distance; math_input[mode]=input;
95 5: 69: math_got[mode]=*result; math_reference[mode]=bits;
96 -: 70: }
97 807499: 71: return status;
98 -: 72:}
99function report_math_inputs called 2 returned 100% blocks executed 100%
100 2: 73:static void __attribute__((destructor)) report_math_inputs(void) {
101 18: 74: for (unsigned mode=0;mode<8;++mode) if (math_calls[mode])
102branch 0 taken 7 (fallthrough)
103branch 1 taken 9
104branch 2 taken 16
105branch 3 taken 2 (fallthrough)
106 7: 75: printf("CM LIBM actual-inputs mode=%u calls=%llu max_ulp=%llu input=%016llx candidate=%016llx glibc=%016llx\n",
107 7: 76: mode,(unsigned long long)math_calls[mode],(unsigned long long)math_ulp[mode],
108 7: 77: (unsigned long long)math_input[mode],(unsigned long long)math_got[mode],
109 7: 78: (unsigned long long)math_reference[mode]);
110call 0 returned 7
111 2: 79:}