GPU+VORONOI+KOKKOS+OPENMP reaction force field acceleration

关注 M r . m a t e r i a l   , \color{Violet} \rm Mr.material\ , Mr.material ,  more \color{red}{more}more \color{blue}{more}Much finer\color{orange}{fine}Wonderful \color{green}{color}color !


The main columns include:
  †"LAMMPS Tips": ‾ \textbf{ \underline{\dag"LAMMPS Tips":}} " LAMMPS Tips" :Mainly introduces the use of molecular dynamics ( L ammps LammpsL amm p s ) simulation related installation tutorials, principles and simulation tips (difficulty:★ \bigstar )
  ††"LAMMPS Instance Tutorial—In File Detailed Explanation": ‾ \textbf{ \underline{\dag\dag"LAMMPS Instance Tutorial—In File Detailed Explanation":}} †† " LAMMPS Instance Tutorial - Detailed Explanation of In File" :Mainly introduces the use of molecular dynamics ( L ammps LammpsL amm p s ) to simulate related physical process simulations. (Including: calculation of thermal conductivity, calculation of specific heat capacity at constant pressure, difficulty:★ \bigstar\ bigstar\ bigstar )
  †††"Lammps programming skills and post-processing skills": ‾ \textbf{ \underline{\dag\dag\dag"Lammps programming skills and post-processing skills":}} ††† " Lammps Programming Tips and Post-Processor Tips" :Mainly introduces the post-correlation processing analysis for the dynamic process (trajectory file) of molecular simulation (needs certain programming ability. Difficulty: ★ \bigstar\ bigstar\ bigstar\ bigstar\ bigstar ).
  ††††《Molecular Dynamics Postprocessing Integrated Function—Matlab》: ‾ \textbf{ \underline{\dag\dag\dag\dag《Molecular Dynamics Postprocessing Integrated Function—Matlab》:}} †††† "Molecular Dynamics Postprocessing Integrated Function —Matlab " :It mainly introduces the packaging of the specified function in the post-processing process, which is convenient for users to call directly (a certain programming ability is required, difficulty: ★ \bigstar\ bigstar\ bigstar\ bigstar ).
  †††††"SCI Paper Drawing—Python Drawing Common Templates and Techniques": ‾ \textbf{ \underline{\dag\dag\dag\dag\dag"SCI Paper Drawing—Python Drawing Common Templates and Techniques": }} ††††† " SCI Paper Drawing - Common Templates and Techniques for Python Drawing" :It mainly introduces the visualization of processed data and provides corresponding drawing templates (a certain programming ability is required, difficulty: ★ \bigstar\ bigstar\ bigstar\ bigstar ).
  ††††††"Molecular Simulation - Ovito Rendering Case Tutorial": ‾ \textbf{ \underline{\dag\dag\dag\dag\dag\dag "Molecular Simulation - Ovito Rendering Case Tutorial": }} †††††† "Molecular Simulation - Ovito Rendering Case Tutorial" :Mainly use O vito \rm OvitoOvito software, forL amps \ rm LammpsTrajectory files generated by Lammps for rendering (difficulty:★ \bigstar\ bigstar)。

  Column description (you can browse all the blog posts of the corresponding column after subscribing): ‾ \color{red}{\textbf{ \underline{Column description (you can browse all the blog posts of the corresponding column after subscribing):}}} Column Description (After subscribing, you can browse all blog posts of the corresponding column) :
Note: \color{red} Note:Note: If you only want to subscribe to a single blog post, please contact the blogger's mailbox for consultation. [email protected] \rm lammps\[email protected][email protected]

♠ \spadesuit † \day Open source post-processing integration program: Please pay attention to the column"LAMMPS post-processing - MATLAB sub-function collection"
♠ \spadesuit † \day † \day For a custom post-processing program please email:lammps_materials@163. com \rm lammps\[email protected][email protected]


There are many steps to install lammps and related libraries on the Internet. Here is how to achieve calculation acceleration through gpu-based kokkos+openmp if the in file contains the reaction force field and needs to calculate the stress through the voronoi library when the previous steps are prepared.

GPU-based kokkos accelerated installation

1. Install lammps

Download the lammps stable version installation package, and type the command line in the same directory: tar -xvzf lammpsxxx.tar.gz

2. Install cmake

For specific methods, refer to ubuntu installation cmake_yuanzhoulvpi's blog-CSDN blog_ubuntu installation cmake
After the installation is complete, cmake --version checks the installation version, which cmake checks the installation path

3. cmake related file modification

Execute the following command line in the decompressed lammps directory:

mkdir build_kokkos_cuda 
cd build_kokkos_cuda 

修改 / c m a k e / p r e s e t s \rm /cmake/presets basic.make \rm basic.makein the /cmake/presets folderbasic.make file, according to the package you need to install\rm packageThe package can be modified in the file, or not modified, and can be added later on the command line. willkokkos − cuda.cmake \rm kokkos-cuda.cmakekokkoscuda.cmake file withARCH_GPUARCH \rm ARCH\_GPUARCHDelete the line ARCH_GPUARCH

4. cmake compile

Compile in the build_kokkos_cuda directory. For multi-core + gpu,
refer to the official website
3.7. Packages with extra build options — LAMMPS documentation.
The following variables need to be set for compilation:
insert image description here
insert image description here
HOSTARCH and GPUARCH need to be modified according to the table given on the official website according to your machine model. For the specific model of the machine, please refer to the official website: https://ark.intel.com/content/www/us/en/ark.html#@Processors

insert image description here
Use the following command line to set the above related variables:

