A multi-core optimization method and system based on VASP software

By performing timing evaluation and adaptive master-slave core optimization on the internal loop of the VASP software, the problem of underutilization of slave core computing performance in existing technologies is solved, achieving more efficient computing and energy consumption optimization.

CN115408006BActive Publication Date: 2025-09-09SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211026230.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-25
Publication Date
2025-09-09
Estimated Expiration
2042-08-25

AI Technical Summary

Technical Problem

Existing many-core optimization methods fail to fully utilize the slave-core computing performance of domestic Shenwei processors. Traditional methods increase computing time and unnecessary energy consumption in some cases.

Method used

The internal loop of the VASP software is evaluated through automatic source program instrumentation. The target function is selected and adaptive master-slave core optimization is performed, including differentiated optimization of computation-intensive and communication-intensive functions. The loop structure is analyzed using abstract syntax trees and function call relationship graphs, and timers are inserted to estimate the computational workload and evaluate the efficiency of slave cores.

Benefits of technology

It shortens the calculation time of VASP calculations, reduces unnecessary energy consumption, fully utilizes the computing performance of the core, and improves computing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115408006B_ABST
    Figure CN115408006B_ABST
Patent Text Reader

Abstract

The present invention proposes a many-core optimization method and system based on VASP software, which belongs to the field of many-core optimization. The method adopts a source program automatic instrumentation method to measure the internal loop of the program to be optimized to obtain an estimated value of the computational amount of the loop; according to the estimated value of the computational amount of the internal loop of the function, the optimizability score of the function is calculated, and based on the optimizability score, an optimizable target function is selected; according to the optimizability score, the optimizability target function is divided into computation-intensive and communication-intensive types, and different methods are adopted to optimize the two types of functions; the present invention performs timing evaluation on the computational amount of the internal loop of the program, selects the target function to be optimized, and adaptively selects a slave core for acceleration according to the computational amount, thereby realizing quantitative analysis of the function computational amount, selection of the optimizable position, and adaptive selection of the slave core for acceleration, fully utilizing the computing performance of the many-cores, shortening the computational time of the example operation, and reducing unnecessary energy consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of many-core optimization, and in particular relates to a many-core optimization method and system based on VASP software. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] VASP (Vienna Ab-initio Simulation Package) is a general-purpose material calculation simulation software based on density functional theory, which occupies and consumes a large amount of computing resources of the world's supercomputers. With the iteration of VASP versions, corresponding versions have been made for the architectures and systems of different processors, but there is no version suitable for the domestic Shenwei processor. The Shenwei processor is a domestically developed processor independently developed by my country. Among them, the new generation of Shenwei supercomputer is built based on Shenwei's new generation of high-performance heterogeneous many-core processors and interconnection network chips, integrating 6 core groups, each core group contains an operation control core (master core) and an 8*8 operation core array (that is, 64 slave cores). The main frequency of the master core is 2.1GHz, and the slave core is 2.25GHz. The superposition of the main frequencies of the 64 slave cores has far exceeded that of the master core. If the computing performance of the slave cores can be fully utilized, the improvement of VASP's computing power will be enormous.

[0004] On the one hand, existing many-core optimization methods do not fully utilize the computing performance of slave cores, and the computing power of VASP needs to be further improved. On the other hand, the traditional many-core optimization idea is to directly migrate the parts with larger computational workloads to the slave cores. This approach works well for most examples, but it ignores the problem that migrating some examples to slave cores will increase the computing time. Summary of the Invention

[0005] To overcome the deficiencies of the above-mentioned prior art, the present invention provides a many-core optimization method and system based on VASP software. By timing and evaluating the computational size of the program's inner loop, selecting the target function to be optimized, and adaptively selecting the slave core for acceleration based on the computational size, the present invention implements quantitative analysis of the function's computational size, selection of optimizable locations, and adaptive selection of the slave core for acceleration, thereby fully utilizing the computing performance of the many-cores, shortening the computational time of the example operation, and reducing unnecessary energy consumption.

[0006] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:

[0007] The first aspect of the present invention provides a many-core optimization method based on VASP software;

[0008] A many-core optimization method based on VASP software, comprising:

[0009] The source program automatic instrumentation method is used to measure the internal loop of the program to be optimized and obtain the estimated value of the computational effort of the loop;

