omega-helix
This project has not described itself yet.
Brought by drakestapleton
omega-helix / native / apu_fabric_nogpu.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note native/apu_fabric_nogpu.om: CPU producer backend for Linux multi-core apuweave (aarch64 & x86linux). |
| 3 | |
| 4 | fn apu_be_open to ulong |
| 5 | ret 0 |
| 6 | end |
| 7 | |
| 8 | fn apu_be_close to void |
| 9 | end |
| 10 | |
| 11 | fn apu_load_pref_win1 pbase ulong wi ulong dst_b ulong to void |
| 12 | sh = get apu_shmh 0 |
| 13 | tt = get og 1 |
| 14 | src_w = mul wi mul tt 8 |
| 15 | for t ulong tt bound 512 |
| 16 | o = add pbase add src_w mul t 8 |
| 17 | put obx add dst_b t mapget sh o 4 |
| 18 | put oby add dst_b t mapget sh add o 4 4 |
| 19 | end |
| 20 | end |
| 21 | |
| 22 | fn apu_load_pref_windows ps ulong w_start ulong nw ulong b0 ulong to void |
| 23 | tt = get og 1 |
| 24 | pbase = add apu_pref_base ps APU_SLOT_HDR |
| 25 | for w ulong nw bound 32 |
| 26 | apu_load_pref_win1 pbase add w_start w mul add b0 w tt |
| 27 | end |
| 28 | end |
| 29 | |
| 30 | fn apu_cpu_store_zr wb ulong row ulong zo ulong to void |
| 31 | sh = get apu_shmh 0 |
| 32 | d = get og 2 |
| 33 | r = long 0 |
| 34 | for j ulong d bound 2048 |
| 35 | off = mul add mul row d j 4 |
| 36 | dst = add add wb get apu_shm 4 off |
| 37 | val = ulong bitcast uint f32 get oa add zo j |
| 38 | r = mapset sh dst 4 val |
| 39 | dst = add add wb get apu_shm 5 off |
| 40 | val = ulong bitcast uint f32 get sp2_rvec j |
| 41 | r = mapset sh dst 4 val |
| 42 | end |
| 43 | end |
| 44 | |
| 45 | fn apu_cpu_train_tok wb ulong row ulong t ulong to void |
| 46 | zo = add get og 17 mul t get og 2 |
| 47 | yt = get oby t |
| 48 | surp = sp2_tok_grad zo yt |
| 49 | apu_cpu_store_zr wb row zo |
| 50 | sh = get apu_shmh 0 |
| 51 | dst = add add wb get apu_shm 6 mul row 4 |
| 52 | val = ulong bitcast uint f32 surp |
| 53 | r = mapset sh dst 4 val |
| 54 | dst = add add wb get apu_shm 7 mul row 4 |
| 55 | r = mapset sh dst 4 yt |
| 56 | end |
| 57 | |
| 58 | fn apu_cpu_train_win ps ulong w ulong wb ulong to void |
| 59 | tt = get og 1 |
| 60 | apu_load_pref_windows ps w 1 0 |
| 61 | dl = ofwd 0 |
| 62 | for t ulong tt bound 512 |
| 63 | apu_cpu_train_tok wb add mul w tt t t |
| 64 | end |
| 65 | end |
| 66 | |
| 67 | fn apu_cpu_held_copy base ulong zo2 ulong d ulong to void |
| 68 | sh = get apu_shmh 0 |
| 69 | r = long 0 |
| 70 | for j2 ulong d bound 2048 |
| 71 | val = ulong bitcast uint f32 get oa add zo2 j2 |
| 72 | r = mapset sh add base mul j2 4 4 val |
| 73 | end |
| 74 | end |
| 75 | |
| 76 | fn apu_cpu_held_tok wb ulong row2 ulong t2 ulong to void |
| 77 | d = get og 2 |
| 78 | base = add add wb get apu_shm 8 mul mul row2 d 4 |
| 79 | apu_cpu_held_copy base add get og 17 mul t2 d d |
| 80 | sh = get apu_shmh 0 |
| 81 | yb = add add wb get apu_shm 9 mul row2 4 |
| 82 | yt = get oby t2 |
| 83 | r = mapset sh yb 4 yt |
| 84 | end |
| 85 | |
| 86 | fn apu_cpu_held_win ps ulong nw ulong wh ulong wb ulong to void |
| 87 | tt = get og 1 |
| 88 | apu_load_pref_windows ps add nw wh 1 0 |
| 89 | dl2 = ofwd 0 |
| 90 | for t2 ulong tt bound 512 |
| 91 | apu_cpu_held_tok wb add mul wh tt t2 t2 |
| 92 | end |
| 93 | end |
| 94 | |
| 95 | fn apu_cpu_run_one idx ulong to void |
| 96 | shrd = get apu_bsh idx |
| 97 | ps = get apu_bps idx |
| 98 | wb = apu_work_base get apu_bws idx |
| 99 | nw = get apu_bnw idx |
| 100 | nh = get apu_bnh idx |
| 101 | for w ulong nw bound 32 |
| 102 | apu_cpu_train_win ps w wb |
| 103 | end |
| 104 | for wh ulong nh bound 4 |
| 105 | apu_cpu_held_win ps nw wh wb |
| 106 | end |
| 107 | sh = get apu_shmh 0 |
| 108 | tt = get og 1 |
| 109 | r7 = mapset sh wb 8 shrd |
| 110 | r8 = mapset sh add wb 8 8 get apu_sids shrd |
| 111 | r9 = mapset sh add wb 16 8 mul nw tt |
| 112 | r10 = mapset sh add wb 24 8 mul nh tt |
| 113 | r11 = mapset sh add wb 32 8 bitcast ulong 1.0f64 |
| 114 | cpufence |
| 115 | end |
| 116 | |
| 117 | fn apu_be_run_batch k ulong to void |
| 118 | for idx ulong k bound 16 |
| 119 | apu_cpu_run_one idx |
| 120 | end |
| 121 | end |