自动确定作用域的详细结果显示在编译器注释中。在使用 -g 选项编译源时,编译器将生成内联注释。可以使用 er_src 命令查看该注释,如以下示例所示。er_src 命令作为 Oracle Developer Studio 软件的一部分提供。有关更多信息,请参见 er_src(1) 手册页或Oracle Developer Studio 12.5:性能分析器。
要快速检查自动确定作用域的结果,请使用 -xvpara 选项进行编译。使用 —xvpara 进行编译可大体确定针对特定构造的自动确定作用域是否成功。
示例 16 使用 -xvpara 检查自动确定作用域的结果% cat source1.f INTEGER X(100), Y(100), I, T C$OMP PARALLEL DO DEFAULT(__AUTO) DO I=1, 100 T = Y(I) X(I) = T*T END DO C$OMP END PARALLEL DO END % f95 -xopenmp -xO3 -xvpara -c -g source1.f "source1.f", line 2: Autoscoping for OpenMP construct succeeded. Check er_src for details
如果针对特定构造的自动确定作用域失败,指定 -xvpara 时将发出警告消息,如以下示例所示。
示例 17 使用 -xvpara 时自动确定作用域失败% cat source2.f INTEGER X(100), Y(100), I, T C$OMP PARALLEL DO DEFAULT(__AUTO) DO I=1, 100 T = Y(I) CALL FOO(X) X(I) = T*T END DO C$OMP END PARALLEL DO END % f95 -xopenmp -xO3 -xvpara -c -g source2.f "source2.f", line 2: Warning: Autoscoping for OpenMP construct failed. Check er_src for details. Parallel region will be executed by a single thread.
有关自动确定作用域的更多详细信息将显示在 er_src 显示的编译器注释中,如以下示例所示。
示例 18 使用 er_src 显示的自动确定作用域详细结果% er_src source2.o Source file: source2.f Object file: source2.o Load Object: source2.o 1. INTEGER X(100), Y(100), I, T Source OpenMP region below has tag R1 Variables autoscoped as SHARED in R1: y Variables autoscoped as PRIVATE in R1: t, i Variables treated as shared because they cannot be autoscoped in R1: x R1 will be executed by a single thread because autoscoping for some variable s was not successful Private variables in R1: i, t Shared variables in R1: y, x 2. C$OMP PARALLEL DO DEFAULT(__AUTO) Source loop below has tag L1 L1 parallelized by explicit user directive L1 autoparallelized L1 parallel loop-body code placed in function _$d1A2.MAIN_ along with 0 inner loops L1 could not be pipelined because it contains calls 3. DO I=1, 100 4. T = Y(I) 5. CALL FOO(X) 6. X(I) = T*T 7. END DO 8. C$OMP END PARALLEL DO 9. END 10.