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/CUDApp/blob/main/tests/runtime/cm_oracle.c # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / runtime / cm_oracle.c` 79 lines · 3314 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #define omega_cm_math oracle_cm_math_trace 3 #define CUDAPP_MIGRATION_PENDING_C_CM_SORT 1 4 /* Omega's per-operation binary64 and first-party libm are canonical. This 5 * retained C algorithm is compiled with -ffp-contract=off; its math calls bind 6 * the same canonical routines. cm_math_unit independently measures glibc drift. */ 7 #define CUDAPP_MIGRATION_PENDING_C_CM_MATH 0 8 #define CUDAPP_MIGRATION_PENDING_C_CM_FIT 1 9 #define CUDAPP_MIGRATION_PENDING_C_CM_STATS 1 10 #define CUDAPP_MIGRATION_PENDING_C_CM_FEATURES 1 11 #define CUDAPP_MIGRATION_PENDING_C_CM_QUANTILE 1 12 #define CUDAPP_MIGRATION_PENDING_C_CM_DECISION 1 13 #define rx_cm_t_quantile oracle_cm_t_quantile 14 #define CUDAPP_MIGRATION_PENDING_C_CM_PREDICTION 1 15 #define CUDAPP_MIGRATION_PENDING_C_CM_CALIBRATION 1 16 #define CUDAPP_MIGRATION_PENDING_C_CM_BLOB 1 17 #define CUDAPP_MIGRATION_PENDING_C_CM_DIGEST 1 18 #define CUDAPP_MIGRATION_PENDING_C_CM_ROUTE 1 19 #define rx_cm_default_policy oracle_cm_default_policy 20 #define rx_cm_init oracle_cm_init 21 #define rx_cm_observe oracle_cm_observe 22 #define rx_cm_predict oracle_cm_predict 23 #define rx_cm_decide oracle_cm_decide 24 #define rx_cm_calibrate oracle_cm_calibrate 25 #define rx_cm_charge oracle_cm_charge 26 #define rx_cm_blob_size oracle_cm_blob_size 27 #define rx_cm_serialize oracle_cm_serialize 28 #define rx_cm_deserialize oracle_cm_deserialize 29 #define rx_cm_digest oracle_cm_digest 30 #define rx_cm_basis oracle_cm_basis 31 #define rx_cm_cell oracle_cm_cell 32 #include "../../src/runtime/rx_costmodel.c" 33 #undef omega_cm_math 34 #undef log 35 #undef log2 36 #undef ceil 37 #undef exp 38 #undef exp2 39 #undef sqrt 40 #undef erfc 41 #undef fabs 42 #include 43 uint32_t omega_cm_math(uint64_t *, uint64_t, uint64_t); 44 static uint64_t math_calls[8], math_ulp[8], math_input[8], math_got[8], math_reference[8]; 45 uint32_t oracle_cm_math_trace(uint64_t *result, uint64_t mode, uint64_t input) { 46 uint32_t status=omega_cm_math(result,mode,input); 47 if (status!=OMEGA_OK || mode>=8) return status; 48 double x, reference; 49 memcpy(&x,&input,sizeof x); 50 switch (mode) { 51 case 0: reference=log(x); break; 52 case 1: reference=log2(x); break; 53 case 2: reference=ceil(x); break; 54 case 3: reference=exp(x); break; 55 case 4: reference=exp2(x); break; 56 case 5: reference=sqrt(x); break; 57 case 6: reference=erfc(x); break; 58 default: reference=fabs(x); break; 59 } 60 uint64_t bits; 61 memcpy(&bits,&reference,sizeof bits); 62 uint64_t a=*result, b=bits; 63 a=a>>63 ? ~a : a|UINT64_C(0x8000000000000000); 64 b=b>>63 ? ~b : b|UINT64_C(0x8000000000000000); 65 uint64_t distance=a>b ? a-b : b-a; 66 ++math_calls[mode]; 67 if (distance>math_ulp[mode]) { 68 math_ulp[mode]=distance; math_input[mode]=input; 69 math_got[mode]=*result; math_reference[mode]=bits; 70 } 71 return status; 72 } 73 static void __attribute__((destructor)) report_math_inputs(void) { 74 for (unsigned mode=0;mode<8;++mode) if (math_calls[mode]) 75 printf("CM LIBM actual-inputs mode=%u calls=%llu max_ulp=%llu input=%016llx candidate=%016llx glibc=%016llx\n", 76 mode,(unsigned long long)math_calls[mode],(unsigned long long)math_ulp[mode], 77 (unsigned long long)math_input[mode],(unsigned long long)math_got[mode], 78 (unsigned long long)math_reference[mode]); 79 }