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 / tests / ampere / f16_fixture.om

140 lines · 2925 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Dedicated behavior fixture for native_f16 scalar binary32 to binary16 RNE conversion.
3
4fn f16_sub exp ulong m ulong to ulong
5if eq exp 112
6lsb = and shr m 14 1
7r = add add m 8191 lsb
8ret shr r 14
9end
10if eq exp 111
11lsb = and shr m 15 1
12r = add add m 16383 lsb
13ret shr r 15
14end
15if eq exp 110
16lsb = and shr m 16 1
17r = add add m 32767 lsb
18ret shr r 16
19end
20if eq exp 109
21lsb = and shr m 17 1
22r = add add m 65535 lsb
23ret shr r 17
24end
25if eq exp 108
26lsb = and shr m 18 1
27r = add add m 131071 lsb
28ret shr r 18
29end
30if eq exp 107
31lsb = and shr m 19 1
32r = add add m 262143 lsb
33ret shr r 19
34end
35if eq exp 106
36lsb = and shr m 20 1
37r = add add m 524287 lsb
38ret shr r 20
39end
40if eq exp 105
41lsb = and shr m 21 1
42r = add add m 1048575 lsb
43ret shr r 21
44end
45if eq exp 104
46lsb = and shr m 22 1
47r = add add m 2097151 lsb
48ret shr r 22
49end
50if eq exp 103
51lsb = and shr m 23 1
52r = add add m 4194303 lsb
53ret shr r 23
54end
55if eq exp 102
56lsb = and shr m 24 1
57r = add add m 8388607 lsb
58ret shr r 24
59end
60ret 0
61end
62
63fn native_f16 bits ulong to ulong
64sign = and shr bits 16 32768
65u = and bits 2147483647
66if ge u 2139095040
67if gt u 2139095040
68payload = and shr u 13 1023
69res = or 32256 payload
70ret or sign res
71end
72ret or sign 31744
73end
74if ge u 1199566848
75ret or sign 31744
76end
77if ge u 947912704
78lsb = and shr u 13 1
79rounded = add add u 4095 lsb
80val = sub rounded 939524096
81ret or sign shr val 13
82end
83if gt u 855638016
84exp = shr u 23
85m = or 8388608 and u 8388607
86res = f16_sub exp m
87ret or sign res
88end
89ret sign
90end
91
92fn check eq_val ulong exp_val ulong to ulong
93if ne eq_val exp_val
94ret 1
95end
96ret 0
97end
98
99fn main to int
100fails = ulong 0
101
102note Zero
103fails = add fails check native_f16 0 0
104fails = add fails check native_f16 2147483648 32768
105note Subnormal boundary and underflow
106fails = add fails check native_f16 855638016 0
107fails = add fails check native_f16 855638017 1
108fails = add fails check native_f16 947904511 1023
109fails = add fails check native_f16 947904512 1024
110fails = add fails check native_f16 947912703 1024
111
112note Normal min and 1.0f
113fails = add fails check native_f16 947912704 1024
114fails = add fails check native_f16 1065353216 15360
115
116note RNE ties to even
117fails = add fails check native_f16 1065357312 15360
118fails = add fails check native_f16 1065365504 15362
119
120note Normal max and overflow boundary
121fails = add fails check native_f16 1199562752 31743
122fails = add fails check native_f16 1199566847 31743
123fails = add fails check native_f16 1199566848 31744
124fails = add fails check native_f16 3347050496 64512
125
126note Infinities
127fails = add fails check native_f16 2139095040 31744
128fails = add fails check native_f16 4286578688 64512
129
130note NaNs
131fails = add fails check native_f16 2143289344 32256
132fails = add fails check native_f16 2139095041 32256
133fails = add fails check native_f16 4290773024 65024
134fails = add fails check native_f16 2147483647 32767
135
136if ne fails 0
137ret 1
138end
139ret 0
140end