AztecOO transplantation optimization method and system based on Shenwei super computer

By transplanting the Epetra and AztecOO software packages to Sunway's new generation supercomputer and optimizing them, its performance problems on the SW26010Pro architecture were solved, efficient numerical calculations were achieved, computing performance and development efficiency were improved, and it became a heterogeneous supercomputing platform. Optimization solutions are provided.

CN118656126APending Publication Date: 2024-09-17QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410820407.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

The existing Epetra and AztecOO software packages have not yet been adapted to the SW26010Pro architecture of Sunway's new generation supercomputer, resulting in a lower performance limit on this platform and affecting the execution efficiency of numerical computing applications.

Method used

Epetra and AztecOO were transplanted to the main core of the new generation Sunway supercomputer, and manual instrumentation was used to analyze computing hot spots, adjust the array allocation method, and use the shared LDM mechanism and Athread acceleration thread library for data batch transmission to achieve parallel computing from the core.

Benefits of technology

It improves the overall performance of the software library, improves the development efficiency of numerical calculations, provides a reference for the development of heterogeneous many-core architecture platforms, and significantly improves the computing performance of sparse linear equation solving.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656126A
    Figure CN118656126A
Patent Text Reader

Abstract

The invention relates to the technical field of electronic information, and provides an AztecOO transplantation optimization method and system based on a Shenwei super computer. The method comprises the following steps of: transplanting Epera and AztecOO to a main core of a new-generation Shenwei super computer; on the basis of calculation hotspots of the transplanted main program, fine-grained hotspot analysis is conducted in the main program in a manual instrumentation mode, a calculation dense function is found, and the calculation dense function is a subprogram of sparse matrix vector multiplication of a CSR format; changing the format of an array with an assumed size in the subprogram into a fixed memory allocation mode, and adjusting the specific size of the array; equally dividing the data in the sparse matrix according to rows, and averagely distributing the data to all slave cores, so that the slave cores perform thread-level parallel computing on the distributed data, and the purpose that the slave cores can complete data computing at the same time is achieved; slave core memory access optimization is carried out from the two aspects of memory access speed and memory access bandwidth, the bandwidth utilization rate and the memory access efficiency are improved, and the program calculation performance is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of electronic information technology, and in particular to an AztecOO transplantation optimization method and system based on a Sunway supercomputer. 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] Epetra and AztecOO are two important software packages in the Trilinos project. Trilinos is a collection of mathematical software libraries developed by Sandia National Laboratory. Its goal is to develop parallel solver algorithms and libraries within an object-oriented software framework for solving large-scale, complex multi-physics engineering and scientific applications. Trilinos contains a collection of open source software packages with many different functions and modules, which can directly or iteratively solve dense, sparse linear and nonlinear equations, as well as eigenvalue calculations. Epetra provides a framework for distributed memory parallel linear algebra operations, including operations on sparse and dense matrices, vectors and linear systems, as well as some commonly used linear algebra algorithms and data structures. It provides a foundation for building large-scale parallel computing applications. AztecOO is a parallel iterative solver for solving sparse linear systems. AztecOO is built on the basis of Epetra and takes advantage of the distributed memory parallel linear algebra operations provided by Epetra to provide users with an efficient way to solve large-scale sparse linear systems. Epetra and AztecOO work together to solve large-scale sparse linear equation problems.

[0004] As one of the most advanced high-performance computing platforms in the world, the new generation of Sunway supercomputer based on the domestic Sunway processor has powerful computing capabilities. The system inherits and develops the "Sunway Taihu Light" architecture, and the domestic new generation of multi-core processor SW26010Pro inherits and develops the SW26010 processor architecture. For the SW26010Pro heterogeneous multi-core processor in the new generation of Sunway supercomputer, 6 core groups are integrated, containing a total of 390 processing elements. Each core group has a master core and 64 slave cores, all of which use the self-developed SW64 instruction set and share 16GB of main memory. Each slave core is configured with 256KB of local memory (LDM). The slave core can access the main memory in two ways, namely, directly and sporadically accessing the main memory data and transferring data in batches between the main memory and the local LDM through direct memory access (DMA).

[0005] As an important basis for improving the execution efficiency of numerical computing applications, the migration and optimization of mathematical software libraries on the new generation of Sunway supercomputers has become an urgent problem to be solved at this stage. For a class of parallel applications that use Epetra and AztecOO software packages as underlying calls, their performance lower limit depends on the optimization effect of such software packages under the current architecture. However, the new generation of Sunway supercomputers do not currently have the Epetra and AztecOO modules suitable for the SW26010Pro architecture. Summary of the invention

[0006] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides an AztecOO transplantation optimization method and system based on the Sunway supercomputer. The present invention improves the overall performance of the software library and provides more efficient development efficiency for researchers in numerical computing.

[0007] In order to achieve the above object, the present invention adopts the following technical solution:

[0008] The first aspect of the present invention provides an AztecOO transplantation optimization method based on the Sunway supercomputer.

