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 / om / components / api_bf_plan.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | fn api_bf_plan mode ulong a edit ulong 16 to ulong |
| 3 | if eq mode 0 |
| 4 | k = get a 0 |
| 5 | ks = div k 256 |
| 6 | w = ulong 16 |
| 7 | d = ks |
| 8 | if ne d 0 |
| 9 | while or gt d 16 ne rem ks d 0 bound 65536 |
| 10 | d = sub d 1 |
| 11 | end |
| 12 | end |
| 13 | if or ne rem k mul 32 w 0 gt k mul 512 w |
| 14 | w = 32 |
| 15 | end |
| 16 | put a 8 ulong 1 |
| 17 | put a 9 w |
| 18 | put a 10 d |
| 19 | put a 11 ulong 96 |
| 20 | for i ulong 4 |
| 21 | if ne get a add i 1 0 |
| 22 | put a add i 8 get a add i 1 |
| 23 | end |
| 24 | end |
| 25 | ret 0 |
| 26 | end |
| 27 | if eq mode 1 |
| 28 | n = get a 0 |
| 29 | rows = get a 1 |
| 30 | warps = get a 2 |
| 31 | ctas = get a 3 |
| 32 | if or eq rows 0 eq warps 0 |
| 33 | ret 3 |
| 34 | end |
| 35 | if ne rem n rows 0 |
| 36 | ret 3 |
| 37 | end |
| 38 | gx = div and add div n rows sub warps 1 4294967295 warps |
| 39 | if gt gx ctas |
| 40 | gx = ctas |
| 41 | end |
| 42 | if eq gx 0 |
| 43 | gx = 1 |
| 44 | end |
| 45 | put a 8 gx |
| 46 | put a 9 div n rows |
| 47 | ret 0 |
| 48 | end |
| 49 | if eq mode 2 |
| 50 | rec = ne get a 0 0 |
| 51 | xr = get a 1 |
| 52 | xb = get a 2 |
| 53 | if and ne xr 0 or not rec gt xr 65535 |
| 54 | ret 1 |
| 55 | end |
| 56 | if ne get a 4 0 |
| 57 | if or not rec ne xr 0 |
| 58 | ret 1 |
| 59 | end |
| 60 | if or gt xb 1 eq get a 5 0 |
| 61 | ret 1 |
| 62 | end |
| 63 | end |
| 64 | if gt xb 1 |
| 65 | if or not rec ne xr 0 |
| 66 | ret 1 |
| 67 | end |
| 68 | if or gt xb 4 lt get a 3 get a 6 |
| 69 | ret 1 |
| 70 | end |
| 71 | end |
| 72 | ret 0 |
| 73 | end |
| 74 | if eq mode 3 |
| 75 | if gt get a 0 1 |
| 76 | if or gt get a 0 4 eq get a 1 0 |
| 77 | ret 1 |
| 78 | end |
| 79 | end |
| 80 | put a 8 ulong 0 |
| 81 | if le get a 0 1 |
| 82 | put a 8 ulong 1 |
| 83 | end |
| 84 | ret 0 |
| 85 | end |
| 86 | if eq mode 4 |
| 87 | if gt mul mul ulong 32 get a 0 get a 1 65536 |
| 88 | ret 2 |
| 89 | end |
| 90 | ret 0 |
| 91 | end |
| 92 | if eq mode 5 |
| 93 | if eq get a 0 0 |
| 94 | ret 1 |
| 95 | end |
| 96 | put a 8 ulong 0 |
| 97 | if eq get a 0 1 |
| 98 | put a 8 ulong 1 |
| 99 | end |
| 100 | ret 0 |
| 101 | end |
| 102 | if eq mode 6 |
| 103 | r = get a 5 |
| 104 | s = ulong 0 |
| 105 | xb = ulong 0 |
| 106 | gy = ulong 1 |
| 107 | nr = ulong 1 |
| 108 | if ne get a 0 0 |
| 109 | s = get a 4 |
| 110 | gy = get a 0 |
| 111 | nr = gy |
| 112 | end |
| 113 | if ne get a 3 0 |
| 114 | r = 1 |
| 115 | end |
| 116 | if gt get a 1 1 |
| 117 | xb = get a 1 |
| 118 | s = get a 2 |
| 119 | nr = xb |
| 120 | end |
| 121 | put a 8 r |
| 122 | put a 9 s |
| 123 | put a 10 xb |
| 124 | put a 11 gy |
| 125 | put a 12 mul get a 4 nr |
| 126 | ret 0 |
| 127 | end |
| 128 | ret 1 |
| 129 | end |