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/om/apiviews/scan.om # 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 / om / apiviews / scan.om` 99 lines · 1524 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note One 32-wide scan tile. op 0 sum, 1 max, 2 min, 3 prefix sum. 3 note n is the live count; the rest of the window is the pad (-0 for sum and 4 note prefix, quiet NaN for min and max). The butterfly matches the frozen 5 note host reference: reduce combines i with i+d ascending, prefix adds 6 note descending so the earlier element is still old. 7 note Pad bits: -0 is `2147483648`, quiet NaN is `2143289344`. 8 fn av_pad op ulong to f32 9 if or eq op 0 eq op 3 10 ret bitcast f32 uint `2147483648` 11 end 12 ret bitcast f32 uint `2143289344` 13 end 14 fn av_fmax a f32 b f32 to f32 15 if gt a b 16 ret a 17 end 18 if gt b a 19 ret b 20 end 21 if eq a a 22 if eq b b 23 if and eq a 0.0f32 eq b 0.0f32 24 ret 0.0f32 25 end 26 ret b 27 end 28 ret a 29 end 30 ret b 31 end 32 fn av_fmin a f32 b f32 to f32 33 if lt a b 34 ret a 35 end 36 if lt b a 37 ret b 38 end 39 if eq a a 40 if eq bitcast uint b `2147483648` 41 ret b 42 end 43 ret a 44 end 45 ret b 46 end 47 fn av_cmb op ulong a f32 b f32 to f32 48 if eq op 0 49 ret add a b 50 end 51 if eq op 1 52 ret av_fmax a b 53 end 54 ret av_fmin a b 55 end 56 fn av_scan op ulong n ulong inn view f32 32 out edit f32 32 to ulong 57 if eq n 0 58 ret 1 59 end 60 if gt n 32 61 ret 1 62 end 63 if gt op 3 64 ret 1 65 end 66 v = new f32 32 0.0f32 67 p = av_pad op 68 for i ulong 32 69 if lt i n 70 put v i get inn i 71 else 72 put v i p 73 end 74 end 75 if eq op 3 76 for t ulong 5 77 d = shl 1 t 78 for i ulong 32 79 k = sub 31 i 80 if ge k d 81 put v k add get v sub k d get v k 82 end 83 end 84 end 85 else 86 for t ulong 5 87 d = shr 16 t 88 for i ulong 32 89 if lt add i d 32 90 put v i av_cmb op get v i get v add i d 91 end 92 end 93 end 94 end 95 for i ulong 32 96 put out i get v i 97 end 98 ret 0 99 end