[0010] Calculate the function's optimizability score based on the estimated computational effort of the function's inner loop, and select an optimizable target function based on the optimizability score.

[0011] According to the optimizability score, computing mode and data transmission, the optimizable objective functions are divided into computing-intensive and communication-intensive ones, and different methods are adopted to optimize the two types of functions.

[0012] Furthermore, the source program automatic instrumentation method is specifically as follows:

[0013] Build an abstract syntax tree for the source code;

[0014] Find the loop part of each code file based on the abstract syntax tree;

[0015] Generate function call graph;

[0016] Recursively search for loop functions inside the loop body through the function call relationship graph;

[0017] Automatically insert timers before and after loops and loops in functions that call them.

[0018] Furthermore, the automatic insertion timer is specifically:

[0019] Obtain the start line and end line of the VASP source program where the loop structure is located through the abstract syntax tree;

[0020] Insert the start code of the timer into the start line.

[0021] Move one line below the termination line and insert the timer end code.

[0022] Furthermore, the timer obtains the start and end time points of the loop during the program execution, and counts the loop duration, execution times, loop level, and loop variables;

[0023] Perform unique identification processing on the loop structure inserted by the timer, specifically:

[0024] Get the file name, function name, loop level, and loop variable name of the source program where the loop is located, and perform mixed identification to make the loop unique.

[0025] Furthermore, after obtaining the estimated value of the computational amount of the inner loop of each function, the data access size is calculated, the core efficiency index is estimated, the function nodes that do not meet the core efficiency index are deleted, the remaining node functions are scored for optimizability, and the optimizable target function is selected based on the optimizability score.

[0026] Furthermore, we optimize the master and slave cores for computationally intensive functions, using a hybrid compilation method of master and slave cores to port the loop bodies with large computational load to the slave cores.

[0027] For communication-intensive functions, the master and slave cores are optimized and data is loaded into the local storage of the slave core processor to facilitate reading from the slave core.

[0028] Furthermore, the optimization also includes slave-core adaptive optimization: adaptive judgment of slave-core acceleration is performed to determine whether the acceleration point is suitable for slave-core acceleration during case calculation.

[0029] A second aspect of the present invention provides a many-core optimization system based on VASP software.

[0030] A many-core optimization system based on VASP software, including a computational load estimation module, an objective function selection module, and a function optimization module;

[0031] The computational amount estimation module is configured to: measure the internal loop of the program to be optimized by using a source program automatic instrumentation method to obtain an estimated computational amount of the loop;

[0032] The objective function selection module is configured to: calculate an optimizability score of the function according to an estimated value of the computational effort of a loop within the function, and select an optimizable objective function based on the optimizability score;

[0033] The function optimization module is configured to classify the optimizable objective functions into computationally intensive and communication-intensive functions based on the optimizability score, computational mode, and data transmission, and optimize the two types of functions in different ways.

[0034] A third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps of a multi-core optimization method based on VASP software as described in the first aspect of the present invention.

[0035] The fourth aspect of the present invention provides an electronic device, comprising a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps of the multi-core optimization method based on VASP software as described in the first aspect of the present invention are implemented.

[0036] One or more of the above technical solutions have the following beneficial effects:

[0037] The VASP software-based many-core optimization method described in the present invention uses a software engineering perspective to perform call analysis, loop timing, optimizable fraction modeling, and adaptive selection of master and slave core acceleration on the VASP source code. This allows VSAP many-core optimizers to quickly find the location of optimizable functions without having to understand the complex principles of VASP. This solves the problem of traditional optimization where hotspot functions, although computationally expensive, cannot be optimized because they call too many other functions.

[0038] The present invention studies the adaptive method of shortening the communication delay and the master-slave core optimization time, calculates the threshold of the loop body, and adaptively runs the function loop body on the master and slave cores through conditional statements, fully utilizing the computing performance of multiple cores, shortening the calculation time of the example operation, and reducing unnecessary energy consumption.

[0039] Advantages of additional aspects of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0041] Figure 1 This is a flow chart of the method of the first embodiment.

[0042] Figure 2 This is a function call relationship diagram in the first embodiment.

