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

312 lines · 5862 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note tests/d8_mutants.om -- the D8 semantic mutants of om/graph/hello-plan.om (developer bar D8,
3note docs/issues/D8-process-tax.md). Make concatenates tests/d8_lib.om in front and compiles with the pinned
4note seeded omc; mk/graph-residue.mk runs it as part of test-graph-residue-mutants, after om/graph/residue-mutants.py.
5note usage: d8_mutants OUT_DIR CC [CFLAG ...] (environment: OMEGA_OMC, OMEGA_BRIDGE, PATH, HOME, TMPDIR)
6note For each mutant: the site must occur exactly once; the mutant source goes through om/units.sh (the
7note bridge's checked converter, OMEGA_UNITS=hello_plan=<mutant> into the lane), tests/test_graph_residue.c is
8note linked against the mutant's cudapp_om_hello_plan.c, and the result must exit nonzero or print other bytes
9note than OUT_DIR/graph-residue does. A surviving mutant is a FAIL (exit 1). Lanes:
10note OUT_DIR/graph-residue-mutants/<name>/{mutant.om,generate.log,compile.log,test,run.log}.
11note Regions: 1 message, 4 OUT_DIR (absolute), 5 CC, 6 lane, 7 file path, 8 log path, 9 lane file, 31 cwd.
12note execprog gives children an empty environment, so om/units.sh and CC run under /usr/bin/env with the
13note variables named above (until omega-mv has an execprog form that takes an environment).
14global X uchar 524288
15global Xn ulong 1
16global P ulong 1
17
18text TUse "usage: d8_mutants OUT_DIR CC [CFLAG ...]\n"
19text TLanes "/graph-residue-mutants"
20text TExp "/graph-residue-mutants/d8-expected.log"
21text TRef "/graph-residue"
22text TLib "/libomega_gpu.a"
23text TPlan "om/graph/hello-plan.om"
24text TMut "/mutant.om"
25text TGen "/generate.log"
26text TCmp "/compile.log"
27text TBin "/test"
28text TRun "/run.log"
29text TUnitC "/cudapp_om_hello_plan.c"
30text TEnvB "/usr/bin/env"
31text THomeV "HOME="
32text TTmpV "TMPDIR="
33text TOmcV "OMEGA_OMC="
34text TBriV "OMEGA_BRIDGE="
35text TUnitsV "OMEGA_UNITS=hello_plan="
36text TDestV "OMEGA_UNITS_DEST="
37text TSh "/bin/sh"
38text TUnitsSh "om/units.sh"
39text TTest "tests/test_graph_residue.c"
40text TPth "-lpthread"
41text TLm "-lm"
42text TOut "-o"
43text TFail "FAIL "
44text TSite ": mutation site count "
45text TGenF ": om/units.sh exit "
46text TCmpF ": compile exit "
47text TSurv "FAIL mutant "
48text TSurv2 " survived"
49text TKill "mutant "
50text TKill2 " killed rc="
51text TRefF "FAIL graph-residue reference: exit "
52text TPass "PASS graph residue D8: 3 compiled semantic mutants killed"
53text TN1 "d8-own-round"
54text TO1 "ownk = div add get c 3 1023 1024"
55text TW1 "ownk = div get c 3 1024"
56text TN2 "d8-beyond-sign"
57text TO2 "put d 4 1"
58text TW2 "put d 4 0"
59text TN3 "d8-driver-kib"
60text TO3 "put d 5 div add get c 4 1023 1024"
61text TW3 "put d 5 div get c 4 1000"
62
63note region d = OUT_DIR t
64fn opath d ulong t view uchar * to void
65bclr d
66bb d 4
67bt d t
68end
69
70note region d = lane t
71fn lpath d ulong t view uchar * to void
72bclr d
73bb d 6
74bt d t
75end
76
77note truncates the file named by region r
78fn trunc r ulong to void
79bclr 3
80bfile r 3 578
81end
82
83note sites of t in L; the last one in P
84fn lfind t view uchar * to ulong
85n = get Ln 0
86k = ulong 0
87if lt n len t
88ret k
89end
90for p ulong add sub n len t 1
91if lat p t
92k = add k 1
93put P 0 p
94end
95end
96ret k
97end
98
99note writes L[a, e) to fd
100fn lwr fd int a ulong e ulong to void
101while lt a e bound 999999
102w = write fd L a sub e a
103if le w 0
104bfail
105end
106a = add a ulong w
107end
108end
109
110fn say1 t view uchar * to void
111bs 1 t
112bc 1 10
113bout 1 1
114end
115
116note the message region 1 gets "FAIL <nm><b><rc>" (or "mutant <nm><b><rc>" when not fail) and is printed
117fn sayrc fail bool nm view uchar * b view uchar * rc long to void
118bs 1 TKill
119if fail
120bs 1 TFail
121end
122bt 1 nm
123bt 1 b
124bl 1 rc
125bc 1 10
126bout 1 1
127end
128
129note writes the mutant (L with the one site of old replaced by new) to lane/mutant.om
130fn wmut old view uchar * rep view uchar * to void
131lpath 7 TMut
132fd = bopen 7 578
133if lt fd 0
134bfail
135end
136p = get P 0
137lwr int fd 0 p
138bs 3 rep
139bout int fd 3
140lwr int fd add p len old get Ln 0
141c = fclose int fd
142end
143
144fn gen to long
145alclr
146alt TEnvB
147envkv TPathV
148envkv THomeV
149envkv TTmpV
150envkv TOmcV
151envkv TBriV
152bs 9 TUnitsV
153bb 9 7
154alb 9
155bs 9 TDestV
156bb 9 6
157alb 9
158alt TSh
159alt TUnitsSh
160lpath 8 TGen
161trunc 8
162ret runwait 1 8
163end
164
165fn build to long
166alclr
167alt TEnvB
168envkv TPathV
169envkv THomeV
170envkv TTmpV
171alb 5
172for i ulong sub ulong argcnt 3
173barg add i 3 9
174alb 9
175end
176alt TTest
177lpath 9 TUnitC
178alb 9
179opath 9 TLib
180alb 9
181alt TPth
182alt TLm
183alt TOut
184lpath 9 TBin
185alb 9
186lpath 8 TCmp
187trunc 8
188ret runwait 1 8
189end
190
191note the run log (region 8) against the reference X
192fn same to bool
193if not fload 8
194ret false
195end
196n = get Ln 0
197if ne n get Xn 0
198ret false
199end
200for i ulong n
201if ne get L i get X i
202ret false
203end
204end
205ret true
206end
207
208fn mutant nm view uchar * old view uchar * rep view uchar * to bool
209bclr 8
210bt 8 TPlan
211if not fload 8
212bfail
213end
214k = lfind old
215if ne k 1
216sayrc true nm TSite long k
217ret false
218end
219opath 6 TLanes
220bt 6 TSl
221bt 6 nm
222mkdirp 6
223wmut old rep
224rc = gen
225if ne rc 0
226sayrc true nm TGenF rc
227ret false
228end
229rc = build
230if ne rc 0
231sayrc true nm TCmpF rc
232ret false
233end
234alclr
235lpath 9 TBin
236alb 9
237lpath 8 TRun
238trunc 8
239rc = runwait 1 8
240if and eq rc 0 same
241bs 1 TSurv
242bt 1 nm
243bt 1 TSurv2
244bc 1 10
245bout 1 1
246ret false
247end
248sayrc false nm TKill2 rc
249ret true
250end
251
252note runs OUT_DIR/graph-residue once and keeps its output in X
253fn reference to bool
254opath 6 TLanes
255mkdirp 6
256alclr
257opath 9 TRef
258alb 9
259opath 8 TExp
260trunc 8
261rc = runwait 1 8
262if ne rc 0
263bs 1 TRefF
264bl 1 rc
265bc 1 10
266bout 1 1
267ret false
268end
269if not fload 8
270bfail
271end
272n = get Ln 0
273for i ulong n
274put X i get L i
275end
276put Xn 0 n
277ret true
278end
279
280fn main to int
281if lt argcnt 3
282r = write 2 TUse 0 len TUse
283ret 2
284end
285barg 1 4
286barg 2 5
287if ne get B mul ulong 4 4096 47
288k = cwd B mul ulong 31 4096 4095
289if le k 0
290bfail
291end
292put Bn 31 sub ulong k 1
293bt 31 TSl
294bb 31 4
295bclr 4
296bb 4 31
297end
298if not reference
299ret 1
300end
301if not mutant TN1 TO1 TW1
302ret 1
303end
304if not mutant TN2 TO2 TW2
305ret 1
306end
307if not mutant TN3 TO3 TW3
308ret 1
309end
310say1 TPass
311ret 0
312end