interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / om / gpu / cg_bf16.om

794 lines · 15975 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note om/gpu/cg_bf16.om: Pure OM-2 Blackwell IR emitter for BF16 streaming GEMV (lm_head, ROWS, MASK, XBATCH).
3note Replaces src/omega_blackwell_codegen_bf16.c.
4note Spec wire sp[8]: 0=k, 1=rows, 2=warps, 3=depth, 4=mutant, 5=ystride, 6=xbatch, 7=mask.
5om2
6
7const BF_NOREG ulong 0xffffffffffffffff
8const BF_CW_YIELD ulong 0x2000
9const BF_MAX_SMEM ulong 98304
10const BF_MAX_K ulong 8192
11const BF_MAX_XB ulong 4
12
13fn bf_cw st ulong wb ulong rb ulong wt ulong to ulong
14ret or or or shl st 9 shl wb 14 shl rb 17 shl wt 20
15end
16
17fn bf_v meta edit ulong 512 w ulong to ulong
18v = get meta 1
19if ge v 256
20put meta 5 1
21ret 0
22end
23put meta add 64 v w
24put meta 1 add v 1
25ret v
26end
27
28fn bf_uv meta edit ulong 512 w ulong to ulong
29u = get meta 2
30if ge u 32
31put meta 5 1
32ret 0
33end
34put meta add 352 u w
35put meta 2 add u 1
36ret u
37end
38
39fn bf_emit ins edit ulong 8192 meta edit ulong 512 row view ulong 8 kind ulong to void
40n = get meta 0
41if ge n 1024
42put meta 5 1
43ret
44end
45wt = get meta 4
46ctrl = ulong 0
47if eq kind 0
48ctrl = bf_cw 6 7 7 wt
49put meta 4 0
50end
51if eq kind 1
52ctrl = bf_cw 14 7 7 wt
53put meta 4 0
54end
55if eq kind 2
56ctrl = or bf_cw 4 0 1 wt BF_CW_YIELD
57put meta 4 3
58end
59if eq kind 3
60ctrl = or bf_cw 4 0 1 and wt 2 BF_CW_YIELD
61put meta 4 or wt 3
62end
63if eq kind 4
64ctrl = or bf_cw 4 2 7 wt BF_CW_YIELD
65put meta 4 4
66end
67if eq kind 5
68ctrl = or bf_cw 4 7 1 wt BF_CW_YIELD
69put meta 4 2
70end
71if eq kind 6
72ctrl = bf_cw 6 7 7 wt
73put meta 4 0
74end
75if eq kind 7
76ctrl = bf_cw 5 7 7 wt
77if eq and shr get row 7 1 1 0
78put meta 4 0
79end
80end
81if eq kind 8
82ctrl = or bf_cw 1 7 7 wt BF_CW_YIELD
83put meta 4 0
84end
85if eq kind 9
86ctrl = or bf_cw 5 7 7 wt BF_CW_YIELD
87put meta 4 0
88end
89b = mul n 8
90for k ulong 6
91put ins add b k get row k
92end
93put ins add b 6 or and get row 6 0xffffffff shl ctrl 32
94put ins add b 7 get row 7
95put meta 0 add n 1
96end
97
98fn bf_r0 r edit ulong 8 op ulong to void
99put r 0 op
100put r 1 BF_NOREG
101put r 2 BF_NOREG
102put r 3 BF_NOREG
103put r 4 BF_NOREG
104put r 5 BF_NOREG
105put r 6 0
106put r 7 0
107end
108
109fn bf_patch ins edit ulong 8192 pos ulong tgt ulong to void
110if ge pos 1024
111ret
112end
113b = add mul pos 8 6
114w6 = get ins b
115delta = sub tgt pos
116put ins b or and w6 0xffffffff00000000 and delta 0xffffffff
117end
118
119fn bf_loop_end meta edit ulong 512 start ulong to void
120nl = get meta 3
121if ge nl 16
122put meta 5 1
123ret
124end
125put meta add 320 mul nl 2 start
126put meta add 321 mul nl 2 sub get meta 0 1
127put meta 3 add nl 1
128end
129
130fn em_op1 ins edit ulong 8192 meta edit ulong 512 op ulong dst ulong imm ulong kind ulong to void
131r = new ulong 8 0
132bf_r0 r op
133put r 1 dst
134put r 6 imm
135if eq kind 4
136put r 7 1
137end
138bf_emit ins meta r kind
139end
140
141fn em_imadi ins edit ulong 8192 meta edit ulong 512 d ulong a ulong asub ulong to void
142r = new ulong 8 0
143bf_r0 r 8
144put r 1 d
145put r 2 a
146put r 4 get meta 10
147put r 6 get meta 11
148put r 7 shl asub 24
149bf_emit ins meta r 0
150end
151
152fn em_imadw ins edit ulong 8192 meta edit ulong 512 d ulong a ulong imm ulong c ulong to void
153r = new ulong 8 0
154bf_r0 r 9
155put r 1 d
156put r 2 a
157put r 4 c
158put r 6 imm
159bf_emit ins meta r 0
160end
161
162fn em_bin ins edit ulong 8192 meta edit ulong 512 op ulong d ulong a ulong b ulong to void
163r = new ulong 8 0
164bf_r0 r op
165put r 1 d
166put r 2 a
167put r 3 b
168bf_emit ins meta r 0
169end
170
171fn em_ldg ins edit ulong 8192 meta edit ulong 512 op ulong d ulong a ulong imm ulong to void
172r = new ulong 8 0
173bf_r0 r op
174put r 1 d
175put r 2 a
176put r 5 get meta 384
177put r 6 imm
178bf_emit ins meta r get meta 12
179end
180
181fn em_lds128 ins edit ulong 8192 meta edit ulong 512 d ulong a ulong imm ulong first ulong to void
182r = new ulong 8 0
183bf_r0 r 58
184put r 1 d
185put r 2 a
186put r 6 imm
187k = ulong 3
188if ne first 0
189k = ulong 2
190end
191bf_emit ins meta r k
192end
193
194fn em_ffma ins edit ulong 8192 meta edit ulong 512 d ulong a ulong b ulong bsub ulong to void
195r = new ulong 8 0
196bf_r0 r 33
197put r 1 d
198put r 2 a
199put r 3 b
200put r 4 d
201put r 7 shl bsub 32
202bf_emit ins meta r 0
203end
204
205fn bf_ok_xb sp view ulong 8 xb ulong to ulong
206k = get sp 0
207rows = get sp 1
208warps = get sp 2
209ys = get sp 5
210if eq ys 0
211ret 0
212end
213if gt mul rows xb 16
214ret 0
215end
216if gt mul mul xb k 4 BF_MAX_SMEM
217ret 0
218end
219if gt mul xb k mul 2048 warps
220ret 0
221end
222if ge mul mul sub xb 1 ys 4 shl ulong 1 31
223ret 0
224end
225ret 1
226end
227
228export fn cg_bf16_ok_i sp view ulong 8 to ulong
229k = get sp 0
230rows = get sp 1
231warps = get sp 2
232depth = get sp 3
233if ne rows 1
234if ne rows 2
235if ne rows 4
236ret 0
237end
238end
239end
240if eq warps 0
241ret 0
242end
243if gt warps 32
244ret 0
245end
246if eq k 0
247ret 0
248end
249if gt k BF_MAX_K
250ret 0
251end
252if ne rem k 256 0
253ret 0
254end
255if ne rem k mul 32 warps 0
256ret 0
257end
258if gt k mul 2048 warps
259ret 0
260end
261if eq depth 0
262ret 0
263end
264if gt depth 16
265ret 0
266end
267if ne rem div k 256 depth 0
268ret 0
269end
270if gt mul rows depth 16
271ret 0
272end
273if gt get sp 7 1
274ret 0
275end
276xb = get sp 6
277if eq xb 0
278xb = ulong 1
279end
280if gt xb BF_MAX_XB
281ret 0
282end
283if ne get sp 7 0
284if ne rows 1
285ret 0
286end
287if ne get sp 5 0
288ret 0
289end
290if gt xb 1
291ret 0
292end
293end
294if gt xb 1
295if eq bf_ok_xb sp xb 0
296ret 0
297end
298end
299if gt get sp 4 4
300ret 0
301end
302if eq get sp 4 4
303if eq get sp 7 0
304if lt xb 2
305ret 0
306end
307end
308end
309if gt get sp 5 shl ulong 1 28
310ret 0
311end
312if ge add mul mul sub rows 1 k 2 mul 512 depth shl ulong 1 23
313ret 0
314end
315ret 1
316end
317
318fn bf_stage_chunk sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
319pxs = new ulong 8 0
320xst = new ulong 8 0
321r = new ulong 8 0
322j0 = get meta 416
323nj = get meta 417
324step = mul 128 get sp 2
325for q ulong nj bound 8
326put pxs q bf_v meta 2
327put xst q bf_v meta 1
328end
329for q ulong nj bound 8
330off = mul add j0 q step
331em_imadw ins meta get pxs q get meta 394 off get meta 413
332end
333for q ulong nj bound 8
334put meta 12 3
335if eq q 0
336put meta 12 2
337end
338em_ldg ins meta 11 get xst q get pxs q 0
339end
340for q ulong nj bound 8
341put meta 10 get meta 414
342put meta 11 mul add j0 q step
343em_imadi ins meta get meta 415 get meta 394 0
344bf_r0 r 50
345put r 2 get meta 415
346put r 3 get xst q
347bf_emit ins meta r 5
348end
349end
350
351fn bf_stage_x sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
352r = new ulong 8 0
353xb = get sp 6
354if eq xb 0
355xb = ulong 1
356end
357rounds = div mul xb get sp 0 mul 32 get sp 2
358put meta 413 bf_v meta 2
359put meta 414 bf_v meta 1
360put meta 415 bf_v meta 1
361em_imadw ins meta get meta 413 get meta 390 4 get meta 386
362put meta 10 BF_NOREG
363put meta 11 4
364em_imadi ins meta get meta 414 get meta 390 0
365j0 = ulong 0
366while lt j0 rounds bound 64
367nj = sub rounds j0
368if gt nj 8
369nj = ulong 8
370end
371put meta 416 j0
372put meta 417 nj
373bf_stage_chunk sp ins meta
374j0 = add j0 nj
375end
376bf_r0 r 48
377bf_emit ins meta r 6
378end
379
380fn bf_prologue sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
381put meta 384 bf_uv meta 2
382put meta 385 bf_v meta 2
383put meta 386 bf_v meta 2
384put meta 387 bf_v meta 2
385put meta 388 bf_v meta 1
386put meta 389 bf_v meta 1
387put meta 390 bf_v meta 1
388put meta 391 bf_v meta 1
389put meta 392 bf_v meta 1
390put meta 393 bf_v meta 1
391put meta 394 bf_v meta 1
392put meta 395 bf_v meta 1
393put meta 396 bf_v meta 1
394put meta 397 bf_v meta 1
395em_op1 ins meta 7 get meta 384 0x358 4
396em_op1 ins meta 5 get meta 385 0x380 2
397em_op1 ins meta 5 get meta 386 0x388 2
398em_op1 ins meta 5 get meta 387 0x390 2
399em_op1 ins meta 4 get meta 388 0x398 2
400em_op1 ins meta 4 get meta 389 0x39c 2
401em_op1 ins meta 3 get meta 390 0x21 2
402em_op1 ins meta 3 get meta 391 0x25 2
403xb = get sp 6
404if eq xb 0
405xb = ulong 1
406end
407if ne get sp 5 0
408if eq xb 1
409cy = bf_v meta 1
410em_op1 ins meta 3 cy 0x26 2
411em_imadw ins meta get meta 386 cy mul get sp 0 4 get meta 386
412em_imadw ins meta get meta 387 cy mul get sp 5 4 get meta 387
413end
414end
415em_op1 ins meta 2 get meta 394 1 0
416r = new ulong 8 0
417bf_r0 r 17
418put r 1 get meta 392
419put r 2 get meta 390
420put r 6 5
421bf_emit ins meta r 0
422bf_r0 r 18
423put r 1 get meta 393
424put r 2 get meta 390
425put r 6 31
426bf_emit ins meta r 0
427put meta 10 BF_NOREG
428put meta 11 16
429em_imadi ins meta get meta 395 get meta 393 0
430put meta 10 get meta 392
431put meta 11 get sp 2
432em_imadi ins meta get meta 396 get meta 391 0
433put meta 10 BF_NOREG
434put meta 11 32
435em_imadi ins meta get meta 397 get meta 393 0
436bf_stage_x sp ins meta
437end
438
439fn bf_alloc_body sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
440put meta 398 bf_v meta 2
441put meta 399 bf_v meta 2
442put meta 400 bf_v meta 1
443put meta 401 bf_v meta 1
444put meta 402 bf_v meta 2
445put meta 403 bf_v meta 2
446put meta 404 bf_v meta 1
447put meta 405 bf_v meta 1
448rows = get sp 1
449depth = get sp 3
450xb = get sp 6
451if eq xb 0
452xb = ulong 1
453end
454for ri ulong rows bound 4
455for m ulong xb bound 4
456put meta add 416 add mul ri 4 m bf_v meta 1
457end
458for s ulong depth bound 16
459put meta add 432 add mul ri 16 s bf_v meta 4
460end
461end
462for m ulong xb bound 4
463put meta add 496 mul m 2 bf_v meta 4
464put meta add 497 mul m 2 bf_v meta 4
465end
466if ne get sp 7 0
467ptau = bf_v meta 2
468put meta 406 bf_v meta 2
469put meta 407 bf_v meta 1
470put meta 408 bf_v meta 1
471put meta 409 bf_v meta 1
472put meta 410 bf_v meta 2
473put meta 411 bf_v meta 1
474put meta 412 bf_v meta 1
475em_op1 ins meta 5 get meta 406 0x3a0 2
476em_op1 ins meta 5 ptau 0x3a8 2
477put meta 12 2
478em_ldg ins meta 11 get meta 407 ptau 0
479em_op1 ins meta 1 get meta 408 0 0
480em_bin ins meta 30 get meta 407 get meta 407 get meta 408
481em_op1 ins meta 2 get meta 409 0xff800000 0
482end
483end
484
485fn bf_kloop_ldg_s sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
486for ri ulong get sp 1 bound 4
487put meta 12 3
488if ne get meta 505 0
489put meta 12 2
490put meta 505 0
491end
492off = mul ri get sp 0
493off = add mul off 2 mul get meta 504 512
494em_ldg ins meta 57 get meta add 432 add mul ri 16 get meta 504 get meta 398 off
495end
496end
497
498fn bf_kloop_ldg sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
499put meta 505 1
500for s ulong get sp 3 bound 16
501put meta 504 s
502bf_kloop_ldg_s sp ins meta
503end
504end
505
506fn bf_kloop_lds sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
507xb = get sp 6
508if eq xb 0
509xb = ulong 1
510end
511put meta 508 mul get meta 504 1024
512if eq get sp 4 2
513put meta 508 0
514end
515for m ulong xb bound 4
516off = mul mul m get sp 0 4
517if eq get sp 4 4
518off = ulong 0
519end
520off = add off get meta 508
521if eq m 0
522em_lds128 ins meta get meta add 496 mul m 2 get meta 400 off 1
523else
524em_lds128 ins meta get meta add 496 mul m 2 get meta 400 off 0
525end
526off = add off 16
527em_lds128 ins meta get meta add 497 mul m 2 get meta 400 off 0
528end
529end
530
531fn bf_kloop_ffma sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
532xb = get sp 6
533if eq xb 0
534xb = ulong 1
535end
536for m ulong xb bound 4
537acc = get meta add 416 add mul get meta 505 4 m
538xv = get meta add 496 add mul m 2 shr get meta 507 1
539em_ffma ins meta acc get meta 405 xv get meta 508
540end
541end
542
543fn bf_kloop_word sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
544r = new ulong 8 0
545sub0 = mul and get meta 507 1 2
546sub1 = add sub0 1
547if eq get sp 4 1
548sub0 = add mul and get meta 507 1 2 1
549sub1 = mul and get meta 507 1 2
550end
551put meta 10 BF_NOREG
552put meta 11 65536
553em_imadi ins meta get meta 405 get meta 506 get meta 507
554put meta 508 sub0
555bf_kloop_ffma sp ins meta
556bf_r0 r 18
557put r 1 get meta 405
558put r 2 get meta 506
559put r 6 0xffff0000
560put r 7 shl get meta 507 24
561bf_emit ins meta r 0
562put meta 508 sub1
563bf_kloop_ffma sp ins meta
564end
565
566fn bf_kloop_mac sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
567s = get meta 504
568bf_kloop_lds sp ins meta
569words = ulong 4
570if eq get sp 4 3
571words = ulong 3
572end
573for ri ulong get sp 1 bound 4
574put meta 506 get meta add 432 add mul ri 16 s
575put meta 505 ri
576for wd ulong words bound 4
577put meta 507 wd
578bf_kloop_word sp ins meta
579end
580end
581end
582
583fn bf_kloop sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
584r = new ulong 8 0
585lk = get meta 0
586bf_kloop_ldg sp ins meta
587for s ulong get sp 3 bound 16
588put meta 504 s
589bf_kloop_mac sp ins meta
590end
591em_imadw ins meta get meta 398 get meta 394 mul get sp 3 512 get meta 398
592put meta 10 get meta 400
593put meta 11 mul get sp 3 1024
594if eq get sp 4 2
595put meta 11 0
596end
597em_imadi ins meta get meta 400 get meta 394 0
598put meta 10 get meta 401
599put meta 11 0xffffffff
600em_imadi ins meta get meta 401 get meta 394 0
601bf_r0 r 28
602put r 2 get meta 401
603put r 3 get meta 394
604bf_emit ins meta r 1
605bf_r0 r 46
606put r 6 sub lk get meta 0
607put r 7 2
608bf_emit ins meta r 7
609bf_loop_end meta lk
610end
611
612fn bf_store_row sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 ri ulong to void
613r = new ulong 8 0
614xb = get sp 6
615if eq xb 0
616xb = ulong 1
617end
618for m ulong xb bound 4
619off = add mul ri 4 mul mul m get sp 5 4
620em_imadw ins meta get meta 403 get meta 394 off get meta 402
621bf_r0 r 12
622put r 2 get meta 403
623put r 3 get meta add 416 add mul ri 4 m
624put r 5 get meta 384
625bf_emit ins meta r 5
626end
627end
628
629fn bf_store_rows sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
630for ri ulong get sp 1 bound 4
631bf_store_row sp ins meta ri
632end
633end
634
635fn bf_reduce_one ins edit ulong 8192 meta edit ulong 512 ac ulong to void
636r = new ulong 8 0
637off = ulong 16
638while ge off 1 bound 5
639bf_r0 r 42
640put r 1 get meta 404
641put r 2 ac
642put r 6 off
643bf_emit ins meta r 2
644em_bin ins meta 30 ac ac get meta 404
645off = shr off 1
646end
647end
648
649fn bf_reduce_store sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
650r = new ulong 8 0
651xb = get sp 6
652if eq xb 0
653xb = ulong 1
654end
655for ri ulong get sp 1 bound 4
656for m ulong xb bound 4
657bf_reduce_one ins meta get meta add 416 add mul ri 4 m
658end
659end
660em_imadw ins meta get meta 402 get meta 396 mul get sp 1 4 get meta 387
661bf_r0 r 28
662put r 2 get meta 393
663put r 3 get meta 394
664bf_emit ins meta r 1
665put meta 504 get meta 0
666bf_r0 r 54
667put r 6 2
668bf_emit ins meta r 8
669put meta 505 get meta 0
670bf_r0 r 46
671put r 6 1
672put r 7 2
673bf_emit ins meta r 7
674bf_store_rows sp ins meta
675at_bsync = get meta 0
676bf_r0 r 55
677bf_emit ins meta r 9
678bf_patch ins get meta 505 at_bsync
679bf_patch ins get meta 504 add at_bsync 1
680end
681
682fn bf_zero_acc sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
683xb = get sp 6
684if eq xb 0
685xb = ulong 1
686end
687for ri ulong get sp 1 bound 4
688for m ulong xb bound 4
689em_op1 ins meta 1 get meta add 416 add mul ri 4 m 0 0
690end
691end
692end
693
694fn bf_rowgroup sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to void
695r = new ulong 8 0
696lrg = get meta 0
697bf_r0 r 28
698put r 2 get meta 396
699put r 3 get meta 388
700bf_emit ins meta r 1
701bra_end = get meta 0
702bf_r0 r 46
703put r 6 1
704put r 7 2
705bf_emit ins meta r 7
706bra_skip_row = BF_NOREG
707if ne get sp 7 0
708em_imadw ins meta get meta 410 get meta 396 4 get meta 406
709put meta 12 2
710em_ldg ins meta 11 get meta 411 get meta 410 0
711em_bin ins meta 30 get meta 411 get meta 411 get meta 408
712em_bin ins meta 37 get meta 412 get meta 411 get meta 407
713em_bin ins meta 29 get meta 412 get meta 412 get meta 411
714bf_r0 r 28
715put r 2 get meta 412
716put r 3 get meta 394
717bf_emit ins meta r 1
718bra_skip_row = get meta 0
719bf_r0 r 46
720put r 6 1
721put r 7 2
722if eq get sp 4 4
723put r 7 6
724end
725bf_emit ins meta r 7
726end
727em_imadw ins meta get meta 399 get meta 396 mul mul get sp 1 get sp 0 2 get meta 385
728em_imadw ins meta get meta 398 get meta 395 1 get meta 399
729put meta 10 BF_NOREG
730put meta 11 1
731em_imadi ins meta get meta 400 get meta 397 0
732bf_zero_acc sp ins meta
733em_op1 ins meta 2 get meta 401 div div get sp 0 256 get sp 3 0
734bf_kloop sp ins meta
735bf_reduce_store sp ins meta
736if ne get sp 7 0
737bra_next = get meta 0
738bf_r0 r 46
739put r 6 1
740bf_emit ins meta r 7
741bf_patch ins bra_skip_row get meta 0
742em_imadw ins meta get meta 402 get meta 396 4 get meta 387
743bf_r0 r 12
744put r 2 get meta 402
745put r 3 get meta 409
746put r 5 get meta 384
747bf_emit ins meta r 5
748bf_patch ins bra_next get meta 0
749end
750put meta 10 get meta 396
751put meta 11 1
752em_imadi ins meta get meta 396 get meta 389 0
753bf_r0 r 46
754put r 6 sub lrg get meta 0
755bf_emit ins meta r 7
756bf_loop_end meta lrg
757bf_patch ins bra_end get meta 0
758bf_r0 r 45
759bf_emit ins meta r 7
760end
761
762export fn cg_bf16_ok sp view ulong 8 to ulong
763ret cg_bf16_ok_i sp
764end
765
766export fn cg_bf16_emit sp view ulong 8 ins edit ulong 8192 meta edit ulong 512 to ulong
767if eq cg_bf16_ok_i sp 0
768ret 1
769end
770for i ulong 512
771put meta i 0
772end
773bf_prologue sp ins meta
774bf_alloc_body sp ins meta
775bf_rowgroup sp ins meta
776n = get meta 0
777if ge n 1024
778ret 1
779end
780b = mul n 8
781put ins b 46
782put ins add b 1 BF_NOREG
783put ins add b 2 BF_NOREG
784put ins add b 3 BF_NOREG
785put ins add b 4 BF_NOREG
786put ins add b 5 BF_NOREG
787put ins add b 6 shl ulong 0x000fc000 32
788put ins add b 7 0
789put meta 0 add n 1
790if ne get meta 5 0
791ret 1
792end
793ret 0
794end