[0043] Figure 3 This is a system structure diagram of the second embodiment. DETAILED DESCRIPTION

[0044] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0045] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.

[0046] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.

[0047] Example 1

[0048] This embodiment discloses a many-core optimization method based on VASP software;

[0049] like Figure 1 As shown, a many-core optimization method based on VASP software includes:

[0050] Step S1 uses the source program automatic instrumentation method to measure the internal loop of the program to be optimized to obtain an estimated value of the computational effort of the loop;

[0051] The VASP source program is written in Fortran, which is relatively complex. The present invention uses a method of automatic source program instrumentation to measure loops within the program to evaluate the computational complexity of the loop. When performing automatic source program instrumentation, the loop is first located, the starting position of the loop is found according to the abstract syntax tree, and timing modules are inserted at the starting and ending positions of the loop. The specific steps are as follows:

[0052] Step S1-1 constructs an abstract syntax tree for the source code

[0053] The abstract syntax tree represents the grammatical structure of the source code in the form of an abstract tree. Each node in the tree represents a structure of a function. The abstract syntax tree tool is used to construct the abstract syntax tree of the VASP source code to describe the structural relationship within the source code file.

[0054] Step S1-2 generates a function call relationship graph

[0055] Use code analysis tools to read the source program and recursively access the functions in the source program to obtain the function call relationship, and finally generate a function call relationship graph in the form of a graph.

[0056] Step S1-3 finds the loop part of each code file according to the abstract syntax tree

[0057] The loop structure in the VASP source program is found through the node information of the abstract syntax tree; the use of the abstract syntax tree to find the loop structure can completely find the start and end parts of the loop structure, avoiding ambiguity caused by character matching.

[0058] Step S1-4 recursively searches for loop functions within the loop body by calling the relationship graph

[0059] Since the loop structure contains more than just simple mathematical calculations, it also calls other functions. Therefore, the functions called within the loop structure are found through the function call relationship diagram. The VASP source program function call relationship is as follows: Figure 2 As shown, there will still be loop structures inside the functions called inside the loop structure, so all loop structures need to be recursively searched.

[0060] Step S1-5 automatically inserts timers before and after the loop and the loop in its calling function

[0061] When calculating the amount of computation in a loop structure, a timer is used. The timer needs to obtain the start and end time points of the loop, so the function of the start and end positions of the loop must be instrumented. During the function instrumentation process, the automatic instrumentation calculator method is used.

[0062] The specific method of the automatic stub calculator is to first obtain the location of the loop structure in the VASP source program through the abstract syntax tree, that is, the start line and the end line, and then sink the code of the start line one line, insert the start code of the timer in the start line, and similarly sink the code starting from the end line one line, and insert the end code of the timer.

[0063] To facilitate timer identification, the loop structure into which the timer is inserted must be uniquely identified. This unique identification process involves obtaining the source program's file name, function name, loop level, and loop variable name, and then combining these identifiers to make the loop unique. The timer must not only count the loop's computational duration, but also the number of loop executions, loop level, and loop variable.

[0064] Step S2 calculates the optimizability score of the function based on the estimated computational effort of the inner loop of the function, and selects an optimizable target function based on the optimizability score;

[0065] According to step S1, the call time, execution times, and recursive depth of each function's inner loop are obtained to describe the size of the loop calculation amount, and the optimizability score of the function is calculated. The specific steps for selecting the optimizable target function are as follows:

[0066] Step S2-1: Calculate the data access size

[0067] The data access size indicates the size of the data accessed during data access in the loop within the function.

[0068] When determining whether a function is optimizable, it is necessary to calculate the data access size generated after distributing data to slave cores. The larger the data access size, the more frequent the communication, and the less suitable the function is for slave core optimization. Therefore, it is necessary to measure the data access size. The specific steps are as follows:

[0069] T represents all arrays, T i It represents the i-th array, access represents function access, sizeof represents the function of finding the array size, and I represents the data access size.

[0070] All arrays involved in the inner loop of the function are T={T1,T2,T3,…,Ti ,…,T n}, if the inner loop of the function can access the array T i , remember access(T i )=1, otherwise access(T i )=0. Then the data access size of the array loop is sizeof(T i ), the data access size of this function is And access(T i )=1.

[0071] Step S2-2 Estimate the efficiency index from the core