[0009] An AztecOO transplantation optimization method based on the Shenwei supercomputer, comprising:

[0010] Porting Epetra and AztecOO to the main core of the new generation Sunway supercomputer;

[0011] Based on the computational hotspots of the transplanted main program, a fine-grained hotspot analysis is performed in the main program by manual plugging to find computationally intensive functions, which are subroutines for sparse matrix-vector multiplication in CSR format.

[0012] The assumed size array format in the subroutine is changed to a fixed memory allocation mode, and the specific size of the array is adjusted; the data in the sparse matrix is ​​equally divided by rows, and evenly distributed to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time;

[0013] The shared LDM mechanism of the Shenwei multi-core processor is adopted to divide the preset storage space from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; the direct memory access method in the Athread acceleration thread library is used between the slave core and the master core to perform batch data transmission.

[0014] Furthermore, the process of porting Epetra and AztecOO to the main core of the new generation Sunway supercomputer includes: using the source code method to compile and install the build tool cmake, modifying the Module file of cmake; configuring cmake environment variables; entering the source code directory and creating a new directory for building, entering the new directory, and using cmake to perform basic configuration of Epetra and AztecOO; typing make to execute the Makefile generated by cmake to build Epetra and AztecOO; typing make install to install, and the software will be installed to the directory specified during the configuration phase; running the built-in calculation examples in the test program on the Sunway main core.

[0015] Furthermore, the process of typing make to execute the Makefile generated by cmake to build Epetra and AztecOO includes: entering the src file directory of aztecoo and epetra, typing make to execute the corresponding Makefile file, compiling all source files into corresponding .o target files, and linking all .o into static libraries: libaztecoo.a and libepetra.a.

[0016] Furthermore, based on the computational hotspots of the transplanted main program, a manual plugging method is used to perform fine-grained hotspot analysis inside the main program to find computationally intensive functions, including: dividing the main program into different modules according to functions, timing each module separately using the MPI_Wtime() timing function, comparing the proportion of computational time of each module, finding the module with the longest computational time, and then further analyzing the next layer of functions called by the module, repeating the above-mentioned fine-grained hotspot analysis until the computationally intensive algorithm part in the program algorithm that meets the acceleration of the Sunway new generation supercomputer architecture is found, that is, the computationally intensive function.

[0017] Furthermore, the process of changing the assumed size array format in the subroutine to a fixed memory allocation method and adjusting the specific size of the array includes: changing the assumed size array format in the subroutine to a fixed memory allocation method, passing the actual array size to the subroutine when calling the subroutine through the upper-level function, and combining the theoretical basis of the CSR compression matrix format to determine the specific size of the array.

[0018] Furthermore, the process of dividing the data in the sparse matrix equally by rows and distributing them evenly to all slave cores includes: dividing the data in the sparse matrix equally by rows by one-dimensional partitioning method, each core group is composed of 64 slave cores, for a matrix with m rows, each slave core calculates m / 64 rows, and when there are extra matrix rows, the extra matrix rows are evenly distributed to the first few slave cores with slave core ID.

[0019] Furthermore, the subroutine includes: val() array, pntr() array, indx() array, x() array and y() array. For accessing the x() array, the shared LDM mechanism of the Shenwei multi-core processor is adopted to set a shared space.

[0020] Furthermore, the use of the direct memory access (DMA) method in the Athread acceleration thread library between the slave core and the main core to perform batch data transmission includes: using the crts_dma_iget interface and the crts_dma_iput interface in the Athread acceleration thread library to realize batch data transmission between the slave core and the main core, realizing data transmission between the main memory and the LDM in a direct memory access channel manner, and controlling the data exchange between the main core and the slave core while the slave core performs some computing operations unrelated to the transmitted data.

[0021] The second aspect of the present invention provides an AztecOO transplantation optimization system based on the Sunway supercomputer.

[0022] An AztecOO transplantation optimization system based on the Sunway supercomputer, comprising:

[0023] A porting module configured to: port Epetra and AztecOO to the main core of the new generation Sunway supercomputer;

[0024] The analysis and positioning module is configured to: perform fine-grained hot spot analysis in the main program based on the computational hot spots of the transplanted main program by manual plugging, and find computationally intensive functions, which are sparse matrix-vector multiplication subroutines in CSR format;

[0025] The slave core parallel module is configured to: change the assumed size array format in the subroutine to a fixed memory allocation mode, and adjust the specific size of the array; divide the data in the sparse matrix equally by row, and evenly distribute it to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time;

[0026] The slave core access module is configured as follows: using the shared LDM mechanism of the Shenwei multi-core processor, a preset storage space is divided from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; and the direct memory access (DMA) method in the Athread acceleration thread library is used between the slave core and the master core to perform batch data transmission.

[0027] A third aspect of the present invention provides a computer-readable storage medium.

[0028] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the AztecOO transplantation optimization method based on the Sunway supercomputer as described in the first aspect above.

