Elffuss BraidHub

kikocis/ncnn public

master · 3.0 KiBRenderedRawPermalink
1## natural assembly
2* no register dependency, no penalty
3```
4ld1 {v0.4s}, [r0], #16
5fmla v10.4s, v16.4s, v24.s[0]
6fmla v11.4s, v16.4s, v24.s[1]
7fmla v12.4s, v16.4s, v24.s[2]
8fmla v13.4s, v16.4s, v24.s[3]
9```
10
11## A53
12* 128bit vector load cannot be dual issued with fmla, wait 2 cycles
13* 64bit vector load cannot be dual issued with fmla, wait 1 cycle
14* 64bit integer load can be dual issued with fmla, no penalty
15* pointer update can be dual issued with fmla, no penalty
16* 64bit vector load and 64bit vector insert can be dual issued, no penalty
17* any vector load cannot be issued on the 4th cycle of each fmla (enters the accumulator pipeline)
18
19### practical guide
20* use 64bit vector load only
21* issue vector load every three fmla
22* 1 cycle to load 64bit, dual issue with the previous interleaved 64bit insert
23* load the remaining 64bit into integer register, dual issue with fmla
24* update pointer, dual issue with fmla
25* insert 64bit into vector from integer register, dual issue with the next interleaved 64bit load
26* add nop every three fmla if no load, seems to be faster
27```
28ldr d0, [r0] // 1 cycle, v0 first 64bit
29fmla
30ldr x23, [r0, #8] // 0 cycle, v0 second 64bit to temp register
31fmla
32add r0, r0, #16 // 0 cycle, update pointer
33fmla
34ldr d1, [r0] // 1 cycle, v1 first 64bit
35ins v0.d[1], x23 // 0 cycle, v0 second 64bit complete
36fmla
37ldr x23, [r0, #8] // 0 cycle, v1 second 64bit to temp register
38fmla
39add r0, r0, #16 // 0 cycle, update pointer
40fmla
41ins v1.d[1], x23 // 1 cycle, v1 second 64bit complete
42nop
43fmla
44fmla
45fmla
46nop
47nop
48fmla
49fmla
50fmla
51```
52
53## A55
54* Limited by the number of neon register read and write ports, most neon instructions cannot be dual-issued.
55* neon instructions have different latencies
56* 128bit vector load cannot be issued with fmla, WAR wait 2 cycles
57* 64bit integer load can be dual issued with fmla, no penalty
58* pointer update can be dual issued with fmla, no penalty
59* 64bit vector insert can be dual issued with fmla, no penalty
60
61### practical guide
62* A55 supports 128bit load and 256bit write in one clock. Support dual emission of two 64bit vector loads or single emission of 128bit vector load
63* `ldr`, dual issue with fmla
64* load the remaining 64bit into integer register, dual issue with fmla
65* update pointer, dual issue with fmla
66* insert 64bit into vector from integer register, dual issue with fmla
67* interleaved load loose register dependency
68* nop trick is not needed
69* Loop unrolling fma reduces pipeline bubbles
70* Some data type conversion neon instructions can be dual issued, such as `fsvts`
71```
72ldr d0, [r0] // 0 cycle, v0 first 64bit
73fmla
74ldr x23, [r0, #8] // 0 cycle, v0 second 64bit to temp register
75fmla
76add r0, r0, #16 // 0 cycle, update pointer
77fmla
78ldr d1, [r0] // 0 cycle, v1 first 64bit
79fmla
80ins v0.d[1], x23 // 0 cycle, v0 second 64bit complete
81fmla
82ldr x23, [r0, #8] // 0 cycle, v1 second 64bit to temp register
83fmla
84add r0, r0, #16 // 0 cycle, update pointer
85fmla
86ins v1.d[1], x23 // 0 cycle, v1 second 64bit complete
87fmla
88```