[0072] Estimate the slave core efficiency index for the function to measure the efficiency of the function after slave core optimization. The main method is to compare the main core running time with the slave core running time. If the slave core running time is less than the main core running time, it proves that it is suitable for slave core acceleration optimization. The slave core calculation time includes the sum of the running time allocated to each slave core and the communication time. The formula for the slave core efficiency index ε is as follows:

[0073]

[0074]

[0075] Where j represents the number of slave cores, j∈[1,64], t 主核 Indicates the running time of the node in the main core, t 从核 represents the estimated slave core time of the node being transplanted to the slave core, I is the data access size of the function node, t DMA通讯 Indicates the unit DMA communication transmission time, given by the processor and usually a constant.

[0076] Step S2-3: Delete the function nodes that do not meet the core efficiency index.

[0077] The efficiency index ε is estimated for each node from top to bottom. If ε<1, the node and the subtree with the node as the root are deleted.

[0078] Step S2-4: Scoring the remaining node functions for optimization

[0079] After excluding node functions that do not meet the core efficiency index, the remaining node functions are scored for optimizability. The scoring method is to obtain the ratio of the calculation time of all nodes at the same level to the calculation time of the node, and then multiply it by the core efficiency index and the depth of the loop to finally obtain the optimizability score of the node. The deeper the loop depth, the fewer other functions will be called, which is more conducive to core optimization. The optimizability score formula is as follows:

[0080]

[0081] Among them, ω represents the computational amount of nodes at the same level, ω j represents the computational cost of the jth node, ∑ j=1 ω j represents the sum of the computational cost of the node, S represents the node score, and d represents the depth of the loop.

[0082] Step S2-5: Select an optimizable objective function based on the optimizability score

[0083] The optimizable score is calculated for each node function in the pruned abstract syntax tree, and then the scores are sorted in order, and the nodes with the highest scores are selected as the optimizable target functions.

[0084] In step S3, the optimizable objective functions are divided into computationally intensive and communication-intensive functions according to the optimizable scores, computational modes, and data transmission, and different methods are used to optimize the two types of functions.

[0085] We perform a secondary classification on the objective functions with higher optimizability scores: functions with more frequent calculations are classified as computation-intensive, and functions with more data transmission and less calculations are classified as communication-intensive. We use different optimization methods for the two types of functions. The specific optimization methods are as follows:

[0086] (1) Optimize the function into master-slave cores

[0087] For computationally intensive functions, master-slave core optimization is performed, and the master-slave core hybrid compilation method is used to transplant the loop body with large computational workload to the slave core.

[0088] For communication-intensive functions, the master and slave cores are optimized and data is loaded into the local storage of the slave core processor to facilitate reading from the slave core.

[0089] (2) Kernel adaptive optimization method

[0090] During the calculation of a calculation example, the execution time varies due to differences in input file parameters and the materials in the calculation example. In addition, there is a delay in the communication between the master and slave cores. If the sum of the communication delay and the slave core calculation time is greater than the master core calculation time, not only will the overall calculation time not be accelerated, but it will be extended. Therefore, it is necessary to adaptively judge the acceleration of the slave core to determine whether the acceleration point is suitable for slave core acceleration during the calculation example.

[0091] Due to the differences between the cases, it is impossible to test each case. To facilitate processing, a different calculation scale is set for each acceleration point. The acceleration point is set to on and off for different scales, and then the calculation scale suitable for the acceleration point from the core is found.

[0092] (3) Set conditional thresholds for the loop function to be optimized

[0093] Traditional loop optimization often accelerates larger loops on slave cores, but ignores the fact that the number of loops varies across different computational instances, leading to significant differences in computational effort. By setting thresholds, we add adaptive functionality to loop optimization and reduce excessive energy consumption. Specifically:

[0094] Based on the computing scale critical value obtained in the previous step, conditional thresholds are set for each acceleration point. When the computing instance is actually running, whether to use secondary core acceleration is determined based on the threshold. For computing instances that meet the secondary core acceleration computing scale threshold, secondary core optimization is enabled at the acceleration point. For computing instances that do not meet the secondary core acceleration computing scale threshold, secondary core optimization is disabled.

[0095] Example 2

[0096] This embodiment discloses a many-core optimization system based on VASP software;