[0029] A fourth aspect of the present invention provides a computer device.

[0030] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the AztecOO transplantation optimization method based on the Sunway supercomputer as described in the first aspect above are implemented.

[0031] Compared with the prior art, the present invention has the following beneficial effects:

[0032] The present invention includes, in sequence, the implementation of the transplantation of Epetra and AztecOO on the main core of the new generation Sunway supercomputer, the analysis of the computing process of the transplanted program and the location of the program hotspots, the design of a slave core parallel solution for the program computing hotspot part, and the optimization of slave core memory access in terms of memory access speed and memory access bandwidth. The present invention not only realizes the transplantation and optimization of Epetra and AztecOO on the new generation of Sunway supercomputers for the first time, but also provides a good reference example for the development of such software and applications on heterogeneous many-core architecture platforms. At the same time, it helps to enrich the software ecology of the platform where the Sunway many-core processor is located, and is of great significance for realizing its own supporting numerical calculation function library on heterogeneous supercomputers.

[0033] The present invention utilizes the swprof performance analysis tool of the new generation supercomputer of Shenwei to analyze the typical example program therein, adopts the form of manual stub, performs fine-grained hot spot analysis inside the program, finds the computationally intensive algorithm part in the program algorithm that meets the acceleration of the architecture of the new generation supercomputer of Shenwei, rewrites the algorithm for the programming platform of the new generation supercomputer of Shenwei, performs slave-core design on the fortran77 subroutine of the computationally intensive function epetra_dcrsmv: sparse matrix vector multiplication (SpMV) algorithm in CSR format obtained by the hot spot analysis, writes the master-slave core code by calling the Athread acceleration thread library function interface customized by Shenwei, and accelerates the above computational hot spots by using the master-slave acceleration model, thereby improving the overall performance of the software.

[0034] The present invention optimizes slave core memory access with respect to memory access speed and memory access bandwidth: by reasonably utilizing slave core LDM space, computing core data is allocated to LDM as needed, thereby improving memory access speed; and adopting direct memory access (DMA) to realize data exchange between main memory and LDM, thereby reducing the problem of excessive main memory access pressure, improving memory access bandwidth, and further improving program computing performance.

[0035] The present invention utilizes the Shenwei master-slave acceleration model to perform slave-core parallelization design on the computational hot spots of the core functions in the library according to the algorithm characteristics, thus achieving two-level parallel acceleration.

[0036] The present invention combines the core computing data of the algorithm, rationally utilizes Shenwei communication and computing components, optimizes memory access from the core in terms of memory access speed and bandwidth, improves bandwidth utilization and memory access efficiency, and greatly enhances program computing performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings in the specification, 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.

[0038] Figure 1 It is a flow chart of the AztecOO transplantation optimization method based on the Sunway supercomputer shown in the present invention;

[0039] Figure 2 It is a schematic diagram of a master-slave acceleration model of a hotspot function shown in the present invention;

[0040] Figure 3 It is a comparison chart of the execution time of solving the sparse linear equations problem using the GMRES algorithm in the AztecOO parallel iterative solver under a single core group shown in the present invention;

[0041] Figure 4 It is a comparison chart of execution time of solving sparse linear equations problem using PCG algorithm in AztecOO parallel iterative solver under multiple core groups shown in the present invention. DETAILED DESCRIPTION

[0042] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

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

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

[0045] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and systems according to various embodiments of the present disclosure. It should be noted that each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code may include one or more executable instructions for implementing the logical functions specified in each embodiment. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the flowchart and / or block diagram, and the combination of boxes in the flowchart and / or block diagram can be implemented using a dedicated hardware-based system that performs a specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.

[0046] The present invention discloses an AztecOO transplantation optimization method and system based on a Shenwei supercomputer, which is mainly constructed based on a new generation of Shenwei supercomputers. Combined with the characteristics of the Shenwei supercomputer compiler, the transplantation of Epetra and AztecOO on the main core of the new generation of Shenwei supercomputers is realized. And the program is analyzed for hot spots using a performance analysis tool, and according to the heterogeneous programming model of the new generation of Shenwei supercomputers, the hot spots of the core functions are divided into the unique slave cores of Shenwei to achieve two-level parallelism. After two-level parallelism, the program can be significantly accelerated, but the implementation of master-slave accelerated parallelism neither considers the memory access overhead between the slave core and the main memory, nor fully utilizes the communication and computing components between the master and slave cores. Therefore, it is necessary to combine the general optimization strategy of the new generation of Shenwei supercomputers to further optimize the program hot spots, and finally achieve efficient parallel solution, thereby improving the overall performance of the software library.

[0047] Embodiment 1

[0048] like Figure 1As shown, this embodiment provides an AztecOO transplantation optimization method based on the Shenwei supercomputer. This embodiment uses the method applied to the server as an example. It can be understood that the method can also be applied to terminals, and can also be applied to systems including terminals, servers, and systems, and is implemented through the interaction between terminals and servers. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network servers, cloud communications, middleware services, domain name services, security services CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. In this embodiment, the method includes the following steps:

