使用旧的 Rust 2015
1.0.2 |
|
---|---|
1.0.1 |
|
#20 在 #allocated
25KB
534 行
UM-32
这是 Rust 实现的 UM-32 "通用计算机"。您可以在 UM-32 "通用计算机" 规范、各种 VM 映像以及有关此竞赛的更多信息中找到 boundvariable.org。
架构
通用计算机由 8 个无符号 32 位寄存器、一个包含任意大小无符号 32 位数据数组的动态分配堆和 14 个操作码组成。通用计算机图像以大端字节顺序存储为无符号 32 位字序列。
实现
这是一个非常基础的实现,是为了更好地熟悉 Rust 而编写的练习。它目前比 Joe 的 C++ 实现慢一些。我想纠正这一点。
待办事项
- 构建一个合理的测试套件
- 修复性能问题
测试
指令解析代码有良好的覆盖率,但没有其他任何覆盖率。在尝试优化之前需要修复这些问题。
性能
[jgrillo@localhost um32]$ sudo lshw -class cpu
*-cpu
description: CPU
product: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
vendor: Intel Corp.
physical id: 6
bus info: cpu@0
version: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
serial: None
slot: U3E1
size: 1392MHz
capacity: 4005MHz
width: 64 bits
clock: 100MHz
capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti retpoline intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp cpufreq
configuration: cores=4 enabledcores=4 threads=8
[jgrillo@localhost um32]$ time ./target/release/um32 ~/src/boundvariable/umbin/midmark.um
read 120440 bytes from /home/jgrillo/src/boundvariable/umbin/midmark.um
== UM beginning stress test / benchmark.. ==
4. 12345678.09abcdef
3. 6d58165c.2948d58d
2. 0f63b9ed.1d9c4076
1. 8dba0fc0.64af8685
0. 583e02ae.490775c0
Benchmark complete.
real 0m0.655s
user 0m0.651s
sys 0m0.002s
[jgrillo@localhost um32]$ time ./target/release/um32 ~/src/boundvariable/sandmark.umz
read 56364 bytes from /home/jgrillo/src/boundvariable/sandmark.umz
trying to Allocate array of size 0..
trying to Abandon size 0 allocation..
trying to Allocate size 11..
trying Array Index on allocated array..
trying Amendment of allocated array..
checking Amendment of allocated array..
trying Alloc(a,a) and amending it..
comparing multiple allocations..
pointer arithmetic..
check old allocation..
simple tests ok!
about to load program from some allocated array..
success.
verifying that the array and its copy are the same...
success.
testing aliasing..
success.
free after loadprog..
success.
loadprog ok.
== SANDmark 19106 beginning stress test / benchmark.. ==
100. 12345678.09abcdef
99. 6d58165c.2948d58d
98. 0f63b9ed.1d9c4076
...
3. 7c7394b2.476c1ee5
2. f3a52453.19cc755d
1. 2c80b43d.5646302f
0. a8d1619e.5540e6cf
SANDmark complete.
real 0m40.584s
user 0m40.451s
sys 0m0.020s
根据 这个源,midmark.um
基准应该 "大约一秒钟" 运行。
以下博客文章和文章提供了对分析 Rust 程序的介绍
依赖项
~165KB