[Build] How to enable the omp mode with new 23Jun2022 version

hi,

  • I download the tarballs from lammps-stable.tar.gz, and it is the new 23Jun2022 version.

  • Then I compile the lammp with make yes-OPENMP and its depends to enable the omp mode, but it seems staill run with std mode.

detail compile: make yes-MOLECULE;  make yes-KSPACE; make yes-OPENMP; make yes-MANYBODY; make yes-RIGID; make no-lib
run: mpirun --allow-run-as-root  -mca pml ucx -mca btl ^vader,tcp,openib,uct -x UCX_TLS=self,sm --bind-to core -np 128 --use-hwthread-cpus lmp_omp -in equ.in
  • When I take a look at the perf.data, the hot function’s name doesn’t attached with omp, so I think it stall run with std mode.
Samples: 67M of event 'cycles', Event count (approx.): 43602299068711                                                                                      
Overhead  Command          Shared Object                                     Symbol                                                                        
  38.88%  lmp_omp          lmp_omp                                           [.] LAMMPS_NS::PairLJCutTIP4PLong::compute                                   ◆
  23.73%  lmp_omp          lmp_omp                                           [.] LAMMPS_NS::NPairFullBinGhost::build                                      ▒
   7.58%  lmp_omp          lmp_omp                                           [.] LAMMPS_NS::NPairHalfBinNewton::build                                     ▒
   3.36%  lmp_omp          libuct.so.0.1.0                                   [.] uct_mm_iface_progress

any suggestion about the way to enable the omp mode ? Thanks !

You have to pay closer attention to the compilation instructions in the manual.
Typing make yes-openmp installs the OPENMP package code, but it does not activate compilation with OpenMP support enabled or compile LAMMPS. Your entire quoted command line only installs/uninstalls packages, but there is no mention of a compilation.

Your command for running LAMMPS only uses MPI parallelism and does not seem to enable the omp suffix. Furthermore the --bind-to core option will prohibit multiple threads to run on different CPU cores.

We generally recommend people with limited experience in customizing makefiles and compiler flags to build LAMMPS using CMake. This can and will autodetect and enable OpenMP and MPI support transparently, if your software installation supports it.

Of course, you can only have multi-threaded execution, if you are using styles for which multi-threaded versions exist.

A good test can be made using the statically linked pre-compiled executable from LAMMPS Static Linux Binary Download Repository: .
This has the OPENMP package (and most other packages) included and OpenMP enabled (but no MPI).
You can run with env OMP_NUM_THREADS=8 ./lmp -in equ.in -sf omp and the run should multi-thread across 8 CPU cores, if the input uses styles with multi-thread support.

This is all explained in great details in the documentation: 7. Accelerate performance — LAMMPS documentation

Thanks for the detail instruction.

  • I see the omp suffix in the perf.data now. (I compile the project with make -j omp)
run: env OMP_NUM_THREADS=8 perf record -e cycles -C0-3 mpirun --allow-run-as-root  -mca pml ucx -mca btl ^vader,tcp,openib,uct -x UCX_TLS=self,sm --bind-to core -np 128 --use-hwthread-cpus lmp_omp -in equ.in -sf omp
Samples: 118M of event 'cycles', Event count (approx.): 77068317899171                                                                                     
Overhead  Command          Shared Object                                     Symbol                                                                        
  24.49%  lmp_omp          [kernel.kallsyms]                                 [k] finish_task_switch                                                       ◆
  15.13%  lmp_omp          lmp_omp                                           [.] .omp_outlined..11507                                                     ▒
  11.95%  lmp_omp          lmp_omp                                           [.] .omp_outlined..8553                                                      ▒
   4.47%  lmp_omp          lmp_omp                                           [.] .omp_outlined..8639                                                      ▒
   4.01%  lmp_omp          libuct.so.0.1.0                                   [.] uct_mm_iface_progress                                                    ▒
   3.53%  lmp_omp          libc-2.28.so                                      [.] __sched_yield