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/components/cm_sort.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 / components / cm_sort.om` 81 lines · 1215 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Stable total binary64 ordering. NaNs follow numbers; equal values use bits. 3 fn cms_less a ulong b ulong to bool 4 x = bitcast f64 a 5 y = bitcast f64 b 6 if ne x x 7 if eq y y 8 ret false 9 end 10 ret lt a b 11 end 12 if ne y y 13 ret true 14 end 15 if lt x y 16 ret true 17 end 18 if gt x y 19 ret false 20 end 21 ret lt a b 22 end 23 fn cms_run a edit ulong 256 n ulong to void 24 for i ulong n 25 j = i 26 while gt j 0 27 if not cms_less get a j get a sub j 1 28 break 29 end 30 x = get a j 31 put a j get a sub j 1 32 put a sub j 1 x 33 j = sub j 1 34 end 35 end 36 end 37 note meta: valid left/right then consumed left/right; C advances only these counts. 38 fn cm_sort a edit ulong 256 b view ulong 256 out edit ulong 256 meta edit ulong 4 to ulong 39 na = get meta 0 40 nb = get meta 1 41 if or gt na 256 gt nb 256 42 ret 0 43 end 44 if eq get meta 2 0 45 cms_run a na 46 ret na 47 end 48 ia = ulong 0 49 ib = ulong 0 50 n = ulong 0 51 while lt n 256 52 if and eq ia na eq ib nb 53 break 54 end 55 left = eq ib nb 56 if and lt ia na lt ib nb 57 left = not cms_less get b ib get a ia 58 end 59 if left 60 put out n get a ia 61 ia = add ia 1 62 else 63 put out n get b ib 64 ib = add ib 1 65 end 66 n = add n 1 67 if gt na 0 68 if eq ia na 69 break 70 end 71 end 72 if gt nb 0 73 if eq ib nb 74 break 75 end 76 end 77 end 78 put meta 2 ia 79 put meta 3 ib 80 ret n 81 end