Finding entry point of LAMMPS when using GPU acceleration

Hi,
I use the following command to use the GPU acceleration.

./lammps-29Oct20/src/lmp_mpi -sf gpu -in in.colloid

I would like to get the PID of the process right after the beginning of lammps and then raise SIGSTOP so that I can attach GDB to the process. The piece of code that I want to write is

  std::cout<< "Attach gdb with the following command and 'c'" << std::endl;
  std::cout<< "  gdb - " << getpid() << std::endl;
  raise(SIGSTOP);

Problem is that I can not find the entry point when using the GPU acceleration. Should I search ./lib/gpu path or elsewhere? Any hint about that?

Two comments:

  1. Your approach to attach GDB is needlessly convoluted and complex.
    Why not simply create a small text file gdbcmds with commands to run when launching gdb, e.g.:
break main
run

and then launch gdb like this:

gdb -x gdbcmds --args ./lammps-29Oct20/src/lmp_mpi -sf gpu -in in.colloid

That will load the command line into GDB, set a desired break point and run the the executable with its arguments. You can easily add desired watch points or additional break points or any other GDB commands to that file.

  1. There is not a single “entry point” to the GPU package code. Rather LAMMPS starts up as a CPU code and occasionally launches functions from the GPU library. Due to the architecture of LAMMPS, those are called in a specific sequence. Since you seem to be using the colloid pair style, this would be either functions from the FixGPU class (which is initialized and called from the “package” command; that is also implied when using -sf gpu) or from the PairColloidGPU. The functions that those classes call from the GPU library are prototyped in the corresponding .cpp source files of the two classes.
1 Like

Thanks for the comments. Based on your comments maybe it is better to express the problem with more details. I am using a tool which traces the GPU instructions and the command is

LD_PRELOAD=/path/to/tool.so ../src/lmp_mpi -sf gpu -in in.colloid

I tried gdb --args LD_PRELOAD=.... or LD_PRELOAD=... gdb --args ../src/lmp_mpi ... but they are not correct. So, I though maybe it is better to force the LAMMPS code to stop and raise a PID while the LD_PRELOAD is in effect and then attach the GDB to the process.

With your comments about using gdb -x gdbcmds --args I am still not able to use that with LD_PRELOAD.

How about searching for this topic on the web?

You are not likely the first person running and for matters like these there is probably a discussion on stackoverflow that will be relevant and rank highly in the search output. Like this one: c - How to use gdb with LD_PRELOAD - Stack Overflow

1 Like