Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用了SOA在内的各种优化方法 #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TedHimym
Copy link

@TedHimym TedHimym commented Feb 8, 2022

使用的优化方法

将AOS改为了SOA,vector改为原生数组,for循环int改为size_t,将循环中不必要的计算提出来,使用了std的数学函数,开启了浮点运算的优化选项。
提升最大的还是浮点优化选项,速度快了不止一倍,而是大概6倍的提升。
试了AOS结构体数据对齐的操作,发现并不比SOA慢,可能是数据量还有不同设备的差别引起的。

执行时间对比

  • 优化前:
Initial energy: -13.414000
Final energy: -13.356842
Time elapsed: 2838 ms
  • 优化后:
Initial energy: -13.414012
Final energy: -13.356912
Time elapsed: 286 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant