Question regarding openmp usage

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
biodc172
Posts: 12
Joined: Sat May 07, 2022 2:59 am

Question regarding openmp usage

Post by biodc172 »

Hi,

I am running the tutorial test cases with 1 opennmp thread and 1 processor, and I found that somehow in the hotspots most of the functions ended with ._omp_fn_.x with multiple times appreance such as
_p_sym_gauss_seidel_msr._omp_fn.3
_p_sym_gauss_seidel_msr._omp_fn.1

this is the hostpot list generated, I tried gprof and perf with the same result.

No. InstSize(B) Time(%) State FunName
1 4512 21.35 ORIGIN _compute_cocgb_rhsb_lsq_v.isra.131
2 3012 5.48 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.3
3 2028 4.22 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.1
4 2368 4.22 ORIGIN _lsq_vector_gradient._omp_fn.74
5 1540 3.00 ORIGIN _reconstruct_scalar_gradient._omp_fn.48
6 648 2.69 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.4
7 700 2.59 ORIGIN _mat_vec_p_l_msr._omp_fn.30
8 1188 2.32 ORIGIN _lsq_scalar_gradient._omp_fn.26
9 872 2.22 ORIGIN _reconstruct_scalar_gradient._omp_fn.49
10 74904 2.19 ORIGIN condli_
11 908 2.14 ORIGIN _lsq_scalar_gradient._omp_fn.28
12 1348 2.06 ORIGIN _reconstruct_vector_gradient._omp_fn.86
13 688 1.98 ORIGIN _lsq_scalar_gradient._omp_fn.20
14 1252 1.96 ORIGIN _reconstruct_vector_gradient._omp_fn.85
15 624 1.62 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.6
16 1196 1.62 ORIGIN _lsq_vector_gradient._omp_fn.73
17 8476 1.35 ORIGIN clsyvt_
18 956 1.34 ORIGIN _reconstruct_vector_gradient._omp_fn.87
19 34816 1.24 ORIGIN predvv_
20 1400 1.18 ORIGIN _lsq_vector_gradient._omp_fn.71
21 38928 1.08 ORIGIN typecl_
22 1256 1.08 ORIGIN _lsq_scalar_gradient._omp_fn.21
23 1972 1.01 ORIGIN cs_convection_diffusion_vector._omp_fn.60
24 2632 1.00 ORIGIN cs_ext_force_flux
25 876 0.96 ORIGIN cs_diffusion_potential._omp_fn.132
26 3496 0.87 ORIGIN cs_convection_diffusion_vector._omp_fn.56
27 648 0.84 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.0
28 5856 0.83 ORIGIN cs_matrix_vector
29 352 0.81 ORIGIN _lsq_scalar_gradient._omp_fn.19
30 1520 0.79 ORIGIN cs_convection_diffusion_vector._omp_fn.65
31 3096 0.77 ORIGIN cs_convection_diffusion_thermal._omp_fn.85
32 788 0.75 ORIGIN _p_sym_gauss_seidel_msr._omp_fn.2

does this mean that the program is still running in parallel? I am confused about it.

Regards.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Question regarding openmp usage

Post by Yvan Fournier »

Hello,

When compiling with OpenMP support (the default for code_saturne), when the compiler encounters an OpenMP section, it "outlines" the contained code, and generates a function matching that section, using names such as the ones you observed.
Then, when running, it will run that function for each thread, with a different loop start and end value for each thread.

So when running one only one thread, those functions are still outlined and called, but do the work for the whole loop.
So, no, on a single thread, you are not running in parallel.

If you want to avoid these functions altogether, you can disable OpenMP at install time (--disable-openmp at configure stage).

Best regards,

Yvan
biodc172
Posts: 12
Joined: Sat May 07, 2022 2:59 am

Re: Question regarding openmp usage

Post by biodc172 »

Yvan Fournier wrote: Wed Aug 10, 2022 12:14 pm Hello,

When compiling with OpenMP support (the default for code_saturne), when the compiler encounters an OpenMP section, it "outlines" the contained code, and generates a function matching that section, using names such as the ones you observed.
Then, when running, it will run that function for each thread, with a different loop start and end value for each thread.

So when running one only one thread, those functions are still outlined and called, but do the work for the whole loop.
So, no, on a single thread, you are not running in parallel.

If you want to avoid these functions altogether, you can disable OpenMP at install time (--disable-openmp at configure stage).

Best regards,

Yvan
Hi,

I tried to add --disbale-openmp in the configure stage, and the configure result still showed that Openmp support: yes. I re-runed the test case the hotspot result is still same. It there any extra step I can do to avoid openmp usage?

Regards.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Question regarding openmp usage

Post by Yvan Fournier »

Hello,

Sorry, there was a bug I had forgotten about, in the master, v7.2, and v7.1 branches where this option was ignored id --disable-openmp-target was not also set.

I just fixed the option (--disable-openmp should be enough), and synced the GitHub mirror for those branches.

Best regards,

Yvan
Post Reply