理解ARMV8 Device Memory的三个属性

原创文章,转载请注明出处.转载自: Li Haifeng's Blog
本文链接地址: 理解ARMV8 Device Memory的三个属性

ARMV8的spec.对device memory新引入了3个概念,分别是:Gathering, Reordering和Early Write acknowledge.下面从软件工程师的角度去阐述这三个概念。

Gathering

The Gathering attribute determines whether it is permissible for either:
• Multiple memory accesses of the same type, read or write, to the same memory location to be merged into a single transaction.
• Multiple memory accesses of the same type, read or write, to different memory locations to be merged into a single memory transaction on an interconnect.

当某条load/store指令在pipeline的access memory阶段,发生cache miss(对于non-cacheable的memory就直接跳过,不过对于device memory一般都是non-cacheable的)后,需要将access memory请求发到总线上(例如AXI总线),通过AXI总线访问device memory,这个通过总线访问memory的过程被称为一次transaction. 为了优化性能考虑,在core内,会引入一个Buffer, 当发生一个access memory请求后,会将这个请求信息丢到Buffer中,若某条指令和上一条指令共享同一个cache line或者是访问同一个地址,那么,该条指令便不会再向总线发送transaction了,它share上一条指令 读到buffer中的结果。这个share的过程称为gathering. 读到buffer中的数据,如果是cacheable的,会在某个时间内腾到cache中。

Reordering
reordering也是针对device memory的transaction, that is, 某个device memory的连续access的transaction或者device memory之间的连续access的transaction. 对某个device memory的一次transaction 必须等到上一次device memory的transaction结束后(上一次load或者 write的ack发生后)才可以进行,这叫non-reordering. 若这些transaction可以乱序,不需要等待上一次access的ack就可以进行transaction,这种方式叫reordering.

Early Write acknowledge

Early Write Acknowledgement is a hint to the platform memory system. Assigning the No Early Write Acknowledgement attribute to a Device memory location recommends that only the endpoint of the write access returns a write acknowledgement of the access, and that no earlier point in the memory system returns a write acknowledge. This means that a DSB barrier, executed by the processor that performed the write to the No Early Write Acknowledgement location, completes only after the write has reached its endpoint in the memory system. Typically, this endpoint is a peripheral or physical memory.

当对某个Device memory进行write时,需要ACK,下一个对device memory进行access的transaction才能进行。为了性能优化的考虑,device会提供一个类似与寄存器的程序员不可见的buffer,这样当CPU通过总线向device memory写数据的时候,直接写到buffer里就可以了。这样buffer就可以向cpu返回一个ACK,表示写successfully.至于何时buffer将数据真正腾到device memory就看device内部的协议了。

From Li Haifeng's Blog, post 理解ARMV8 Device Memory的三个属性

Post Footer automatically generated by wp-posturl plugin for wordpress.

分享到: