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
CUDApp / src / cudapp_freest_epoch.c
| 1 | /* Omega Bridge portable nontrapping scalar profile. No host runtime. */ |
| 2 | #include <stdint.h> |
| 3 | #if defined(__GNUC__) |
| 4 | #pragma GCC diagnostic push |
| 5 | #pragma GCC diagnostic ignored "-Wunused-function" |
| 6 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
| 7 | #pragma GCC diagnostic ignored "-Wunused-variable" |
| 8 | #endif |
| 9 | static unsigned ombr_fs_width(unsigned t){static const unsigned w[]={0,1,8,16,32,64,8,16,32,64};return w[t];} |
| 10 | static int ombr_fs_valid(unsigned t,uint64_t v){unsigned w=ombr_fs_width(t);if(t<6)return w==64||v<((uint64_t)1<<w);if(w==64)return 1;uint64_t m=(uint64_t)1<<(w-1);return v<m||v>=UINT64_MAX-m+1;} |
| 11 | static uint64_t ombr_fs_op(unsigned op,unsigned t,uint64_t a,uint64_t b){unsigned w=ombr_fs_width(t);uint64_t mask=UINT64_MAX>>(64-w);if(op>=6&&op<=11){uint64_t x=a,y=b;if(t>=6){x^=(uint64_t)1<<63;y^=(uint64_t)1<<63;}switch(op){case 6:return x==y;case 7:return x!=y;case 8:return x<y;case 9:return x<=y;case 10:return x>y;default:return x>=y;}}switch(op){case 1:return (a+b)&mask;case 2:return (a-b)&mask;case 3:return (a*b)&mask;case 12:return a&b;case 13:return a|b;case 14:return a^b;case 15:return (a<<b)&mask;case 16:return a>>b;case 17:return (0-a)&mask;default:return t==1?!a:t>=6?~a:(~a)&mask;}} |
| 12 | static uint64_t f0(uint64_t v0); |
| 13 | static uint64_t f0(uint64_t v0){ |
| 14 | if(ombr_fs_op(6, 5, v0, 18446744073709551615ULL)){ |
| 15 | return 18446744073709551615ULL; |
| 16 | } |
| 17 | return ombr_fs_op(1, 5, v0, 1ULL); |
| 18 | } |
| 19 | uint32_t omega_native_epoch(uint64_t *result, uint64_t p0){ |
| 20 | if(!result || (uintptr_t)result%_Alignof(uint64_t) || (uintptr_t)result>UINTPTR_MAX-sizeof(uint64_t))return 32; |
| 21 | if(!ombr_fs_valid(5, p0))return 32; |
| 22 | *result=f0(p0); |
| 23 | return 0; |
| 24 | } |
| 25 | #if defined(__GNUC__) |
| 26 | #pragma GCC diagnostic pop |
| 27 | #endif |