interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / apiviews / scan.om

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