“顶级重新排序”是什么意思?

时间:2017-07-20 17:44:46

标签: optimization fortran mpi gfortran

我有一个Fortran的开放式MPI代码,它在没有使用优化标志时编译并运行没有错误。当我接通-O1标志时,执行时会出现Segmentation Fault错误。导致此问题的唯一优化标志是 -ftoplevel-reorder 。你能直观地解释这个标志的作用以及发现代码中的错误(如果有的话)的最佳策略是什么?

1 个答案:

答案 0 :(得分:4)

来自https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

-fno-toplevel-reorder

    Do not reorder top-level functions, variables, and asm statements. Output them in the same order that they appear in the input file. When this option is used, unreferenced static variables are not removed. This option is intended to support existing code that relies on a particular ordering. For new code, it is better to use attributes when possible.

    Enabled at level -O0. When disabled explicitly, it also implies -fno-section-anchors, which is otherwise enabled at -O0 on some targets.

你可能正在访问一个超出界限的数组,并且根据局部变量放在堆栈上的方式,后果会从不明显的崩溃到致命的崩溃。

相关问题