[0097] like Figure 3 As shown, a many-core optimization system based on VASP software includes a computational load estimation module, an objective function selection module, and a function optimization module;

[0098] The computational amount estimation module is configured to: measure the internal loop of the program to be optimized by using a source program automatic instrumentation method to obtain an estimated computational amount of the loop;

[0099] The objective function selection module is configured to: calculate an optimizability score of the function according to an estimated value of the computational effort of a loop within the function, and select an optimizable objective function based on the optimizability score;

[0100] The function optimization module is configured to classify the optimizable objective functions into computationally intensive and communication-intensive functions based on the optimizability score, computational mode, and data transmission, and optimize the two types of functions in different ways.

[0101] Example 3

[0102] The purpose of this embodiment is to provide a computer-readable storage medium.

[0103] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a multi-core optimization method based on VASP software as described in Example 1 of the present disclosure.

[0104] Example 4

[0105] The purpose of this embodiment is to provide an electronic device.

[0106] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps of a multi-core optimization method based on VASP software as described in Example 1 of the present disclosure are implemented.

[0107] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A many-core optimization method based on VASP software, characterized in that: include: The source program automatic instrumentation method is used to measure the internal loop of the program to be optimized and obtain the estimated value of the computational effort of the loop; Calculate the function's optimizability score based on the estimated computational effort of the function's inner loop, and select an optimizable target function based on the optimizability score. According to the optimizability score, computing mode and data transmission, the optimizable objective functions are divided into computing-intensive and communication-intensive types, and different methods are adopted to optimize the two types of functions. The automatic source program instrumentation method is specifically as follows: Build an abstract syntax tree for the source code; Find the loop part of each code file based on the abstract syntax tree; Generate function call graph; Recursively search for loop functions inside the loop body through the function call relationship graph; Automatically insert timers before and after loops and loops in their calling functions; The automatic insertion timer is specifically: Obtain the start line and end line of the VASP source program where the loop structure is located through the abstract syntax tree; Insert the start code of the timer into the start line. Insert the timer end code into the code below the termination line. Optimize the master and slave cores for computationally intensive functions. Use the master-slave hybrid compilation method to migrate loops with large computational loads to the slave cores. For communication-intensive functions, the master and slave cores are optimized, and data is loaded into the local storage of the slave core processor to facilitate reading from the slave core. Optimization also includes slave-core adaptive optimization: adaptive judgment of slave-core acceleration is performed to determine whether the acceleration point is suitable for slave-core acceleration during case calculation.

2. The many-core optimization method based on VASP software according to claim 1, characterized in that: The timer obtains the start and end time points of the loop during program execution, and counts the loop duration, execution times, loop level, and loop variables; Perform unique identification processing on the loop structure inserted by the timer, specifically: Get the file name, function name, loop level, and loop variable name of the source program where the loop is located, and perform mixed identification to make the loop unique.

3. The many-core optimization method based on VASP software according to claim 1, characterized in that: After obtaining the estimated value of the computational amount of the inner loop of each function, the data access size is calculated, the core efficiency index is estimated, the function nodes that do not meet the core efficiency index are deleted, the remaining node functions are scored for optimizability, and the optimizable target function is selected based on the optimizability score.

4. A many-core optimization system based on VASP software, characterized in that: A VASP software-based many-core optimization method according to any one of claims 1 to 3 is used, comprising a computational load estimation module, an objective function selection module, and a function optimization module; The computational amount estimation module is configured to: measure the internal loop of the program to be optimized by using a source program automatic instrumentation method to obtain an estimated computational amount of the loop; The objective function selection module is configured to: calculate an optimizability score of the function according to an estimated value of the computational effort of a loop within the function, and select an optimizable objective function based on the optimizability score; The function optimization module is configured to classify the optimizable objective functions into computationally intensive and communication-intensive functions based on the optimizability score, computational mode, and data transmission, and optimize the two types of functions in different ways.

5. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps of the many-core optimization method based on VASP software as described in any one of claims 1 to 3 are implemented.

6. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the many-core optimization method based on VASP software as described in any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Many-core program reconstruction method based on cycle segment

    CN112559032A

  • Ocean mode ROMS many-core optimization method

    CN114218736A