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 / gdnut.om

91 lines · 2328 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Unpack per-head slots back to reference tail [3][conv].
4note First writer is s>=256 or h rem (vh/16) == 0. Later copies must match bits.
5note Returns the mismatch count. 0 agrees. 384 is OMEGA_GDN_SLOTS.
6note WolframLanguageEvaluator: {2^14 - 1, 2^17 - 1} -> {16383, 131071}.
7note Pack is ch 14 bits, base 17 bits, conv from bit 31. vh<=48 stays inside.
8note Row meta is hh 6 bits, vh 6 bits, conv from bit 12.
9fn av_ch hh ulong ss ulong vh ulong to ulong
10hk = div hh div vh 16
11if lt ss 128
12ret add mul hk 128 ss
13end
14if lt ss 256
15ret add 2048 add mul hk 128 sub ss 128
16end
17ret add 4096 add mul hh 128 sub ss 256
18end
19fn av_base hh ulong ss ulong to ulong
20ret mul add mul hh 384 ss 4
21end
22fn av_pk ch ulong base ulong conv ulong to ulong
23ret add add ch shl base 14 shl conv 31
24end
25fn av_slot hh ulong ss ulong vh ulong conv ulong to ulong
26ret av_pk av_ch hh ss vh av_base hh ss conv
27end
28fn av_wr tail edit f32 * dev view f32 * pk ulong to ulong
29ch = and pk 16383
30base = and shr pk 14 131071
31conv = shr pk 31
32put tail ch get dev base
33put tail add ch conv get dev add base 1
34put tail add ch mul conv 2 get dev add base 2
35ret 0
36end
37fn av_cmp tail view f32 * dev view f32 * pk ulong to ulong
38ch = and pk 16383
39base = and shr pk 14 131071
40conv = shr pk 31
41bad = ulong 0
42if ne bitcast uint get tail ch bitcast uint get dev base
43bad = add bad 1
44end
45if ne bitcast uint get tail add ch conv bitcast uint get dev add base 1
46bad = add bad 1
47end
48if ne bitcast uint get tail add ch mul conv 2 bitcast uint get dev add base 2
49bad = add bad 1
50end
51ret bad
52end
53fn av_row dev view f32 * tail edit f32 * meta ulong to ulong
54hh = and meta 63
55vh = and shr meta 6 63
56conv = shr meta 12
57bad = ulong 0
58step = ulong 0
59for ss ulong 384
60slot = av_slot hh ss vh conv
61if ge ss 256
62step = av_wr tail dev slot
63else
64if eq rem hh div vh 16 0
65step = av_wr tail dev slot
66else
67bad = add bad av_cmp tail dev slot
68end
69end
70end
71ret bad
72end
73fn av_meta hh ulong vh ulong conv ulong to ulong
74ret add add hh shl vh 6 shl conv 12
75end
76fn av_gdnut dev view f32 * tail edit f32 * vh ulong conv ulong to ulong
77if eq div vh 16 0
78ret 1
79end
80if ne len dev mul mul vh 384 4
81ret 1
82end
83if ne len tail mul conv 3
84ret 1
85end
86bad = ulong 0
87for hh ulong vh
88bad = add bad av_row dev tail av_meta hh vh conv
89end
90ret bad
91end