[0049] Porting Epetra and AztecOO to the main core of the new generation Sunway supercomputer;

[0050] Based on the computational hotspots of the transplanted main program, a fine-grained hotspot analysis is performed in the main program by manual plugging to find computationally intensive functions, which are subroutines for sparse matrix-vector multiplication in CSR format.

[0051] The assumed size array format in the subroutine is changed to a fixed memory allocation mode, and the specific size of the array is adjusted; the data in the sparse matrix is ​​equally divided by rows, and evenly distributed to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time;

[0052] The shared LDM mechanism of the Shenwei multi-core processor is adopted to divide the preset storage space from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; the direct memory access (DMA) method in the Athread acceleration thread library is used between the slave core and the master core for batch data transmission.

[0053] The specific steps of the present invention are described below:

[0054] 1. Transplantation of Epetra and AztecOO of the present invention on the main core of the new generation Sunway supercomputer

[0055] Build tool: cmake, basic compilation environment: C compiler, C++ compiler, Fortran compiler, related dependent libraries: MPI library, BLAS and LAPACK basic mathematics library.

[0056] Before porting Epetra and AztecOO to the main kernel, you need to ensure that the dependencies are ready in the system:

[0057] (1) Installation of the build tool cmake;

[0058] In the Shenwei system, the basic compilation environment and related dependent libraries are already prepared, so before the main core is ported, only the configuration and installation of the build tool cmake is required. Epetra and AztecOO use cmake as their build system to manage their complex build process, including configuring each module, detecting dependencies, setting compilation options, and generating Makefiles or other build scripts required for the build system.

[0059] Step 1: Use the source code method to compile and install the build tool cmake;

[0060] Step 2: Modify the cmake Module file;

[0061] How to: Enter<Your cmake path> / share / cmake-3.26 / Modules / FortranCInterface.cmake file, where<Your cmake path> The absolute path to the cmake installation.

[0062] Add the following line above line 381 #Report results:

[0063] set(FortranCInterface_VERIFY_${lang}_COMPILED true)

[0064] Add above line 392 #Error if compilers are incompatible: set(FortranCInterface_VERIFIED_${lang}true)

[0065] Reason for step 2: In order to pass the mixed compilation check that comes with cmake, the general GNU or INTEL C language compiler will add -lgfortran or -lfortcore or similar content during the check, but the Shenwei compiler will not, so you need to manually add -lgfortran to CMAKE_CXX_FLAGS.

[0066] Step 3: Configure cmake environment variables

[0067] Method: Enter ~ / .bashrc and add alias cmake=×××× / bin / cmake, where ×××× is the absolute path.

[0068] (2) Use the build tool cmake to configure the build process of Epetra and AztecOO;

[0069] Step 1: Go into the source code directory and create a new directory for building (usually called build).

[0070] Step 2: Go to the build directory and use cmake to perform basic configuration of Epetra and AztecOO: Type the following configuration command options.

[0071] cmake.. / -DTrilinos_ENABLE_ALL_PACKAGES=OFF\

[0072] -DTrilinos_ENABLE_AztecOO=ON\

[0073] -DTrilinos_ENABLE_Epetra=ON\

[0074] -DTPL_ENABLE_BLAS=ON\

[0075] -DBLAS_LIBRARY_DIRS='××××'\

[0076] -DBLAS_LIBRARY_NAMES='××××.a'\

[0077] -DTPL_ENABLE_LAPACK=ON\

[0078] -DLAPACK_LIBRARY_DIRS='××××'\

[0079] -DLAPACK_LIBRARY_NAMES='××××.a'\

[0080] -DCMAKE_C_COMPILER=mpicc\

[0081] -DCMAKE_CXX_COMPILER=mpic++\

[0082] -DCMAKE_CXX_FLAGS="-lgfortran"\

[0083] -DCMAKE_C_FLAGS="-lgfortran"\

[0084] -DCMAKE_Fortran_COMPILER=mpifort\

[0085] -DCMAKE_INSTALL_PREFIX='××××'\

[0086] -DTPL_ENABLE_MPI=ON\

[0087] -DTrilinos_ENABLE_TESTS=OFF

[0088] The above configuration command options can be divided into 4 parts: selecting the list of packages to enable, configuring dependent libraries, configuring compiler and linker options, and setting the installation path.

[0089] in:

[0090] -DTrilinos_ENABLE_ALL_PACKAGES=OFF,

[0091] -DTrilinos_ENABLE_AztecOO=ON,

[0092] -DTrilinos_ENABLE_Epetra=ON.

[0093] Used to select the list of software packages to be used. Trilinos is a large and complex software collection, so it usually follows the principle of enabling the corresponding software packages when building what functions are needed. According to the needs, the present invention first turns off the option of enabling all software packages and enables AztecOO and Epetra.

[0094] in:

[0095] -DCMAKE_C_COMPILER=mpicc

