SPRUI04F july 2015 – april 2023
Avoid Memory Bank Conflicts
.mptr {variable | memref}, base [+ offset] [, stride]
The .mptr directive associates a register with the information that allows the assembly optimizer to determine automatically whether two memory operations have a memory bank conflict. If the assembly optimizer determines that two memory operations have a memory bank conflict, then it does not schedule them in parallel.
A memory bank conflict occurs when two accesses to a single memory bank in a given cycle result in a memory stall that halts all pipeline operation for one cycle while the second value is read from memory. For more information on memory bank conflicts, including how to use the .mptr directive to prevent them, see Section 5.5.
Following are descriptions of the .mptr directive parameters:
variable|memref | The name of the register symbol or memory reference used to identify a load or store involved in a dependence. | |
base | A symbolic address that associates related memory accesses | |
offset | The offset in bytes from the starting base symbol. The offset is an optional parameter and defaults to 0. | |
stride | The register loop increment in bytes. The stride is an optional parameter and defaults to 0. |
The .mptr directive tells the assembly optimizer that when the symbol or memref is used as a memory pointer in an LD(B/BU)(H/HU)(W) or ST(B/H/W) instruction, it is initialized to point to base + offset and is incremented by stride each time through the loop.
The .mptr directive is valid within procedures only; that is, within occurrences of the .proc and .endproc directive pair or the .cproc and .endproc directive pair.
The symbolic addresses used for base symbol names are in a name space separate from all other labels. This means that a symbolic register or assembly label can have the same name as a memory bank base name. For example:
.mptr Darray,Darray
Here is an example in which .mptr is used to avoid memory bank conflicts.
_blkcp: .cproc I
.reg ptr1, ptr2, tmp1, tmp2
MVK 0x0, ptr1 ; ptr1 = address 0
MVK 0x8, ptr2 ; ptr2 = address 8
loop: .trip 50
.mptr ptr1, a+0, 4
.mptr foo, a+8, 4
; potential conflict
LDW *ptr1++, tmp1 ; load *0, bank 0
STW tmp1, *ptr2++{foo} ; store *8, bank 0
[I] ADD -1,i,i ; I--
[I] B loop ; if (!0) goto loop
.endproc