Molecular dynamics simulator based on Viis HLS
Through the Vitis HLS-based molecular dynamics simulator, using the input file reading module, bond force module, non-bonded force module, force accumulation module and motion update module, the problem of inconsistent running results between the simulator and FPGA on the FPGA platform was solved, bit-level consistency was achieved, and the accuracy of the results of the FPGA project was verified.
Patent Information
- Application Number
- CN202510674159.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-09-19
AI Technical Summary
When performing molecular dynamics simulations on an FPGA platform, there are bit-level inconsistencies between the FPGA's running results and those of the software simulator, making it difficult to verify the correctness of the FPGA project's results.
A molecular dynamics simulator based on Vitis HLS is provided. Through the input file reading module, bonding force module, non-bonding force module, force accumulation module and motion update module, the running results of the simulator and FPGA are ensured to maintain bit-level consistency.
The consistency between the FPGA's running results and the running results of the Vitis HLS-based simulator was achieved, thereby verifying the accuracy of the FPGA project results and solving the problem of precision error between the simulator and FPGA running results.
Smart Images

Figure CN120673866A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a molecular dynamics simulator based on Vitis HLS. Background Art
[0002] When developing molecular dynamics projects on FPGA platforms, to verify correctness, the FPGA's execution results are typically compared with those from software simulators, such as GROMACS, AMBER, and OpenMM. Software simulators are typically developed in C / C++ or Python and offer advantages such as high speed, but they only support double-, single-, and half-precision floating-point numbers. On FPGAs, for resource utilization and frequency considerations, fixed-point numbers or floating-point numbers that do not fully comply with the IEEE 754 standard are often used. This results in inconsistencies between the FPGA's and the software simulator's results, even for a single time step. Furthermore, molecular dynamics simulations are an iterative process, and accumulated errors can lead to complete inconsistencies between the final FPGA's and the software simulator's results, making it difficult to verify the correctness of the results from the FPGA project. Summary of the Invention
[0003] In order to solve the problem of inconsistent running results between FPGA and software simulator in the prior art, the present invention provides a molecular dynamics simulator based on Vitis HLS that can maintain bit-level consistency with the running results of FPGA.
[0004] To achieve the above object, the technical solution adopted by the present invention is:
[0005] The present invention provides a molecular dynamics simulator based on Vitis HLS, comprising: an input file reading module, used to read input files and obtain initial information of a simulation system; a bonding force module, used to calculate the bonding forces acting on particles at the current time step; a non-bonding force module, used to calculate the non-bonding forces acting on particles at the current time step; a force accumulation module, used to accumulate the calculated bonding forces and non-bonding forces; and a motion update module, used to calculate new velocity information and new position information of particles at the current time step.
[0006] The present invention provides a molecular dynamics simulator based on Vitis HLS, preferably including the following operating steps: S1, converting the format of the input file into the simulator format, and reading the input file by the input file reading module to obtain the initial information of the simulation system; S2, recording the current time step as t, detecting whether the current time step meets the preset conditions, if the preset conditions are met, continuing the simulation calculation of the time step, if the preset conditions are not met, and ending the simulation; S3, the bonding force module calculates the bonding force exerted on the particle in the current time step according to the bond table and the particle information in the initial information; the non-bonding force module calculates the non-bonding force exerted on the particle in the current time step according to the particle information in the box and the initial information; S4, the force accumulation module accumulates the bonding force and the non-bonding force; S5, the motion update module calculates the new velocity information and new position information of the particle in the current time step according to the force information of the particle, adds 1 to the value of the time step t, and re-executes S2.
[0007] The present invention provides a molecular dynamics simulator based on Vitis HLS. Preferably, the number of time steps required for simulation is recorded as T; the preset conditions include: t<T.
[0008] The present invention provides a molecular dynamics simulator based on Vitis HLS. Preferably, steps S1-S5 are compiled and linked to a fixed-point library by a C / C++ compiler to generate an executable file.
[0009] The present invention provides a molecular dynamics simulator based on Vitis HLS. Preferably, in step S3, calculating the non-bonded forces acting on particles at the current time step includes the following methods: S31, obtaining box pairs that need to be calculated for this process according to the ID number of the process; S32, traversing the box pairs of this process to calculate the local non-bonded forces of this process; S33, all processes obtain the complete non-bonded forces through the MPI reduction function.
[0010] The above technical solution has the following advantages or beneficial effects: The present invention provides a molecular dynamics simulator based on Vitis HLS, which relates to the field of data processing and includes: an input file reading module for reading input files and obtaining initial information of the simulation system; a bonding force module for calculating the bonding forces received by particles in the current time step; a non-bonding force module for calculating the non-bonding forces received by particles in the current time step; a force accumulation module for accumulating the calculated bonding forces and non-bonding forces; and a motion update module for calculating the new velocity information and new position information of particles in the current time step. The molecular dynamics simulator based on Vitis HLS provided by the present invention can maintain bit-level consistency with the running results of FPGA, thereby solving the problem of accuracy error between the simulator and the running results of FPGA. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0012] Figure 1 This is a flowchart of an operation of a molecular dynamics simulator based on Vitis HLS provided in Example 1 of the present invention;
[0013] Figure 2 A flowchart of the operation of a molecular dynamics simulator based on Vitis HLS compiled by a C / C++ compiler provided in Example 1 of the present invention;
[0014] Figure 3 A molecular dynamics simulator based on Vitis HLS provided in Example 1 of the present invention generates IP through HLS version code and constructs an operation flow chart of a Vivado project;
[0015] Figure 1-3 Includes: 1. Input file reading module; 2. Bonding force module; 3. Non-bonding force module; 4. Force accumulation module; 5. Motion update module. DETAILED DESCRIPTION
[0016] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0017] Example 1:
[0018] like Figure 1-2 As shown:
[0019] In order to solve the accuracy error problem between the simulator and FPGA in the prior art, the present invention provides a molecular dynamics simulator based on Vitis HLS, including: an input file reading module 1, used to read the input file and obtain the initial information of the simulation system; a bonding force module 2, used to calculate the bonding force exerted on the particle in the current time step; a non-bonded force module 3, used to calculate the non-bonded force exerted on the particle in the current time step; a force accumulation module 4, used to accumulate the calculated bonding force and non-bonded force; and a motion update module 5, used to calculate the new velocity information and new position information of the particle in the current time step.
[0020] When a molecular dynamics simulator based on Vitis HLS provided by the present invention calculates and runs particle information, the file is first read by the input file reading module 1 to obtain the initial information of the simulation system; when the input file is in GROMACS format, the input file module 1 first converts the input file in GROMACS format into the simulator format; then the input file reading module 1 compares and judges the current time step t with the number of time steps T that need to be simulated. When t<T, the simulator continues the simulation calculation of the time step, and ends the simulation when t≥T; then the bonding force module 2 and the non-bonding force module 3 respectively calculate the bonding force and non-bonding force exerted on the particle in the current time step, and the bonding force and non-bonding force are accumulated by the force accumulation module 4, and the motion update module 5 calculates the latest velocity and position information of the current time step, and then the time step t is increased by 1 and the t<T step is re-judged.
[0021] Because Vitis HLS is a high-level synthesis toolkit, it can synthesize C / C++ code into RTL code (csynth), enabling efficient hardware-accelerated FPGA design. Therefore, a Vitis HLS-based simulator can run efficiently, ensuring that the FPGA's operating results are consistent with those of the Vitis HLS-based simulator, thereby ensuring the accuracy of the results of FPGA project verification.
[0022] The molecular dynamics simulator based on Vitis HLS provided by the present invention simulates particle information based on Vitis HLS, so that its running results can be consistent with the running results of FPGA, thereby realizing the accuracy of the results of the FPGA project verification.
[0023] A molecular dynamics simulator based on Vitis HLS provided by the present invention includes the following operating steps: S1, converting the format of an input file into a simulator format, and reading an input file module 1 to read the input file to obtain initial information of a simulation system; S2, recording the current time step as t, detecting whether the current time step meets a preset condition, and continuing the simulation calculation of the time step if the preset condition is met, and ending the simulation if the preset condition is not met; S3, a bonding force module 2 calculates the bonding force exerted on the particle in the current time step according to the bond table and the particle information in the initial information; a non-bonding force module 3 calculates the non-bonding force exerted on the particle in the current time step according to the particle information in the box and the initial information; S4, a force accumulation module 4 accumulates the bonding force and the non-bonding force; S5, a motion update module 5 calculates the new velocity information and new position information of the particle in the current time step according to the force information of the particle, and re-executes S2 after adding 1 to the value of the time step t.
[0024] In a preferred solution of this embodiment, the number of time steps required for simulation is recorded as T; the preset conditions include: t<T.
[0025] On the other hand, Vitis HLS also supports C simulation (csim), which can verify the logical correctness of C / C++ code. However, Vitis HLS also has a disadvantage, that is, the csim process is extremely slow. Taking a system of about 10,000 particles as an example, the time required for simulating a time step is about 10 minutes, which makes it difficult to support simulations of up to tens of thousands of time steps within an acceptable time. In order to solve the problem that the csim of Vitis HLS is too slow, in a preferred embodiment of the present invention, steps S1-S5 are compiled and linked to a fixed-point library by a C / C++ compiler to generate an executable file. In this preferred embodiment, the native csim tool provided by Vitis HLS is no longer used, but the source file is compiled using a C / C++ compiler, and the fixed-point library of Vitis HLS is linked to generate an executable file.
[0026] The molecular dynamics simulator based on Vitis HLS provided by the present invention is compiled by a C / C++ compiler and linked to a fixed-point library, which can effectively solve the problem of Vitis HLS's csim being too slow.
[0027] Since the operation of the non-bonded force calculation module 3 consumes the most time, before there is MPI parallel optimization, a single process will traverse all box pairs and calculate the complete non-bonded forces. If MPI parallel optimization is used, the simulator can simulate a large system of millions of atoms within an acceptable time. In a preferred embodiment, in step S3, the non-bonded forces received by the particles at the current time step are calculated, including the following methods: S31, dividing the box pairs that need to be calculated for this process according to the ID number of the process; S32, traversing the box pairs of this process, and calculating the local non-bonded forces of this process; S33, all processes obtain the complete non-bonded forces through the MPI reduction function.
[0028] The MPI parallel optimization algorithm for the non-bond force calculation module 3 is as follows:
[0029] enter:
[0030] BOX_PAIRS: box pairs required to calculate non-bonded forces;
[0031] N_PAIRS: total number of box pairs;
[0032] BOX_INFO: particle information;
[0033] NP: number of processes;
[0034] Output:
[0035] F: calculated non-bonded force;
[0036] 1:box_pairs = partition(BOX_PAIRS, N_PARIS, myid) / / Partition to obtain the box pairs and the number of box pairs required for calculation in this process;
[0037] 2:Foreach p in box_pairs do / / Traverse the box pairs that need to be calculated in this process;
[0038] 3:cal_f(p,BOX_INFO,F) / / Calculate non-bonded forces based on box pairs;
[0039] 4:end for;
[0040] 5:MPI_Allreduce(F,myid) / / Reduce the non-bond forces of all processes;
[0041] 6:return F.
[0042] In the above MPI parallel optimization algorithm, line 1 divides the box pairs box_pairs that need to be calculated by this process according to the process ID number; lines 2-4 traverse the box_pairs of this process and calculate the local non-bonded forces of this process; line 5, all processes obtain the complete non-bonded forces through the MPI reduction function.
[0043] The above-mentioned MPI parallel optimization algorithm achieves parallelism by dividing the box pairs, because each box pair is unique and there is no dependency between the box pairs.
[0044] like Figure 3 As shown:
[0045] Since it is a complete molecular dynamics simulator based on Vitis HLS, the modules in the simulator can be directly synthesized into IP through the csynth tool and then a complete molecular dynamics FPGA project can be built through the Vivado design suite, which can greatly improve the efficiency of hardware development. Therefore, the molecular dynamics simulator based on Vitis HLS provided by the present invention can generate the IP of each module through the HLS version of the code through the csynth tool, and then build a complete molecular dynamics FPGA project through the Vivado designsuite. Each module is synthesized into RTL and packaged into IP using the csynth tool in the Vitis HLS tool chain; then a complete molecular dynamics FPGA project is built using the Vivado design suite tool chain and the packaged IP; finally, a bitstream is generated and burned onto the board for operation, and the results of the on-board operation are compared with the simulation results of the simulator to form a complete and efficient development process.
[0046] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the application herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not covered by this application. The description and examples are to be considered merely as exemplary, and the true scope and spirit of the present invention are indicated by the appended claims.
[0047] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A molecular dynamics simulator based on Vitis HLS, characterized in that: include: The input file reading module is used to read the input file and obtain the initial information of the simulation system; Bonding force module, used to calculate the bonding force on particles in the current time step; The non-bonded force module is used to calculate the non-bonded forces acting on particles in the current time step; A force accumulation module is used to accumulate the calculated bonding forces and non-bonding forces; The motion update module is used to calculate the new velocity information and new position information of the particle at the current time step.
2. The molecular dynamics simulator based on Vitis HLS according to claim 1, characterized in that The following steps are included: S1, converting the format of the input file into the simulator format, and the input file reading module reads the input file to obtain the initial information of the simulation system; S2, record the current time step as t, detect whether the current time step meets the preset conditions, if the preset conditions are met, continue the simulation calculation of the time step, if not, end the simulation; S3, the bonding force module calculates the bonding force on the particle at the current time step according to the bond table and the particle information in the initial information; the non-bonding force module calculates the non-bonding force on the particle at the current time step according to the box and the particle information in the initial information; S4, the force accumulation module accumulates the bonding force and the non-bonding force; S5, the motion update module calculates the new velocity information and new position information of the particle at the current time step according to the force information of the particle, adds 1 to the value of the time step t, and then re-executes S2.
3. The molecular dynamics simulator based on Vitis HLS according to claim 2, characterized in that The number of time steps required for simulation is recorded as T; the preset conditions include: t<T.
4. The molecular dynamics simulator based on Vitis HLS according to claim 2, characterized in that The steps S1-S5 are compiled and linked to the fixed-point library by a C / C++ compiler to generate an executable file.
5. The molecular dynamics simulator based on Vitis HLS according to claim 2, characterized in that In step S3, the calculation of the non-bonded forces on the particles at the current time step includes the following methods: S31, obtaining the box pairs that need to be calculated for this process according to the process ID number; S32, traversing the box pairs of this process, and calculating the local non-bonded forces of this process; S33, all processes obtain the complete non-bonded forces through the MPI reduction function.