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 / omega_gpu_platform_linux_rest_oracle.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* Migration oracle only; production must not include this header. */ |
| 3 | #ifndef OMEGA_GPU_PLATFORM_LINUX_REST_ORACLE_H |
| 4 | #define OMEGA_GPU_PLATFORM_LINUX_REST_ORACLE_H |
| 5 | #include <stdint.h> |
| 6 | static uint64_t plat_rest_c(uint64_t mode, const uint64_t m[16], uint64_t q[16]) { |
| 7 | switch (mode) { |
| 8 | case 0: { |
| 9 | uint64_t pages=(m[0]+4095ull)&~4095ull, cursor=m[1]; |
| 10 | if(pages<4096ull || pages>(1ull<<40)) return 0; |
| 11 | if(cursor<65536ull || cursor>(1ull<<40)-pages) cursor=268435456ull; |
| 12 | if(cursor>(1ull<<40)-pages) return 0; |
| 13 | q[0]=pages; q[1]=cursor; q[2]=cursor+pages; return 1; |
| 14 | } |
| 15 | case 1: { |
| 16 | const unsigned first = m[1]=='/' ? 2 : 1; |
| 17 | const unsigned need = first==2 ? 7 : 6; |
| 18 | const char *prefix="memfd:"; |
| 19 | if(m[0]<need) return 0; |
| 20 | for(unsigned i=0;i<6;++i) if(m[first+i]!=(unsigned char)prefix[i]) return 0; |
| 21 | return 1; |
| 22 | } |
| 23 | case 2: |
| 24 | if(m[0]>=m[5] || m[1]==0) return 5; |
| 25 | if(!m[2] || m[3]!=m[1]) return 6; |
| 26 | if(m[4]!=2 && m[4]!=3 && m[4]!=4) return 5; |
| 27 | return 0; |
| 28 | case 3: return m[0]*1000000000ull+m[1]; |
| 29 | case 4: q[0]=m[0]/1000u; q[1]=(m[0]%1000u)*1000000ull; return 0; |
| 30 | case 5: return m[0]>=m[1] ? 1 : 0; |
| 31 | case 6: |
| 32 | for(unsigned i=0;i<3 && i+1<m[0];++i) if(!m[i+1]) return i+1; |
| 33 | return 0; |
| 34 | case 7: return m[0]!=0 ? 1 : m[1]!=0 ? 11 : 0; |
| 35 | case 8: return m[0] ? 5 : 0; |
| 36 | case 9: return m[0]/1000000ull; |
| 37 | case 10: q[0]=m[0]*4; q[1]=(m[0]+m[1])*4; q[2]=m[0]+m[1]; return 0; |
| 38 | case 11: return (uint32_t)(m[0]+1); |
| 39 | case 12: return m[0] && m[1] && (int64_t)m[2]>=0 && (m[3]&m[4]) && !(m[3]&m[5]); |
| 40 | case 13: return m[0] ? m[0] : 1; |
| 41 | default: return 0; |
| 42 | } |
| 43 | } |
| 44 | #endif |