Modifying a gpu accelerated pair style

Hi Lammps Community

I am trying to modify a pair style in lammps to use in my simulations (chosen pair/buck as it has multiple inputs and gpu support). What i do is just changing the forcebuck and e_wdvl equations, and also variable definitions under " init for one type pair i,j and corresponding j,i" headline.

While i was able to completely succeed for cpu calculations, for gpu calculations, i was not able to find out where does the program calls variables from. Can anybody help me?

Thanks in advance
Marcel

Hi Lammps Community

I am trying to modify a pair style in lammps to use in my simulations
(chosen pair/buck as it has multiple inputs and gpu support). What i do is
just changing the forcebuck and e_wdvl equations, and also variable
definitions under " init for one type pair i,j and corresponding j,i"
headline.

While i was able to completely succeed for cpu calculations, for gpu
calculations, i was not able to find out where does the program calls
variables from. Can anybody help me?

not sure what you are asking here. it is difficult to tell, whether
you have a problem reading/understanding C/C++/CUDA code in general or
are not understanding how the flow of control is in LAMMPS/GPU. the
layout of the code for GPU accelerated styles in the GPU package is
fairly straightforward. you have to show us what kind of changes you
did and explain what you did to compile to give any specific advice.

axel.

If we talk about pair buck/coul/long style, the part between the lines 75-212 of file “pair_buck_coul_long.cpp” is existent in file “pair_buck_coul_long_gpu.cpp”. Yet the lines between 261-372 of file “pair_buck_coul_long.cpp” is also modified and i am unable to find how to apply that modifiement to the gpu accelerated style.

Thank you,
Marcel

If we talk about pair buck/coul/long style, the part between the lines
75-212 of file "pair_buck_coul_long.cpp" is existent in file
"pair_buck_coul_long_gpu.cpp". Yet the lines between 261-372 of file
"pair_buck_coul_long.cpp" is also modified and i am unable to find how to
apply that modifiement to the gpu accelerated style.

it looks like you are just guessing from similarity, but do not
understand how the flow of control in the GPU package works in general
and also how derived classes in C++ work.

as far as the first part is concerned, you have not really modified
the GPU execution, but only the CPU force function that is called when
you are distributing the work between the CPU and the GPU. if you do
not do a corresponding change in the GPU library, nothing will happen
or your results will be bogus.

as far as the second part is concerned, the GPU version is a derived
class and thus imports modifications from the parent class unless the
specific function is declared virtual and thus completely overridden
by it replacement in the derived class.

axel.

What I’ve done so far was to modify “pair_buck_coul_long.cpp” file in KSPACE folder and “pair_buck_coul_long_gpu.cpp” file in GPU folder. What i assumed was as the part non-existent in gpu code is irrelevant with gpu calculations, it was going to be called from file “pair_buck_coul_long.cpp”(Is it pair/buck instead?). Yet from my results what i see that it is not. I am attaching the modified .cpp files and all i have done was making lammps with Kspace and gpu packages. i am also providing input and log files for gpu and cpu simulations.

cpu.out (2.51 KB)

ethane.data (99.5 KB)

gpu.out (5.01 KB)

input.in (1.04 KB)

pair_buck_coul_long.cpp (18.4 KB)

pair_buck_coul_long_gpu.cpp (10.5 KB)

What I've done so far was to modify "pair_buck_coul_long.cpp" file in KSPACE
folder and "pair_buck_coul_long_gpu.cpp" file in GPU folder. What i assumed
was as the part non-existent in gpu code is irrelevant with gpu
calculations, it was going to be called from file
"pair_buck_coul_long.cpp"(Is it pair/buck instead?). Yet from my results
what i see that it is not. I am attaching the modified .cpp files and all i
have done was making lammps with Kspace and gpu packages. i am also
providing input and log files for gpu and cpu simulations.

you assumed wrong and i already mentioned in my previous e-mail what
you have to do to get this working. if this is beyond your ability to
read code (no shame in that), then i suggest you try your luck with
tabulation and pair style table instead (that is what tabulation is
good for). this way, you don't need to change code in LAMMPS at all.

axel.

Hi Marcel,

the PairBuckCoulLongGPU class invokes certain functions from the GPU library (lines 51-74 in pair_buck_coul_long_gpu.cpp), which perform initialization, data transfers between CPU and GPU, launching computation on the GPUs and cleaning up. You can see how these functions are implemented by looking at lal_buck_coul_long_ext.cpp in the lib/gpu folder.

For your purposes, you will need to modify the force and energy computation performed on the GPU in the GPU library, from lines 97-145 in lal_buck_coul_long.cu in the lib/gpu folder. Once done, rebuild the library and re-link it to the LAMMPS binary.

Using tabulation per Axel’s suggestion (i.e. using pair table/gpu) is a good choice if you don’t really want to dig in the code.

Hope it helps,
-Trung