 C++高性能并行编程与优化 -  课件 - 04 从汇编角度看编译器优化倒数避免重复求除法。 解决方案 2 : -ffast-math -ffast-math 选项让 GCC 更大胆地尝试浮点 运算的优化,有时能带来 2 倍左右的提升。 作为代价,他对 NaN 和无穷大的处理,可 能会和 IEEE 标准(腐朽的)规定的不一致 。 如果你能保证,程序中永远不会出现 NaN 和无穷大,那么可以放心打开 -ffast-math 。 数学函数请加 std:: 前缀! • sqrt simd 8. 循环中不变的常量挪到外面来 9. 对小循环体用 #pragma unroll 10. -ffast-math 和 -march=native CMake 中开启 -O3 CMake 中开启 -fopenmp CMake 中开启 -ffast-math 和 -march=native 感谢观看! by 彭于斌( github@archibate ) 录播: https://space0 码力 | 108 页 | 9.47 MB | 1 年前3 C++高性能并行编程与优化 -  课件 - 04 从汇编角度看编译器优化倒数避免重复求除法。 解决方案 2 : -ffast-math -ffast-math 选项让 GCC 更大胆地尝试浮点 运算的优化,有时能带来 2 倍左右的提升。 作为代价,他对 NaN 和无穷大的处理,可 能会和 IEEE 标准(腐朽的)规定的不一致 。 如果你能保证,程序中永远不会出现 NaN 和无穷大,那么可以放心打开 -ffast-math 。 数学函数请加 std:: 前缀! • sqrt simd 8. 循环中不变的常量挪到外面来 9. 对小循环体用 #pragma unroll 10. -ffast-math 和 -march=native CMake 中开启 -O3 CMake 中开启 -fopenmp CMake 中开启 -ffast-math 和 -march=native 感谢观看! by 彭于斌( github@archibate ) 录播: https://space0 码力 | 108 页 | 9.47 MB | 1 年前3
 C++高性能并行编程与优化 -  课件 - 08 CUDA 开启的 GPU 编程fmodf , fabsf , fminf , fmax f 。 https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#math-libraries 稍微快一些,但不完全精确的 __sinf • 两个下划线的 __sinf 是 GPU intrinstics ,精度相当于 GLSL 里的那种。 适合对精度要求不高,但有性能要求的图 __fdividef(x, y) 提供更快的浮点除法 ,和一般的除法有相同的精确度,但是在 2^216 < y < 2^218 时会得到错误的结果。 编译器选项: --use_fast_math • 如果开启了 --use_fast_math 选项,那么所有对 sinf 的调用都会自动被替换成 __sinf 。 • --ftz=true 会把极小数 (denormal) 退化为 0 。 • --prec-div=false --prec-sqrt=false 降低开方的精度换取速度。 • --fmad 因为非常重要,所以默认就是开启的, 会自动把 a * b + c 优化成乘加 (FMA) 指令。 • 开启 --use_fast_math 后会自动开启上述所有。 SAXPY ( Scalar A times X Plus Y ) • 即标量 A 乘 X 加 Y 。 • 这是很多 CUDA 教科书上的 Hello, world0 码力 | 142 页 | 13.52 MB | 1 年前3 C++高性能并行编程与优化 -  课件 - 08 CUDA 开启的 GPU 编程fmodf , fabsf , fminf , fmax f 。 https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#math-libraries 稍微快一些,但不完全精确的 __sinf • 两个下划线的 __sinf 是 GPU intrinstics ,精度相当于 GLSL 里的那种。 适合对精度要求不高,但有性能要求的图 __fdividef(x, y) 提供更快的浮点除法 ,和一般的除法有相同的精确度,但是在 2^216 < y < 2^218 时会得到错误的结果。 编译器选项: --use_fast_math • 如果开启了 --use_fast_math 选项,那么所有对 sinf 的调用都会自动被替换成 __sinf 。 • --ftz=true 会把极小数 (denormal) 退化为 0 。 • --prec-div=false --prec-sqrt=false 降低开方的精度换取速度。 • --fmad 因为非常重要,所以默认就是开启的, 会自动把 a * b + c 优化成乘加 (FMA) 指令。 • 开启 --use_fast_math 后会自动开启上述所有。 SAXPY ( Scalar A times X Plus Y ) • 即标量 A 乘 X 加 Y 。 • 这是很多 CUDA 教科书上的 Hello, world0 码力 | 142 页 | 13.52 MB | 1 年前3
 C++20 STL Features: 1 Year of Development on GitHuband BillyONeal initially implemented this • GH-1048 by statementreply completed this • C++20 STL Features: 1 Year of Development on GitHuband BillyONeal initially implemented this • GH-1048 by statementreply completed this •- Math Constants • GH-261 by SuperWig27 GitHub Development Part 228 How We Use GitHub • Code: linear Product: stl/inc, stl/src • Build system: CMake/Ninja • vcpkg submodule acquires Boost.Math for Special Math • tests/std, tests/libcxx, tests/tr1 (legacy) • llvm-project submodule for libc++'s test 0 码力 | 45 页 | 702.09 KB | 6 月前3
 C++20: An (Almost) Complete OverviewImmediate Functions – consteval  constinit  Class Enums and using Directive  Text Formatting  Math Constants  std::source_location  [[nodiscard(reason)]]  Bit Operations  Small Standard Library Library: An Overview and Use with Custom Types” -- Marc Gregoire Wednesday, September 16 • 13:3077 Math Constants  C++20: An (Almost) Complete OverviewImmediate Functions – consteval  constinit  Class Enums and using Directive  Text Formatting  Math Constants  std::source_location  [[nodiscard(reason)]]  Bit Operations  Small Standard Library Library: An Overview and Use with Custom Types” -- Marc Gregoire Wednesday, September 16 • 13:3077 Math Constants -  Following mathematical constants are defined:  e, log2e, log10e  pi Immediate Functions – consteval  constinit  Class Enums and using Directive  Text Formatting  Math Constants  std::source_location  [[nodiscard(reason)]]  Bit Operations  Small Standard Library 0 码力 | 85 页 | 512.18 KB | 6 月前3
 C++20's weekday_indexeds, etc. effectively, we don’t need to know or understand the details of the wrap-around math, formatting details, etc. We can just use them and be clients of them! Plus, the types often0 码力 | 55 页 | 8.67 MB | 6 月前3 C++20's weekday_indexeds, etc. effectively, we don’t need to know or understand the details of the wrap-around math, formatting details, etc. We can just use them and be clients of them! Plus, the types often0 码力 | 55 页 | 8.67 MB | 6 月前3
共 5 条
- 1













