Open
Conversation
Author
第04讲笔记效果优化前 优化后 优化SOA把AOS改成SOA,虽然没有了面向对象的属性,但更方便数据成块读取 对齐数据对齐成 64 bytes cache line width,有利于CPU 缓存,减少内存访问次数。 AVX256手写AVX指令,可以一次批量处理8个float数据
循环优化把在循环中常量放到循环外层,或者减少部分计算次数
空间换时间把计算中间结果存为全局变量,有利于减少计算次数 cmake配置针对MSVC和G++有单独的配置,这个案例只测试Release所以只把编译选项加入Release。 if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(main PRIVATE $<$<CONFIG:Release>:-march=native -funroll-loops -O3>)
endif()
if (MSVC)
target_compile_options(main PRIVATE $<$<CONFIG:Release>:/arch:AVX2 /fp:fast>)
endif()
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
小彭老师,又好久不见哈,前段时间非常非常忙,现在才有空做作业,请见谅哈