Can't fully use my PC resources when run LAMMPS

Hello,

My cpu is AMD® Ryzen 7 pro 5750g with radeon graphics × 16, and I compile LAMMPS with Open MPI 4.1.2 with the default compile option ‘make mpi’. In my opinion, I can run my task by 'mpirun -np 16 lmp_mpi -in in.script’, but the fact is I can only run by ‘mpirun -np 8 lmp_mpi -in in.quartzmelting’ as a maximum value.
If I use 'mpirun -np 16 lmp_mpi -in in.script’, there is an error:

There are not enough slots available in the system to satisfy the 16
slots that were requested by the application:

lmp_mpi

Either request fewer slots for your application, or make more slots
available for use.

A “slot” is the Open MPI term for an allocatable unit where we can
launch a process. The number of slots available are defined by the
environment in which Open MPI processes are run:

  1. Hostfile, via “slots=N” clauses (N defaults to number of
    processor cores if not provided)
  2. The --host command line parameter, via a “:N” suffix on the
    hostname (N defaults to 1 if not provided)
  3. Resource manager (e.g., SLURM, PBS/Torque, LSF, etc.)
  4. If none of a hostfile, the --host command line parameter, or an
    RM is present, Open MPI defaults to the number of processor cores

In all the above cases, if you want Open MPI to default to the number
of hardware threads instead of the number of processor cores, use the
–use-hwthread-cpus option.

Alternatively, you can use the --oversubscribe option to ignore the
number of available slots when deciding the number of processes to
launch.

I can only use ‘mpirun -np 8 lmp_mpi -in in.quartzmelting’ , but when I monitor the usage of the system resource, I only use half of it!

I really want to know how I can fix it. (Maybe the problem of multithreads and it’s not a problem? I am not sure.)

Thank you very much!

BR,
Fan

There is nothing really to fix on the LAMMPS side.

The situation is mostly a problem of understanding your hardware and how to use it. The error you are getting is from the OpenMPI library and not from LAMMPS. The reason for that is that your CPU has 8 (eight!) cores and not 16. The doubling of the cores is due to the availability of Simultaneous multithreading - Wikipedia This won’t get you 16 cores, but makes your 8 cores look like 16.

The gain in performance from SMT for scientific applications like LAMMPS is very limited, often in the range of 10-20%, for others it may be less or you could even see a slowdown. The reason for that is that all processes now have to share the physical CPU cores, the CPU cache and the memory bandwidth to the RAM. So with using 8 MPI processes you are using your CPU properly.

The OpenMPI library will restrict you to using only the real hardware cores. This is part of how the library is configured by default. You can override this with the command line as indicated in the error message, e.g. with mpirun -np 8 --host localhost:16 [...]

Hi Akohlmey,

Thank you very much for your instructions! I basically understand it.
Thank you again.

BR,
Fan