[0096] -DCMAKE_CXX_COMPILER=mpic++

[0097] -DCMAKE_CXX_FLAGS="-lgfortran"

[0098] -DCMAKE_C_FLAGS="-lgfortran"

[0099] -DCMAKE_Fortran_COMPILER=mpifort

[0100] Used to configure compiler and linker options, -DCMAKE_C_COMPILER = mpicc, -DCMAKE_CXX_COMPILER = mpic++, -DCMAKE_Fortran_COMPILER = mpifort correspond to the compilers of C, C++ and Fortran respectively, and the two cmake options -DCMAKE_CXX_FLAGS and -DCMAKE_C_FLAGS are used to pass specific compiler options to cmake. In this case, -lgfortran specifies the flag to link to the gfortran library. Using these options ensures that the gfortran library is correctly included during the compilation and linking process so that C / C++ and Fortran codes can call and link each other correctly.

[0101] in:

[0102] -DTrilinos_ENABLE_TESTS=OFF

[0103] Configure whether to enable the test function as required.

[0104] (3) Compilation, installation and example execution

[0105] Step 1: Type make to execute the Makefile generated by cmake to build Epetra and AztecOO.

[0106] Step 2: Type make install to install. The software will be installed to the directory specified during the configuration phase, that is: -DCMAKE_INSTALL_PREFIX = '××××'

[0107] Step 3: Run the examples provided in the test program on the Sunway main core.

[0108] The AztecOO_epetra_crsmatrix example in ×××× / build / packages / aztecoo / example is taken as the test object.

[0109] Compilation stage: First, enter the main.cpp folder of the example, type make to execute the corresponding Makefile file, and compile the example main program into the corresponding .o target file. Secondly, enter the src file directory of aztecoo and epetra, type make to execute the corresponding Makefile file, compile all source files into the corresponding .o target files, and link all .o into static libraries: libaztecoo.a and libepetra.a.

[0110] Linking stage: Since the main program is a C++ program and supports MPI, mpic++ is used as the linker to link main.o, libaztecoo.a, libepetra.a, mathematical libraries libblas.a, liblapack.a and static library files generated by other Trilinos software packages into the executable program AztecOO_epetra_crsmatrix.exe.

[0111] Running phase: Use the bsub command to submit the executable program AztecOO_epetra_crsmatrix.exe to the Shenwei computing node for execution.

[0112] Among them, the difficulties and challenges are mainly concentrated in the linking stage.

[0113] By default, the linking process requires linking a dynamic library (×××× / libdl.so). However, the Sunway computing platform is relatively friendly to static libraries, and the master-slave computing mode does not support dynamic library linking, so you need to manually delete ×××× / libdl.so. In addition, since MPI is enabled during the configuration phase, mpicc or mpic++ will come with the -mhybrid option. This option will cause all dependencies to be after the reference. For example, if swg++ is used as the linker, the -lgfortran option must be placed after the .o file when linking the .o file generated by swgfortran. If it is placed in front, the -lgfortran option will not take effect on the .o file. Therefore, you need to adjust the position of the -lgfortran option and place the lgfortran option after all .o and .a files.

[0114] 2. The present invention adopts multiple methods to analyze the calculation process and locate program hot spots

[0115] The present invention first uses the performance analysis tool swprof equipped with the new generation of Sunway supercomputer to preliminarily check the computing hotspots of the AztecOO_epetra_crsmatrix program. Further, a manual plug-in method is used to perform fine-grained hotspot analysis within the program. Specifically, the main program is first divided into different modules according to function, and the MPI_Wtime() timing function is used to time each module separately. The proportion of computing time of each module is compared, and the module with the longest computing time is found. Then, the next layer function called by the module is further analyzed, and the above fine-grained hotspot analysis is repeated until the computing-intensive algorithm part in the program algorithm that conforms to the acceleration of the new generation of Sunway supercomputer architecture is found, and appropriate changes are made to this part of the algorithm to design a slave-core parallel solution.

[0116] Among them, the computationally intensive algorithm part that conforms to the acceleration of the new generation of supercomputer architecture of Sunway is usually a loop structure code, which accounts for a large proportion of the overall program running time and takes a long time. In addition, the core loop code must be serial code. Since there is usually no message communication mechanism in the acceleration device, the core code cannot contain code that uses message communication functions.

[0117] Specifically, the process of making appropriate changes to this part of the algorithm includes: analyzing whether the program has data dependencies: that is, determining whether this part of the algorithm (that is, the loop body structure code) has data dependencies. If there are data dependencies, it cannot be parallelized. Therefore, some means are needed to eliminate the data dependencies. The means to eliminate data dependencies include: data preprocessing, loop body reconstruction, etc.

[0118] 3. The present invention performs core parallelization design on the hot spots of program calculation

[0119] According to the above calculation process analysis and program hotspot location results, the calculation-intensive function finally found is epetra_dcrsmv. This function is located in the Epetra_dcrsmv.f file and is a fortran77 subroutine of the CSR format sparse matrix vector multiplication (SpMV) algorithm. The calculation core of this subroutine is the following two-layer loop body:

