A core optimization method with dependency and cross-loop based on Shenwei multi-core processor
By preprocessing the data in the loop and refining the slave core group, using parallel strategies and explicitly managing local data storage, the problem of low slave core efficiency caused by the cross-dependence of loop data in Sunway many-core processors is solved. It achieves the reduction and efficiency improvement of data transfer from core to main memory.
Patent Information
- Application Number
- CN202410888133.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In the process of slave coreization of Shenwei many-core processors, due to cross-dependencies and conditional restrictions on cyclic data, slave coreization cannot be performed efficiently, resulting in frequent data transmission between slave cores and main memory, resulting in memory access bandwidth bottlenecks and slowing down operations. efficiency.
By preprocessing the data with large dependencies in the loop, the dependence intensity of the dependent data is reduced, and the merged calculation process is refined from the core group to the sub-core group, using single instruction stream multiple data streams and multiple instruction streams multiple data streams. The parallel strategy explicitly manages local data storage and reduces data exchange between slave cores and main memory.
It effectively reduces the number of data transmissions between slave cores and main memory, improves data transmission efficiency, increases load balancing and parallel capabilities between slave core groups, and improves the processing efficiency of complex computing tasks.
Smart Images

Figure CN118409801B
Abstract
Description
Technical Field
[0001] The invention relates to a method for optimizing slave cores with dependencies and cross-cycles based on a Shenwei multi-core processor, and belongs to the technical field of electronic information. Background Art
[0002] After decades of development, China's high-performance computing has explored the development path of domestic high-performance computers represented by the Sunway supercomputer, enabling China to independently develop high-performance processors and accelerators. Supercomputers are of great significance to many aspects, including basic scientific research, industrial application of scientific and technological achievements, and sustainable development of the national economy.
[0003] The processor chip used in the new generation of Sunway supercomputer is the Sunway SW26010Pro processor. The chip adopts a similar heterogeneous architecture. Each core group includes a computing control core (MPE, referred to as the master core) and an 8×8 computing core (CPE, referred to as the slave core) array. Any two computing cores in the array can communicate data and collectively through remote memory access (RMA). A processor chip integrates 6 core groups (CGs) and is connected through an on-chip interconnect network. The hardware architecture of the chip is as follows: Figure 1 shown.
[0004] Both the master core and the slave core use the SW64 instruction set with independent intellectual property rights. The master core supports 256-bit SIMD vector operations, and the slave core supports 512-bit SIMD vector operations. The master core storage hierarchy includes registers, data cache, instruction cache, secondary cache shared by data and instructions, and main memory. The slave core storage hierarchy includes registers, on-chip data storage space, instruction cache, and main memory. The data storage space can be configured as a software-managed local data storage (LDM) or a hardware-managed L1 data cache. The slave core can initiate a direct memory access (DMA) operation to realize data transfer between LDM and main memory, and can also realize data transfer between the local LDM and other slave core LDMs through RMA operations.
[0005] In view of the unique architecture of the Shenwei multi-core processor SW26010Pro, in the process of slave coreization, it is necessary to ensure that the calculations between the slave cores are not affected by other data as much as possible, that is, there is no intersection between the input data required for the calculation of a single slave core and the data calculated by other slave cores. However, in actual applications, the cross-influence of data and the existence of calculation conditions are a common situation. In this case, the slave coreization method of directly accessing the main memory is often adopted, that is, direct access to the main memory slave coreization. This method will cause the slave core to frequently access the main memory, which is easy to cause a bottleneck in the memory access bandwidth when the amount of calculation data is large, resulting in low operating efficiency.
[0006] Therefore, in the process of slave coreization, the first thing to do is to reduce the cross-dependency between data. On this basis, the frequency and size of data exchange between the slave core and the main memory must be reduced. The data required for calculation should be placed in the slave core's private high-speed local memory, namely LDM, as much as possible. Summary of the invention
[0007] In view of the shortcomings of the prior art, in the process of slave core optimization, when there is data cross-dependency and more computing conditions in the loop, directly assigning the computing tasks in the loop to each slave core for calculation cannot bring into play the full performance of the slave core group. Instead, it is necessary to design a suitable computing process according to its computing characteristics and the architectural characteristics of the Shenwei multi-core processor SW26010Pro chip to achieve better computing results. The present invention provides a method for optimizing slave cores with dependencies and cross-loops based on the Shenwei multi-core processor;
[0008] The present invention solves the problem that when using the new generation Shenwei multi-core processor SW26010Pro for slave core conversion, efficient slave core conversion cannot be performed due to cross-dependencies and conditional restrictions on the calculation data required for the loop. It reduces the number of data transmissions between the slave core and the main memory, reduces the memory access pressure, and improves the operating efficiency.
[0009] Terminology explanation:
[0010] 1. LDM: Local Data Memory. Each slave core has a local data storage space with fast memory access speed, but its capacity is limited. It needs to be used with care and usually requires explicit management.
[0011] 2. DMA: Direct Memory Access, a slave core interface initiated by the slave core to implement batch data transfer between main memory and LDM.
[0012] 3. RMA: Remote Memory Access, slave core interface. The slave core can use RMA operation to achieve data transmission between the local LDM and other slave core LDMs with high efficiency.
[0013] The technical solution of the present invention is:
[0014] The dependent and cross-loop slave core optimization method based on the Sunway multi-core processor includes:
[0015] Preprocess the data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reduce the highest-dimensional dependent data to the lowest dimension that does not affect the calculation; the data with large dependencies refers to the data that needs to be modified in multiple steps of calculation and the data that is used multiple times in the loop and has calculation boundaries;
[0016] The calculation process of multiple steps is merged into a process of starting and shutting down a slave core group, and the slave core group is further subdivided into several slave core groups. The parallel strategy of single instruction stream and multiple data streams is adopted between slave core groups, and the parallel strategy of multiple instruction streams and multiple data streams is adopted within the slave core group.
[0017] Explicit management uses local data storage (LDM) to transfer the required computing data from the main memory at one time.
[0018] Preferably, according to the present invention, preprocessing is performed on data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reducing the highest dimensional dependent data to the lowest dimensionality that does not affect the calculation; including:
[0019] If the data with large dependencies is a multiple pointer array variable, in the loop, the required associated data is in a higher dimension, that is, the dependency exists in the outermost layer of the loop, and the high-dimensional dependent data is reduced to the lowest dimension that does not affect the calculation; specifically, it includes: analyzing the calculation data, and exchanging the high-dimensionality where the dependent data is located with the lowest dimension where there is no dependency and does not affect the calculation.
[0020] According to the preferred embodiment of the present invention, the core group is further subdivided into several core subgroups; including:
[0021] When processing data with cross-dependencies and computational conditions, the core groups are grouped according to the size of the highest dimension of the data to be computed;
[0022] Among them, data containing cross-dependencies and calculation conditions refer to data that need to be calculated in both the upper and lower steps of the calculation process and the calculation boundaries that need to be considered in the loop.
[0023] Further preferably, the core groups are grouped according to the size of the highest dimension of the data to be calculated; including:
[0024] The slave core groups are divided into 1, 2, 4, 8 or 16 slave core groups in the settings. The number of slave core groups is automatically selected according to the size of the highest dimension of the data to be calculated.
[0025] Preferably, according to the present invention, a parallel strategy of single instruction stream and multiple data streams is adopted between core groups; including:
[0026] The calculation process is the same among the core groups, but the input data are different.
[0027] Preferably, according to the present invention, a parallel strategy of multiple instruction streams and multiple data streams is adopted within the core group; including:
[0028] The slave cores in the slave core group are assigned to different computing tasks according to the computing conditions of the loop in the original program and the slave core numbers in the group, so as to realize the parallel method of multiple instruction streams and multiple data streams in the slave core group; when it comes to a step of computing process, when the input data required by a certain slave core in the group is the output result of the previous operation of other slave cores, the storage location of the written data is determined in the process of reading data from the main memory to the LDM through DMA, so as to facilitate the use of RMA operation to exchange data between slave cores and LDMs when other cores need it.
[0029] Further preferably, explicit management utilizes local data storage LDM to transfer required computing data from main memory at one time; including:
[0030] Control the size of LDM and the variables stored in it, package all the calculation data, transfer the required calculation data from the main memory to the LDM at one time, and after the calculation is completed, transfer the calculation results back to the corresponding location in the main memory.
[0031] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of a method for optimizing a slave core with dependency and cross-loop based on a Shenwei multi-core processor are implemented.
[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a method for optimizing a slave core with dependencies and cross-loops based on a Shenwei multi-core processor.
[0033] The beneficial effects of the present invention are:
[0034] 1. The present invention effectively reduces the amount of data transmitted to the slave core LDM at one time, saves the use space of LDM, reduces the pressure of transmission bandwidth, and increases the efficiency of LDM use and data transmission.
[0035] 2. The parallel strategy of single instruction stream and multiple data streams among the core groups of the present invention effectively realizes the load balancing among the core groups. The computing tasks of each core group are equivalent, and the time required for computing is basically the same. The computing tasks can be completed simultaneously in a smaller time period, thereby increasing the parallel efficiency.
[0036] 3. The parallel strategy of multiple instruction streams and multiple data streams from the cores in the core group of the present invention enables the cores in the group to collaborate to complete the same computing task, which can solve more complex computing tasks and improve the parallel capability of complex computing tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is the architecture diagram of the Shenwei SW26010Pro processor;
[0038] Figure 2 A schematic diagram comparing the amount of data that needs to be transferred to the slave core before and after dimensionality reduction of dependent data;
[0039] Figure 3 This is a schematic diagram of the data transmission process from the core group to the main memory;
[0040] Figure 4 Schematic diagram of RMA within the slave core group and DMA between the slave core and main memory. DETAILED DESCRIPTION
[0041] The present invention will be further defined below in conjunction with the accompanying drawings and embodiments, but is not limited thereto.
[0042] Example 1
[0043] The dependent and cross-loop slave core optimization method based on the Sunway multi-core processor includes:
[0044] Preprocess the data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reduce the highest-dimensional dependent data to the lowest dimension that does not affect the calculation; provide a basis for efficient coreization; the data with large dependencies refers to the data that needs to be modified in multiple steps of calculation and the data that is used multiple times in the loop and has calculation boundaries;
[0045] The calculation process of multiple steps is merged into the process of starting and shutting down a slave core group. The calculation data required by multiple steps are merged according to their relevance, and the slave core group is further subdivided into several slave core subgroups. The slave core subgroups adopt a single instruction stream and multiple data streams parallel strategy, and the slave core subgroups adopt a multiple instruction stream and multiple data streams parallel strategy;
[0046] Explicit management uses local data storage (LDM) to transfer the required computing data from the main memory at one time. The data exchange process occurs between slave cores, reducing the number of data exchanges with the main memory.
[0047] Example 2
[0048] The difference between the dependent and cross-loop slave core optimization method based on the Shenwei multi-core processor described in Example 1 is that:
[0049] Preprocess the data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reduce the highest-dimensional dependent data to the lowest dimension that does not affect the calculation; including:
[0050] Before the data is sent to the slave core, the data with large dependencies will be preprocessed to reduce the strength of its dependency, thereby reducing the amount of data transmitted to the slave core at one time, saving LDM expenses and transmission time. In the present invention, the method adopted is to reduce the dimension where the dependent data is located. If the data with large dependencies is a multiple pointer array variable, in the loop, the required associated data is in a higher dimension, that is, the dependency exists in the outermost layer of the loop. Due to the unique architecture of the Shenwei multi-core processor, it is not conducive to the slave core optimization of the loop. Because when performing data transmission operations, it is necessary to pass as much related data as possible into the slave core to reduce the number of data transmissions, which will inevitably increase the amount of data transmitted, thereby increasing the access pressure of the memory and reducing the efficiency, and will greatly waste the precious resources of the LDM. This method reduces the high-dimensional dependent data to the lowest dimension that does not affect the calculation; specifically, it includes: analyzing the calculation data, and exchanging the high latitude where the dependent data is located with the lowest dimension where there is no dependency and does not affect the calculation. This can reduce data dependency. As shown in Figure 2, this method can reduce the difficulty and size of data transmission, which is beneficial to the core optimization of the Shenwei multi-core processor and provides a basis for the next step of optimization. Figure 2 In the example, the original computing data required by the entire slave core group is a three-dimensional array a, whose three dimensions are x, y, and z, and whose dependency exists in the first dimension. The lowest dimension that does not affect the computing is the second dimension. The first dimension and the second dimension can be interchanged. The sizes of the three dimensions of the interchanged three-dimensional array b are y, x, and z, respectively. Before the conversion, the array a needs to transfer 3×y×z data to the slave core LDM during data transmission, but after the conversion, only 3×z data needs to be transferred.
[0051] The core group will be further divided into several core subgroups, including:
[0052] When processing multi-loop data, the most effective method is to distribute the computational load in the loop to the slave core group. When processing data with cross-dependencies and computational conditions, the task division of the slave cores needs to be specially designed to meet the design concept of load balancing and achieve the maximum computational efficiency of the slave core group. The present invention provides a method for further grouping a slave core group containing 64 slave cores, which is specifically implemented as follows: grouping the slave core group according to the size of the highest dimension of the data to be calculated;
[0053] Among them, data with cross-dependencies and calculation conditions refers to data that needs to be calculated in both the upper and lower steps of the calculation process and the calculation boundaries that need to be considered in the loop. It is an inclusion relationship with data with large dependencies, and data with large dependencies includes data with cross-dependencies and calculation conditions.
[0054] The core groups are grouped according to the size of the highest dimension of the data to be calculated; including:
[0055] The slave core groups are divided into 1, 2, 4, 8 or 16 slave core groups in the settings, and the optimal number of slave core groups is automatically selected according to the size of the highest dimension of the data to be calculated.
[0056] For example, Figure 3 As shown, the data to be calculated is a triple pointer array variable A[x][y][z]. The slave core group can be divided into N slave core groups according to the size of the highest dimension x. Each slave core group has n slave cores, where N×n=64. i A[j] are assigned to a slave core group for calculation. A[j] is a part of A[x], and j<x, where i×N=x, to implement a parallel method of single instruction stream and multiple data streams between slave core groups.
[0057] A single instruction stream and multiple data stream parallel strategy is adopted between core groups; including:
[0058] The slave core groups can be divided into 1, 2, 4, 8, and 16 slave core groups in the settings. The optimal number of slave core groups is automatically selected based on the size of the highest dimension of the data to be calculated. The calculation process between the slave core groups is the same, but the input data is different.
[0059] Adopt multiple instruction streams and multiple data streams parallel strategy from the core group; including:
[0060] The slave cores in the slave core group are assigned to different computing tasks according to the computing conditions of the loop in the original program and the slave core numbers in the group, so as to implement a parallel method of multiple instruction streams and multiple data streams within the slave core group; due to the different computing tasks, the amount of computing data transmitted is also different, and in the computing process, it also involves the situation that after a step of computing process, the input data required by a certain slave core in the group is the output result of the previous operation of other slave cores. This requires that the data of other slave cores be read into the local LDM after one step of computing is completed. The solution proposed by the present invention is to determine the storage location of the written data in the process of reading data from the main memory to the LDM through DMA. The storage location of the written data is specifically determined based on the boundary conditions and dependencies of the original computing data, rather than habitually storing the data starting from address 0. Figure 4Taking the case shown as an example, the two-dimensional array B
[22] [z] is the input data, and every 8 slave cores form a slave core group. Each operation requires a one-time input of a one-dimensional array B[i][z] with a data size of z, and there are boundary restrictions, that is, B[0][z], B[1][z], B
[20] [z], and B
[21] [z] only participate in the first and third steps of the operation, and when calculating C[i] (1<i<20) in the second step, B[i-1], B[i], and B[i+1] are required to participate in the calculation. In this case, when using DMA to transfer data B[j], B[0][z], B[1][z], B
[20] [z], B
[21] [z] with operation conditions can be stored in the 0th and 7th cores of the slave core group respectively, and the data stored in the 0th core is aligned with the end address of the data stored in the other cores, both are local__B[3], the initial address of the data stored in the 7th core and other cores is aligned, both are local__B[1], and the other cores store data in the normal order starting from local__B[1]. When calculating C[j] (j={2,5,8,11,14,17}), the data stored in the local__B[1] and local__B[2] of the current slave core and the data stored in the local__B[3] of the previous slave core can be read into the local__B[0] of the current slave core through the RMA operation, so as to meet the data required for calculation and complete the calculation task. Similarly, when computing C[j] (j={4,7,10,13,16,19}), the data stored in local__B[2] and local__B[3] of the current slave core and local__B[1] of the next slave core can be read from local__B[1] of the next slave core to local__B[4] of the current slave core through RMA operation. This method can reduce the number of data exchanges between the slave core and the main memory, reduce memory access overhead, and has a positive impact on the computing efficiency of the program.
[0061] Explicit management uses local data storage (LDM) to transfer the required computing data from main memory at one time; including:
[0062] Control the size of LDM and the variables stored in it, package all the calculation data, transfer the required calculation data from the main memory to the LDM at one time, and after the calculation is completed, transfer the calculation results back to the corresponding location in the main memory.
[0063] The core algorithm of the present invention is described as follows. First, the main core algorithm reduces the difficulty of converting data with strong dependencies into secondary cores by preprocessing the data; as shown in Table 1:
[0064] Table 1 Main kernel algorithm;
[0065]
[0066] Then, the slave core algorithm automatically selects the optimal number of slave core groups by judging the scale of the input data. The calculation process is the same among the groups. The slave cores in the group obtain their own calculation tasks and the required calculation data, and then perform calculations. When it is necessary to process dependent parts, the slave cores perform RMA operations to transfer the required data, complete the calculation tasks together, and finally transfer the calculation results back to the corresponding location of the main memory. As shown in Table 2 and Table 3:
[0067] Table 2 From the method of accounting 1;
[0068]
[0069] Table 3 From the second method;
[0070]
[0071] This example tests the patented method within a single core group.
[0072] This test takes the plasma fluid simulation program as an example. Under the same input conditions, the number of points in the Z direction of the test data is 65, 257, and 1025 respectively, and the speedup ratio is tested when the number of iterations of the program is 1000 times.
[0073] The time and speedup ratio of the main core serial version, the direct access to main memory slave core version and the patent optimized version are compared. The experimental results show that the method has a significant speedup effect compared with the main core serial version and the direct access to main memory slave core version. The specific results and comparisons are shown in Tables 4, 5 and 6 below.
[0074] Table 4 The running time and speedup ratio of the test program before and after optimization when the number of test data points in the Z direction is 65 and the number of iterations is 1000;
[0075]
[0076] Table 5. The running time and speedup ratio of the test program before and after optimization when the number of test data points in the Z direction is 257 and the number of iterations is 1000;
[0077]
[0078] Table 6 shows the running time and acceleration ratio of the test program before and after optimization when the number of points in the Z direction of the test data is 1025 and the number of iterations is 1000;
[0079]
[0080] Example 3
[0081] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the dependent and cross-loop slave core optimization method based on the Shenwei multi-core processor described in Example 1 or 2 are implemented.
[0082] Example 4
[0083] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the dependent and cross-loop slave core optimization method based on the Shenwei multi-core processor described in Example 1 or 2.
Claims
1. A method for optimizing cores with dependencies and cross-loops based on the Sunway multi-core processor. It is characterized in that include: Preprocess the data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reduce the highest-dimensional dependent data to the lowest dimension that does not affect the calculation; the data with large dependencies refers to the data that needs to be modified in multiple steps of calculation and the data that is used multiple times in the loop and has calculation boundaries; The calculation process of multiple steps is merged into a process of starting and shutting down a slave core group, and the slave core group is further subdivided into several slave core groups. The parallel strategy of single instruction stream and multiple data streams is adopted between slave core groups, and the parallel strategy of multiple instruction streams and multiple data streams is adopted within the slave core group. Explicit management uses local data storage (LDM) to transfer the required computing data from the main memory at one time; Preprocess the data with large dependencies in each calculation cycle to reduce the dependency strength of the dependent data, that is, reduce the highest-dimensional dependent data to the lowest dimension that does not affect the calculation; including: If the data with large dependencies is a multiple pointer array variable, in the loop, the required associated data is in a higher dimension, that is, the dependency exists in the outermost layer of the loop, and the high-dimensional dependent data is reduced to the lowest dimension that does not affect the calculation; specifically, it includes: analyzing the calculation data, and exchanging the high-dimensionality where the dependent data is located with the lowest dimension where there is no dependency and does not affect the calculation.
2. According to claim 1, the method for optimizing the slave cores with dependency and cross-loop based on the Shenwei multi-core processor, It is characterized in that The core group will be further divided into several core subgroups, including: When processing data with cross-dependencies and computational conditions, the core groups are grouped according to the size of the highest dimension of the data to be computed; Among them, data containing cross-dependencies and calculation conditions refer to data that need to be calculated in both the upper and lower steps of the calculation process and the calculation boundaries that need to be considered in the loop.
3. According to claim 1, the method for optimizing the slave cores with dependency and cross-loop based on the Shenwei multi-core processor, It is characterized in that The core groups are grouped according to the size of the highest dimension of the data to be calculated; including: The slave core groups are divided into 1, 2, 4, 8 or 16 slave core groups in the settings. The number of slave core groups is automatically selected according to the size of the highest dimension of the data to be calculated.
4. The method for optimizing the slave cores with dependency and cross-loop based on the Shenwei multi-core processor according to claim 1, It is characterized in that A single instruction stream and multiple data stream parallel strategy is adopted between core groups; including: The calculation process is the same among the core groups, but the input data are different.
5. The method for optimizing the dependent and cross-loop slave cores based on the Shenwei multi-core processor according to claim 1, It is characterized in that Adopt multiple instruction streams and multiple data streams parallel strategy from the core group; including: The slave cores in the slave core group are assigned to different computing tasks according to the computing conditions of the loop in the original program and the slave core numbers in the group, thereby realizing a parallel method of multiple instruction streams and multiple data streams within the slave core group. When it comes to a calculation process, when the input data required by a certain slave core in the group is the output result of the previous calculation of other slave cores, the storage location of the written data is determined during the process of reading data from the main memory to the LDM through DMA.
6. The method for optimizing slave cores with dependencies and cross-loops based on the Shenwei multi-core processor according to any one of claims 1 to 5, It is characterized in that Explicit management uses local data storage (LDM) to transfer the required computing data from main memory at one time; including: Control the size of LDM and the variables stored in it, package all the calculation data, transfer the required calculation data from the main memory to the LDM at one time, and after the calculation is completed, transfer the calculation results back to the corresponding location in the main memory.
Citation Information
Patent Citations
Sea-flow induced magnetic field parallel computing method based on domestic many-core architecture
CN114490022A
Sunwei many-core processor slave core cluster acceleration parallel method, equipment and medium
CN117472448A
