Skip to content

Commit 0b8a409

Browse files
fix sessions
1 parent f9187b4 commit 0b8a409

81 files changed

Lines changed: 1949 additions & 1115 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

mkdocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ plugins:
165165
- trimmer
166166

167167
# 标签插件 - 为文章添加标签分类
168-
- tags:
169-
tags_file: tags.md # 标签索引页
168+
- tags
170169

171170
# Awesome Pages 插件 - 灵活的页面组织方式
172171
- awesome-pages

tutorial/并行计算C++/AVX 指令集系列深度介绍:领域、意义、以及 AVX AVX2 的基本用法与样例.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,16 @@ void add_float_arrays_avx(const float* a, const float* b, float* out, size_t n)
8181
// tail
8282
for (; i < n; ++i) out[i] = a[i] + b[i];
8383
}
84-
```text
84+
85+
```
8586
8687
编译:
8788
88-
```text
89+
```cpp
90+
8991
g++ -O3 -mavx -std=c++17 avx_samples.cpp -o avx_samples
90-
```text
92+
93+
```
9194

9295
#### 浮点点积(AVX + reduction)
9396

@@ -112,7 +115,8 @@ float dot_product_avx(const float* a, const float* b, size_t n) {
112115
for (; i < n; ++i) sum += a[i] * b[i];
113116
return sum;
114117
}
115-
```text
118+
119+
```
116120
117121
#### 试一下:AVX2:整型并行加法与 gather 示例
118122
@@ -139,10 +143,13 @@ void gather_example(const int32_t* base, const int32_t* idx, int32_t* out) {
139143
__m256i gathered = _mm256_i32gather_epi32(base, vindex, 4);
140144
_mm256_storeu_si256((__m256i*)out, gathered);
141145
}
142-
```text
146+
147+
```
143148

144149
编译:
145150

146-
```text
151+
```cpp
152+
147153
g++ -O3 -mavx2 -std=c++17 avx_samples.cpp -o avx2_samples
148-
```text
154+
155+
```

tutorial/核心:现代嵌入式C++教程/Chapter0/1嵌入式的资源与实时约束.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ void process_data(void) {
7676
// 建议:使用静态或全局内存,或分段处理
7777
static uint8_t buffer[256]; // 或从内存池分配
7878
}
79-
```text
79+
80+
```
8081
8182
### 3.3 堆的风险
8283
@@ -109,7 +110,8 @@ void* mempool_alloc(void) {
109110
}
110111
return NULL; // 无可用内存
111112
}
112-
```text
113+
114+
```
113115

114116
在嵌入式系统中,内存管理首先服务于确定性,而不是便利性。
115117

@@ -163,7 +165,8 @@ for (int i = 0; i < n; i++) {
163165
process_b(data[i]);
164166
}
165167
}
166-
```text
168+
169+
```
167170

168171
问题不在逻辑错误,而在于:**每一次循环都要经历一次分支判断**。在没有分支预测的 CPU 上,这就是稳定且可观的性能损耗。改法也很朴素:
169172

@@ -178,7 +181,8 @@ if (condition) {
178181
process_b(data[i]);
179182
}
180183
}
181-
```text
184+
185+
```
182186

183187
优化点不是"更聪明",而是:**把一次不确定的分支,换成一次确定的执行路径**。在嵌入式里,这种"看起来啰嗦"的写法,常常才是工程上真正安全且可分析的代码。
184188

@@ -235,7 +239,8 @@ void main_loop(void) {
235239
process_all_events();
236240
}
237241
}
238-
```text
242+
243+
```
239244
240245
高级之处不在复杂逻辑,而在明确告诉系统:**没事别硬撑,让硬件帮你省电**。在嵌入式里,写得"更聪明"的代码——往往比写得"更快"的代码更省电。
241246
@@ -282,7 +287,8 @@ void system_init(void) {
282287
// init_uart(); // 移到需要时初始化
283288
// init_spi(); // 同上
284289
}
285-
```text
290+
291+
```
286292

287293
这种"克制"的初始化方式,常常是达成启动时间指标的关键。
288294

@@ -336,6 +342,7 @@ void scheduler_run(void) {
336342
}
337343
}
338344
}
339-
```text
345+
346+
```
340347
341348
它不复杂、不华丽,但行为是**可分析、可推导、可验证的**——这正是嵌入式最看重的特质。

0 commit comments

Comments
 (0)