[0120]

[0121] The CSR format is a compressed storage format for sparse matrices, which stores the data of sparse matrices in the form of three arrays. They are the val() array in the above code: storing all non-zero elements of the matrix; the pntr() array: a row pointer array, the index position of each row of non-zero elements in val(); and the indx() array: the column index of the non-zero element.

[0122] The x() array is the input vector, and y() is the result vector. m, n are the row and column dimensions of the matrix.

[0123] The outer loop traverses each row of the matrix, and the inner loop traverses all non-zero elements in the current row, multiplies the current non-zero element with the element at the corresponding position in vector x, and then adds it to the current row position of the result vector y.

[0124] The present invention writes the master-slave core code by calling the Athread acceleration thread library function interface customized by Shenwei, and uses the master-slave acceleration model to accelerate the above-mentioned computing hotspots, such as Figure 2 As shown in the figure, based on the unique master-slave core hardware architecture of the Sunway heterogeneous multi-core processor, the loop body uses the slave core as an acceleration core to improve the overall performance of the software. The slave core parallelization design mainly includes the following parts: data structure adjustment, data partitioning and slave core parallel computing.

[0125] Data structure adjustment: In the frotran language supported by the Shenwei compiler, when using the sw26010pro processor slave core in parallel, the data related to the computing core needs to be shared through the Common shared area, so that both the master core and the slave core can directly or indirectly access and modify the data in the shared storage space. However, to achieve data sharing in this way, it is necessary to ensure that the size of the array elements in the Common shared area must be fixed. However, for this subroutine, the val() array, pntr() array, indx() array, x() array, and y() array all use the assumed size array format. The size of the array is passed by the upper-level function when calling the subroutine. Therefore, it is necessary to change the assumed size array format to a fixed memory allocation method, and pass the actual array size to the subroutine when calling the subroutine through the upper-level function, and combine the theoretical basis of the CSR compressed matrix format to determine the specific size of the array.

[0126] Data partitioning and slave core parallel computing: There are usually two ways to partition matrix data: one-dimensional partitioning and two-dimensional partitioning. For the two-dimensional partitioning method, multiple slave cores will simultaneously update part of the data of the result vector y() during calculation, so locking is required. Locking will cause additional overhead. Therefore, a one-dimensional partitioning method is adopted to divide the matrix equally by rows. Each core group consists of 64 slave cores. Therefore, for a matrix with m rows, each slave core calculates approximately m / 64 rows. When there are extra matrix rows, these data are evenly distributed to the first few slave cores with slave core IDs. After the data is divided into each slave core, the slave cores simultaneously perform thread-level parallel computing on the data they are assigned. After several computing cycles, all slave cores can complete the data calculation at the same time.

[0127] 4. The present invention optimizes memory access from the core with respect to memory access speed and memory access bandwidth

[0128] Memory access speed:

[0129] For the SpMV algorithm in the CSR format, the calculation process requires the values ​​of the five arrays val(), pntr(), indx(), x(), and y() to complete. Among them, the three arrays val(), x(), and y() are real types, each real occupies 8 bytes, and the two arrays indx() and pntr() are integer types, each integer occupies 4 bytes.

[0130] Here, three real type arrays and two integer type arrays are pre-allocated in the slave core, all in static array form. The size of the y() and pntr() arrays is set to 3000, that is, each slave core processes 3000 rows of data per cycle, and the total space occupied is: (3000*8 / 1024)+(3000*4 / 1024)KB, that is, 35KB. The val() and indx() arrays are related to the number of non-zero elements in the sparse matrix. Therefore, space can be requested based on the average number of non-zero elements per row. Assuming that each row has number non-zero elements, the size of the val() and indx() arrays is set to (3000*number), and the total space occupied is: (3000*number*8 / 1024)+(3000*number*4 / 1024)KB. Assuming number is 5, the total space occupied is (3000*5*8 / 1024)+(3000*5*4 / 1024)KB, which is about 176KB, and the remaining space for the slave core is 45KB. For the array x(), space has not been allocated. Since x() is indirectly accessed in the sparse matrix-vector multiplication, the access behavior is irregular, and the memory access to x() data directly affects the final performance. Here, the shared LDM mechanism of the Shenwei multi-core processor is adopted. The shared LDM provides a shared, high-speed memory area. Multiple slave cores can access and use this memory at the same time without copying the data to their respective local storage. That is, 16KB of storage space is divided from the LDM of each of the 64 slave cores in a core group to form a shared space of 64*16KB. Each slave core directly accesses this space when using the x() array. This not only saves local storage space and solves the LDM memory limitation problem, but also helps to improve the efficiency and performance of multi-core processors.

[0131] Memory access bandwidth:

[0132] For the core data of the hotspot part of the calculation: val(), pntr(), indx(), x(), y(), during the parallel calculation of the slave cores, all slave cores will concurrently access the five arrays in the main memory, resulting in too much pressure on the main memory bandwidth.

