用零开始初始化大型结构,需要多少个Cortex-M7 CPU周期?
我的结构很大,数组很少。 起见,让我们考虑这样的结构:
typedef struct {
uint32_t data_count;
uint8_t data[512];
uint32_t error_count;
uint8_t errors[512];
} measurements_t;
结构初始化〜1kb结构需要多少微控制器CPU周期?
为简单
使用零以〜1kb 声明后的数据)?
Cortex-M7 Core是否具有填充记忆的零元素指令?我不是集会的人,我在本手册,我目前无法访问适当的编译器来检查编译器生产的组件。
measurements_t measurement_results = {0}; // initialization with all zeroes
// or
measurements_t measurement_results; // no initialization
measurement_results.data_count = 0;
measurement_results.error_count = 0;
实际上,我的结构更复杂,几乎没有级别,并且可能更多的数据。
如果我只是用{0}初始化代码,则更容易管理代码, 但是,如果这是对STM32F7的循环廉价的,那么我将不得不创建快速构造函数,该快速构造函数仅在此类结构真正需要的位置将其置于零。
I have big structure with few arrays. For simplicity let's consider structure like this:
typedef struct {
uint32_t data_count;
uint8_t data[512];
uint32_t error_count;
uint8_t errors[512];
} measurements_t;
How many microcontroller CPU cycles does it take to initialize ~1kB structure with zeros?
Does
I'm wondering if I should initialize whole structure with zeroes, or not (assign required data after declaration)?
Does the Cortex-M7 core have any assembly language instruction to fill memory with zeros? I'm not assembly guy, I can't find anything in this manual and I have no access to proper compiler at this moment to check assembly that compiler produces.
measurements_t measurement_results = {0}; // initialization with all zeroes
// or
measurements_t measurement_results; // no initialization
measurement_results.data_count = 0;
measurement_results.error_count = 0;
In fact my struct is more complicated and has few levels and probably more data.
It will be easier to manage code later if I just initialize it with {0},
but if that is cycle-expensive on STM32F7 - I will have to create fast constructor that puts zeroes only where it is really needed for structures like this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的经验,最快的方法是将64位商店指令逐个列出。
https://godbolt.org/z/6wv1dyxfpp
使其更快地进入ITCM内存,并在ITCM内存中更快地放置代码可能进入DTCM内存的结构。它将地址和数据总线分开。
From my experience the fastest way is to have long list of 64 bit store instructions one after another.
https://godbolt.org/z/6Wv1dYxfP
to make it faster place code into ITCM memory and if possible structures into DTCM memory. It separates address and data busses.