cmake -C ../cmake/presets/basic.cmake -C ../cmake/presets/kokkos-cuda.cmake DKokkos_ENABLE_OPENMP=on -DKokkos_ARCH_SKX=on -DBUILD_OMP=on ../cmake

cmake -C ../cmake/presets/basic.cmake -C ../cmake/presets/kokkos-cuda.cmake DKokkos_ARCH_AMPERE86=on -DKokkos_ENABLE_CUDA=on -DCMAKE_CXX_COMPILER= ${
    
    HOME}/lammps/lib/kokkos/bin/nvcc_wrapper ../cmake 

Note the nvcc_wrapper nvcc\_wrapper heren v cc _ w r a pp er needs to write the absolute path, usually in the installedlammps / lib / kokkos / bin \rm lammps/lib/kokkos/binAfter the variables in the lammps/lib/kokkos/bin directory are set, use the following command line to compile, and the following 20 is the number of cores used during compilation:

cmake --build . -- -j20 

After the compilation is complete, it will be in build _ kokkos _ cuda \rm build\_kokkos\_cudaThe executable file lmp \rm lmpis generated under the build_kokkos_cuda directorylmp

5. Test

use lammps lammpsl amm p s built-inexample examplee x ampl e to test, find/examples/reaxff \rm /examples/reaxff/examples/reaxff directory, willin . reaxff . rdx \rm in.reaxff.rdxpair_style\rm pair\_stylein the .reaxff.rdx filepair_style changed toreaxff / kk \rm reaxff/kkreaxff/kk , type the following command in this directory

mpirun -np 2 /home/groupc/lammps-new/lammps-3Nov2022/build_kokkos_cuda/lmp -k on g 1 sf kk -pk kokkos newton on neigh half -in in.reaxff.rdx

6. Install the VORONOI library

1. Install voro++

Enter the installed lammps \rm lammpslambps'lib /voronoi \rm lib/voronoilib/voronoi folder

Available in Voro + + − Download ( lbl . gov ) \rm Voro++ - Download (lbl.gov)Were++Download ( lbl.gov ) to download the voro++ compressed installation package.
You can also use the wget+ URL command to download. After downloading

tar -xvzf voro++-0.4.6.tar.gz

Enter the decompressed voro++ folder, execute make, and execute sudo make install after completion

2. Soft link

cd ... Return to the lib/voronoi directory and type the following command:

 ln -s voro++-0.4.6/src includelink
 ln -s voro++-0.4.6/src liblink 

Will generate two soft links includelink and liblink

3. Compile lammps

Enter the installed lammps/src directory, install the required package in this directory, and install the package according to your needs. For the commands associated with each package, see 6.1. Available Packages — LAMMPS documentation. It is not recommended to directly install all packages that do not require external libraries through the three commands make yes-all, make no-lib, and make no-ext. It is recommended to install the packages you need by using make yes-package, otherwise subsequent compilation may fail error. In addition to the simple package required here, make yes-voronoi is also required, that is, to install the voronoi package we need. Run the make package-status command to check the installation status of the package. After the installation is complete, execute the command make mpi. After the compilation is complete, the lmp_mpi file will be generated in the src directory.

4. Test

进入 l a m m p s / e x a m p l e s / v o r o n o i \rm lammps/examples/voronoi lammps/examples/voronoi type, specifympirun− np N lmp _ mpi ( path ) − in in . voronoi \rm empty -np\ N\ lmp\_empty(path)\ -in\ in.voronoirunnernp N lmp_mpi(path) in in.voronoi  , to test whether it is installed. Herelmp_mpi(path)\rm lmp\_mpi(path)lmp_mpi ( path ) refers to the path of the executable file that needs to be written. If you don’t want to be so troublesome, you can write this path into the system variable.

5. Attention

After the compilation is completed, there are two executable files, one is build _ kokkos _ cuda \rm build\_kokkos\_cudaThere is a lmp \rm lmpin the build_kokkos_cuda directorylmp file, the other islammps/src \rm lammps/srcThere is a lmp _ mpi \rm lmp\_mpiin the lammps/src directory
lmp_mpi file. If you are using a reaction force field in your in file and includecompute voronoi / atom \rm compute voronoi / atomcomputevoronoi/atom command, I recommend using the following method to accelerate and callvoronoi \rm voronoiThe voronoi library is used for calculations. The reason for this is on the one hand becausekokkos \rm kokkosThe kokkos acceleration is mainly done on the gpu (mygpu \rm gpugpu usage reaches 97%), whilevoronoi \rm voronoiThe calculation of the voronoi library is mainly done on the cpu, which can maximize the performance of the gpu and cpu; on the other hand, because I don't know how to usekokkos + openmp \rm kokkos+openmpkokkos+Implement voronoi \rm voronoiat the same time when compiling openmpThe compilation of voronoi is as follows:

  1. Pass kokkos first \rm kokkoskokkos accelerates the entire calculation and outputs the trajectory file. Here, the path of the calculation executable file is written asbuild_kokkos_cuda \rm build\_kokkos\_cudalmp under build_kokkos_cuda \rm lmplmp file path. It is recommended that the output step size of the trajectory file be as small as possible;
  2. Rewrite an in file after completion, use rerun \rm rerun in the in fileThe rerun command reads the trajectory file output in the previous step and performsvoronoi \rm voronoiVoronoi calculates the output data, run in \rm inafter settingin file. Run with purecpu \rm cpucpu calculation, executable file path writesrc \rm srclmp _ mpi \rm lmp\_mpiin the src directorylmp_mpi file path. in \rm inThe settings of the in file can be referred to as follows:

insert image description here

Guess you like

Origin blog.csdn.net/qq_43689832/article/details/127948630