[0133] In view of the problem of excessive bandwidth pressure, the present invention adopts the crts_dma_iget interface and the crts_dma_iput interface in the Athread acceleration thread library to realize the batch transmission of data between the slave core and the master core. The direct memory access (DMA) method realizes the data transmission between the main memory and the LDM, which can control the data exchange between the main core and the slave core while the slave core performs some calculation operations unrelated to the transmission data, so as to realize the concurrent operation of the slave core communication and calculation; at the same time, since the calculation process of multiplying the current non-zero element of the matrix with the element at the corresponding position in the vector x needs to traverse all the values ​​of the x() array, resulting in poor data space locality, while the DMA channel method obtains a continuous data segment from the main memory and transmits it to the slave core LDM when performing data exchange, so the data space locality can be greatly improved, thereby accelerating the efficiency of the slave core accessing the main memory.

[0134] In order to verify the solution of the present invention, the present invention carries out the following experimental process:

[0135] Experimental environment: Sunway's new generation supercomputer;

[0136] Experimental data: Matrix introduction:

[0137] Matrix (1): AF23560

[0138] Source: Transient stability analysis of the Navier-Stokes solver for computational fluid dynamics;

[0139] Matrix size: Order: 23560*23560, 484256 entries.

[0140] Matrix (2): tridiagonal matrix

[0141] Source: Matrix obtained by discretizing the Laplace equation using the finite difference method;

[0142] Matrix size: Order: 20000*20000, 59998 entries;

[0143] Experimental results and analysis:

[0144] Figure 3 The following is a comparison chart of the execution time of solving a sparse linear system of equations (Ax=b, where the data of matrix A is matrix (1)) using the GMRES algorithm in the AztecOO parallel iterative solver under a single core group.

[0145] Taking the time of running on a single master core as the test benchmark, the time proportion of the overall program and hotspot functions before and after optimization is compared after parallel acceleration of slave cores. Figure 3It can be seen that before optimization, the overall calculation time of the program was 123.3s, of which the hotspot part was 81.2s. After optimization, the overall calculation time of the program dropped to 52.5s, of which the hotspot part was only 10.1s. The overall acceleration ratio was more than 2 times, and the performance of the hotspot part was improved by more than 8 times. This shows that after core optimization, the computing efficiency is significantly improved.

[0146] Figure 4 The following is a comparison chart of the execution time of solving the sparse linear equations problem (Ax=b, where the data of matrix A is matrix (2)) using the PCG algorithm in the AztecOO parallel iterative solver under multiple core groups.

[0147] After single-core group performance optimization and performance testing, we used MPI+Athread on the Shenwei platform to conduct a strong scalability analysis under multiple nodes. As can be seen from the figure, as the number of core groups increases, the running time gradually decreases and finally stabilizes, which shows that it has good strong scalability efficiency. The reason for stabilization is that as the number of core groups increases, the number of slices of data partition will increase, resulting in an increase in inter-process communication and increased communication time. Therefore, the program execution time is limited by communication and stabilizes.

[0148] Embodiment 2

[0149] This embodiment provides an AztecOO transplantation optimization system based on the Sunway supercomputer.

[0150] An AztecOO transplantation optimization system based on the Sunway supercomputer, comprising:

[0151] A porting module configured to: port Epetra and AztecOO to the main core of the new generation Sunway supercomputer;

[0152] The analysis and positioning module is configured to: perform fine-grained hot spot analysis in the main program based on the computational hot spots of the transplanted main program by manual plugging, and find computationally intensive functions, which are sparse matrix-vector multiplication subroutines in CSR format;

[0153] The slave core parallel module is configured to: change the assumed size array format in the subroutine to a fixed memory allocation mode, and adjust the specific size of the array; divide the data in the sparse matrix equally by row, and evenly distribute it to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time;

[0154] The slave core access module is configured as follows: using the shared LDM mechanism of the Shenwei multi-core processor, a preset storage space is divided from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; and the direct memory access (DMA) method in the Athread acceleration thread library is used between the slave core and the master core to perform batch data transmission.

[0155] It should be noted that the above-mentioned transplantation module, analysis and positioning module, slave core parallel module and slave core access module are the same as the examples and application scenarios implemented by the steps in Embodiment 1, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the above-mentioned modules as part of the system can be executed in a computer system such as a set of computer executable instructions.

[0156] Embodiment 3

[0157] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of the AztecOO transplantation optimization method based on the Sunway supercomputer as described in the first embodiment above are implemented.

[0158] Embodiment 4

[0159] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the AztecOO transplantation optimization method based on the Sunway supercomputer as described in the first embodiment above are implemented.

[0160] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0161] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0162] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0164] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0165] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for optimizing AztecOO transplantation based on the Sunway supercomputer, characterized in that: include: Porting Epetra and AztecOO to the main core of the new generation Sunway supercomputer; Based on the computational hotspots of the transplanted main program, a fine-grained hotspot analysis is performed in the main program by manual plugging to find computationally intensive functions, which are subroutines for sparse matrix-vector multiplication in CSR format. The assumed size array format in the subroutine is changed to a fixed memory allocation mode, and the specific size of the array is adjusted; the data in the sparse matrix is ​​equally divided by rows, and evenly distributed to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time; The shared LDM mechanism of the Shenwei multi-core processor is adopted to divide the preset storage space from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; the direct memory access method in the Athread acceleration thread library is used between the slave core and the master core to perform batch data transmission.

2. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1 is characterized in that: The process of porting Epetra and AztecOO to the main core of the new generation Sunway supercomputer includes: compiling and installing the build tool cmake using the source code method, modifying the Module file of cmake; configuring the cmake environment variables; entering the source code directory and creating a new directory for building, entering the new directory, and using cmake to perform basic configuration of Epetra and AztecOO; typing make to execute the Makefile generated by cmake to build Epetra and AztecOO; typing make install to install, and the software will be installed to the directory specified during the configuration phase; running the built-in calculation examples in the test program on the Sunway main core.

3. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1, characterized in that: The computational hotspots of the transplanted main program are manually inserted to perform fine-grained hotspot analysis inside the main program. The process of finding computationally intensive functions includes: dividing the main program into different modules according to functions, timing each module separately using the MPI_Wtime() timing function, comparing the proportion of computational time of each module, finding the module with the longest computational time, and then further analyzing the next layer of functions called by the module. Repeating the above-mentioned fine-grained hotspot analysis until the computationally intensive algorithm part in the program algorithm that conforms to the acceleration of the new generation supercomputer architecture of Sunway is found, which is the computationally intensive function.

4. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1 is characterized in that: The process of changing the assumed size array format in the subroutine to a fixed memory allocation method and adjusting the specific size of the array includes: changing the assumed size array format in the subroutine to a fixed memory allocation method, passing the actual array size to the subroutine when calling the subroutine through the upper-level function, and combining the CSR compression matrix format theoretical basis to determine the specific size of the array.

5. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1, characterized in that: The process of dividing the data in the sparse matrix equally by rows and distributing them evenly to all slave cores includes: dividing the data in the sparse matrix equally by rows by one-dimensional partitioning method, each core group is composed of 64 slave cores, for a matrix with m rows, each slave core calculates m / 64 rows, and when there are extra matrix rows, the extra matrix rows are evenly distributed to the first few slave cores with slave core ID.

6. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1, characterized in that: The subroutine includes: val() array, pntr() array, indx() array, x() array and y() array. For accessing the x() array, the shared LDM mechanism of the Shenwei multi-core processor is adopted to set the shared space.

7. The AztecOO transplantation optimization method based on the Sunway supercomputer according to claim 1, characterized in that: The method of using the direct memory access method in the Athread acceleration thread library to perform batch data transmission between the slave core and the main core includes: using the crts_dma_iget interface and the crts_dma_iput interface in the Athread acceleration thread library to realize batch data transmission between the slave core and the main core, realizing data transmission between the main memory and the LDM by the direct memory access method, and controlling the data exchange between the main core and the slave core while the slave core performs some calculation operations unrelated to the transmitted data.

8. An AztecOO transplantation optimization system based on the Sunway supercomputer, characterized in that: include: A porting module configured to: port Epetra and AztecOO to the main core of the new generation Sunway supercomputer; The analysis and positioning module is configured to: perform fine-grained hot spot analysis in the main program based on the computational hot spots of the transplanted main program by manual plugging, and find computationally intensive functions, which are sparse matrix-vector multiplication subroutines in CSR format; The slave core parallel module is configured to: change the assumed size array format in the subroutine to a fixed memory allocation mode, and adjust the specific size of the array; divide the data in the sparse matrix equally by row, and evenly distribute it to all slave cores, so that the slave cores perform thread-level parallel calculations on the allocated data, so that the slave cores can complete data calculations at the same time; The slave core access module is configured as follows: using the shared LDM mechanism of the Shenwei multi-core processor, a preset storage space is divided from the LDM of all slave cores in a core group to form a shared space, and each slave core directly accesses the shared space; and a direct memory access method in the Athread acceleration thread library is used between the slave core and the master core to perform batch data transmission.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the AztecOO transplantation optimization method based on the Sunway supercomputer as described in any one of claims 1-7 are implemented.

10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the AztecOO transplantation optimization method based on the Sunway supercomputer as described in any one of claims 1-7 are implemented.

Citation Information

Cited By

  • Pytorch transplanting method based on domestic Shenwei processor

    CN119806638A

  • Slave core memory access optimization method based on new generation SW many-core processor

    CN120144503A

  • Method for Optimizing Memory Access of Slave Cores Based on New Generation ShenWei Many-Core Processors

    CN120144503B

  • Sparse matrix vector multiplication implementation method and system for Shenwei processor

    CN120372144A