A data-dependent parallel computing method based on many-cores
By initializing the parallel computing data in parallel computing and calculating the starting data line number of the kernel and the starting data line number of the data block in the kernel, the problem of data dependence and data conflict in parallel computing is solved, and efficient and accurate parallel computing is achieved.
Patent Information
- Application Number
- CN202411721026.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-11-28
AI Technical Summary
In parallel computing, the prior art, waiting for the dependent data to be calculated to be completed will cause performance degradation and calculation speed to be reduced. Setting a global array will lead to increased storage overhead, while the data will be out of synchronized, which will cause inaccurate calculation results and inconsistent data.
By obtaining parallel computing data in the data initialization step and assembling it into a structure to pass it into the slave core, entering the full array fast thread group from the kernel, starting the slave core calculation, looking for the correct position value from the starting data line number of the kernel and the starting data line number of the data block, and performing parallel calculation of the correct data by traversing each row of data.
The data dependence and data conflict problems in parallel computing are solved. The data is synchronized and the high-speed buffer is refreshed to keep the data consistent, improving the efficiency and accuracy of parallel computing.
Smart Images

Figure CN119225978B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of many-core parallel computing, and in particular to a many-core-based data-dependent parallel computing method. Background Art
[0002] At present, data dependency and data conflict problems are very common and important in parallel computing, which will affect the correctness and efficiency of computing. Data dependency means that one task needs to rely on the output data of another task before it can start execution. If two storage access operations access the same storage location (the same variable), and one of the accesses is a write (or update) operation, there is data dependency between the two operations. Data conflict refers to the problem that may arise when multiple parallel tasks access or modify the same data at the same time, which may lead to inconsistent data or wrong results. Because some operations are interdependent, an operation can only be executed after other dependent operations are completed. When performing slave-core parallel computing on data with dependencies, there will be data read and write conflicts between different slave cores. Two cores running at the same time have no order of priority when accessing resources. Both are calculated based on their own resources. The data in the later position does not take into account the calculation results of the data in the previous position, so the calculation results do not meet expectations.
[0003] There are some existing methods for dealing with data dependency and data conflict problems in parallel computing, such as locking mechanisms, transactions, data replication, blocking queues, etc. In addition, patent CN118245117A discloses a multi-branch automatic analysis and parallel optimization method based on the new generation Shenwei multi-core processor. By setting the parameter fun to a global shared array of the slave core, the result calculated by wconvon is no longer transmitted back to the source address of the main core fun first, but is directly involved in the add function for calculation, thereby eliminating competition and dependency, and then realizing parallel optimization in the slave core. However, the above method will cause performance degradation and calculation speed reduction by waiting for the dependent data to be calculated, and will increase storage overhead by setting a global array, and will cause inaccurate calculation results and data inconsistency by not synchronizing data. Summary of the invention
[0004] In view of the shortcomings existing in the related art, the purpose of the present invention is to provide a data-dependent parallel computing method based on many cores to solve the technical problems that the prior art may cause performance degradation and reduced computing speed by waiting for the dependent data to be calculated, increase storage overhead by setting a global array, and cause inaccurate calculation results and inconsistent data by not synchronizing data.
[0005] The present invention provides a data-dependent parallel computing method based on many cores, comprising the following steps:
[0006] Data initialization step: obtaining parallel computing data, assembling the parallel computing data into a structure and then transmitting it to the slave core, the slave core enters the full array fast thread group, starts the slave core, and calculates the slave core load;
[0007] Load balancing division steps: Configure the amount of data to be calculated from the core , according to the parallel computing data and the slave core computing data amount Calculate the total number of slave cores , according to the total number of slave cores Calculate the amount of data in the data block Divide the parallel computing tasks, and calculate the starting data row number of each slave core through sequential traversal and reverse traversal and the starting data row number of each data block ;
[0008] Secondary core data query step: Calculate the data volume based on the secondary core and the starting data row number of the slave core Loop to calculate the value of each row of slave core data, according to the starting data row number of the slave core and the starting data row number of the data block Query the calculation position and reading position of each row of slave core data, determine whether the value of each row of slave core data is calculated and updated, and traverse and calculate each row of slave core data by using the column number of each node in the data storage matrix as the subscript.
[0009] The embodiment of the present invention solves the data dependency and data conflict problems in parallel computing by finding the value at the correct position from the starting data row number of the core and the starting data row number of the data block, and performing parallel computing on the correct data by traversing each row of data.
[0010] In some embodiments of the present invention, the method further comprises:
[0011] Data synchronization step: After all parallel computing data in the full array fast thread group are calculated, the calculation results are transferred to the main memory and the calculation of the next data block is started synchronously. After the parallel computing data is transferred to the main memory, the high-speed buffer is refreshed to keep the data consistent.
[0012] The embodiment of the present invention synchronizes the data back to the main memory and refreshes the high-speed buffer to keep the data consistent.
[0013] In some embodiments of the present invention, the column number of each node in the data storage matrix is used as the subscript to traverse and calculate the slave core data of each row, and a sequential traversal is adopted, including:
[0014] The first order judgment step: when reading the line number of the position Less than the starting data row number of the data block When, or, when the line number of the read position Greater than or equal to the starting data row number of the slave core The number of slave core rows calculated When the sum is obtained, the value of each row of slave core data is obtained through the main memory;
[0015] Second order judgment step: when the line number of the read position Greater than or equal to the starting data row number of the slave core , and when the line number of the read position Less than the starting data row number of the slave core The number of slave core rows calculated When the sum of the values is , the value of each row of slave core data is obtained through the slave core corresponding to the read position;
[0016] The third sequential judgment step: when the line number of the read position Greater than or equal to the starting data row number of the data block , and when the line number of the read position Less than the starting data row number of the slave core When , the value of each row of slave core data is obtained through inter-core communication;
[0017] The line number of the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the slave core corresponding to the read position , the calculation formula is:
[0018] ;
[0019] According to the slave core corresponding to the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the starting data row number of the read position corresponding to the slave core , the calculation formula is:
[0020] ;
[0021] Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when the read position The data row number of the slave core corresponding to the read position is smaller than The number of slave core rows calculated When the sum of the read positions is obtained from the slave core corresponding to the read position through inter-core communication Each row in the is a value from the kernel data.
[0022] The column number of each node in the data storage matrix is used as the subscript to traverse and calculate the data of each row from the core, using reverse traversal, including:
[0023] The first reverse order judgment step: when reading the line number of the position Greater than the starting data row number of the data block When, or, when the line number of the read position Less than or equal to the starting data row number of the slave core The number of slave core rows calculated When the sum is obtained, the value of each row of slave core data is obtained through the main memory;
[0024] The second reverse order judgment step: when the row number of the read position Greater than the starting data row number of the slave core and the number of slave core rows calculated, and when the row number of the read position Less than the starting data row number of the slave core The amount of data calculated from the core When the sum of the corresponding number of rows is obtained, the value of each row of slave core data is obtained through the slave core corresponding to the read position;
[0025] The third reverse order judgment step: when the row number of the read position is smaller than the starting data row number of the data block, and when the row number of the read position Greater than or equal to the starting data row number of the slave core The amount of data calculated from the core When the sum of the corresponding number of rows is obtained, the value of each row of slave core data is obtained through inter-core communication;
[0026] The line number of the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the slave core corresponding to the read position , the calculation formula is:
[0027] ;
[0028] According to the slave core corresponding to the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the data row number of the slave core corresponding to the read position , the calculation formula is:
[0029] ;
[0030] Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when the line number of the read position Greater than the data row number of the slave core corresponding to the read position The number of slave core rows calculated When the sum of the read positions is obtained from the slave core corresponding to the read position through inter-core communication Each row in the is a value from the kernel data.
[0031] The embodiment of the present invention uses the methods of sequential traversal and reverse traversal, and by judging the relationship between the reading position and the starting data row number of the slave core and the starting data row number of the data block, it is possible to obtain the correct position of the data to be calculated, make the parallel calculation results accurate, and improve the parallel calculation efficiency.
[0032] In some embodiments of the present invention, the total number of slave cores The calculation formula is:
[0033] ;
[0034] in, is the total amount of the parallel computing data;
[0035] The data block calculates the amount of data The calculation formula is:
[0036] ;
[0037] in, The number of slave cores in a data block.
[0038] Among them, the starting data row number of each slave core is calculated by sequential traversal and reverse traversal respectively. and the starting data row number of each data block The process specifically includes:
[0039] Sequential slave core row number calculation steps: Calculate the starting data row number of each slave core by sequential traversal The calculation formula is:
[0040] ;
[0041] in, is the number of the data block; is the slave nuclear number;
[0042] Sequential data block row number calculation steps: Calculate the starting data row number of each data block by sequential traversal The calculation formula is:
[0043] ;
[0044] Reverse order slave row number calculation steps: Calculate the starting data row number of each slave by traversing in reverse order The calculation formula is:
[0045] ;
[0046] Reverse data block row number calculation steps: Calculate the starting data row number of each data block by sequential traversal The calculation formula is:
[0047] .
[0048] The embodiment of the present invention can reasonably allocate the computing tasks of the slave core by calculating the data volume of the data block, the starting data row number of the slave core, and the starting data row number of the data block, and provides data support for accurately locating the reading position of the required computing data.
[0049] In some embodiments of the present invention, the data initialization step is specifically:
[0050] After the slave core enters the full array fast thread group, the slave core function is started through memory broadcast setting, and the slave core function is synchronously exited through the array synchronization mechanism.
[0051] Wherein, the data initialization step further includes:
[0052] Memory management step: applying for a memory pool from the memory of the core private segment, allocating and using the memory pool according to preset parallel computing requirements, and managing the memory pool through a memory pool management algorithm.
[0053] The embodiment of the present invention can reduce the time spent on continuously allocating and releasing memory by allocating and using the memory pool according to the parallel computing requirements for the applied memory pool. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the specific embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0055] Figure 1 A schematic diagram of the structure of a SW26010 Shenwei multi-core processor provided in an embodiment of the present invention;
[0056] Figure 2 A flowchart of a multi-core-based data-dependent parallel computing method provided in an embodiment of the present invention;
[0057] Figure 3An application flow chart of a multi-core-based data-dependent parallel computing method provided in an embodiment of the present invention;
[0058] Figure 4 A step-by-step flow chart of a load balancing partitioning step S2 provided in an embodiment of the present invention;
[0059] Figure 5 A flowchart of sequentially traversing and calculating each row of slave core data provided by an embodiment of the present invention;
[0060] Figure 6 An application flow chart for sequentially traversing and calculating each row of slave core data provided by an embodiment of the present invention;
[0061] Figure 7 A flowchart of a reverse traversal and calculation of each row of slave core data provided by an embodiment of the present invention;
[0062] Figure 8 An application flow chart for reverse traversal and calculation of each row of slave core data is provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0064] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. 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 the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0065] High-performance computing refers to the use of aggregated computing power to handle data-intensive computing tasks that cannot be completed by standard workstations, including simulation, modeling, and rendering. When dealing with various computing problems, a general-purpose computer cannot complete the work within a reasonable time due to the large amount of calculations required, or the amount of data required is too large and the available resources are limited, resulting in the inability to perform the calculations at all. High-performance computing methods effectively overcome these limitations by using specialized or high-end hardware or integrating the computing power of multiple units.
[0066] The most commonly used method in parallel computing design is the PCAM method. PCAM is the abbreviation of Partitioning, Communication, Agglomeration and Mapping, which represents the four stages of designing parallel algorithms using this method: task division, communication analysis, task combination and processor mapping, referred to as partition, communication, combination and mapping; the division stage is to divide a problem into several parts evenly and let each processor execute them simultaneously; the communication stage is to analyze the data to be exchanged during the execution process and the coordination of tasks; the combination stage is to combine smaller problems together to improve performance and reduce task overhead; the mapping stage is to assign tasks to each processor.
[0067] Some existing methods for dealing with data dependency and data conflict problems in parallel computing include locking mechanisms, transactions, data replication, and blocking queues:
[0068] (1) Lock mechanism: protects shared data. When a task is accessing shared data, other tasks need to wait for it to release the lock before they can access it. This can avoid data conflicts and ensure consistency. However, the lock mechanism may cause performance degradation because other tasks need to wait for the lock to be released.
[0069] (2) Transactions: For situations involving multiple data operations, transactions can be used to ensure consistency and correctness. Transactions can treat a series of operations as a whole, either all succeeding or all failing, thereby ensuring data consistency. In parallel computing, transactions can be used to manage the operations of multiple tasks on data. However, if multiple transactions operate on the same batch of data, some problems will arise.
[0070] (3) Data replication: In some cases, data replication can be used to solve consistency problems. Data can be copied to multiple nodes and synchronized between nodes. This can improve parallel performance and tolerate the failure of some nodes, increasing some storage overhead.
[0071] (4) Blocking queue (producer-consumer model): Blocking queue can achieve synchronization and collaboration between threads. It can be used to solve the producer-consumer problem. The blocking queue acts as a buffer between the producer and the consumer. The producer thread inserts elements into the queue, and the consumer thread obtains elements from the queue. They coordinate through the blocking queue to achieve synchronization between threads.
[0072] It can be seen that the above four existing parallel computing methods using lock mechanisms, transactions, data replication, and blocking queues cannot improve performance and reduce task overhead in high-performance parallel computing. The application scenario of the present invention is that there are two types of data storing matrix information in the process of parallel acceleration. One type is the information representing each row of slave core data; the other type is the column number of each node in the data storage matrix. When calculating the information of each row of slave core data, it is necessary to traverse and update the value of each node column number as the subscript based on the information of each row of slave core data.
[0073] Combined with Figure 1 As shown, the Shenwei supercomputing platform adopted by the present invention is equipped with the SW26010 Shenwei multi-core processor. The SW26010 Shenwei multi-core processor uses a 64-bit autonomous Shenwei instruction set and adopts a master-slave core architecture. The SW26010 Shenwei multi-core processor has 4 core groups and 260 cores. Each core group includes a master core, an 8*8 slave core array, and a memory controller. The core group communicates with other devices through an on-chip network and can be connected to external devices through a system interface. The SW26010 Shenwei multi-core processor is good at processing regular and easy-to-parallel computing-intensive tasks, and has a larger-scale multi-level parallel computing unit and a unique on-chip storage structure.
[0074] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0075] The technical solution of the present invention is described in detail below in conjunction with specific embodiments and the accompanying drawings.
[0076] As attached Figure 2 -Attached Figure 3 As shown, the present invention provides a data-dependent parallel computing method based on many cores, comprising the following steps:
[0077] Data initialization step S1: obtain parallel computing data, assemble the parallel computing data into a structure and pass it to the slave core, the slave core enters the full array fast thread group, starts the slave core, and calculates the slave core load; further, after the slave core enters the full array fast thread group, the slave core function is started through memory broadcast, and the slave core function is synchronously exited through the array synchronization mechanism; optionally, the array synchronization mechanism is ; Optionally, the full array fast thread group mode is ;
[0078] Load balancing partitioning step S2: Configure the amount of data to be calculated from the core , according to the amount of parallel computing data and slave core computing data Calculate the total number of slave cores , based on the total number of slave cores Calculate the amount of data in the data block Divide the parallel computing tasks and complete the parallel computing work in batches. Calculate the starting data row number of each slave core through sequential traversal and reverse traversal and the starting data row number of each data block ; Optionally, calculate the amount of data from the kernel The initial value is 1. If the parallel computing data cannot be evenly distributed among the slave cores, the remaining data needs to be calculated using one more slave core.
[0079] Among them, the total number of cores The calculation formula is:
[0080] ;
[0081] in, is the total amount of parallel computing data; optionally, the parallel computing data uses a size of The sparse matrix is ;
[0082] Data block calculation data volume The calculation formula is:
[0083] ;
[0084] in, is the number of slave cores in a data block; optionally, The value of is 64.
[0085] Combined with Figure 4 As shown, the starting data row number of each slave core is calculated by sequential traversal and reverse traversal respectively. and the starting data row number of each data block The process specifically includes:
[0086] Sequential slave core row number calculation step S21: Calculate the starting data row number of each slave core by sequential traversal The calculation formula is:
[0087] ;
[0088] in, is the number of the data block; is the slave nuclear number;
[0089] Sequential data block row number calculation step S22: Calculate the starting data row number of each data block by sequential traversal The calculation formula is:
[0090] ;
[0091] Reverse order slave core row number calculation step S23: Calculate the starting data row number of each slave core by reverse order traversal The calculation formula is:
[0092] ;
[0093] Reverse data block row number calculation step S24: Calculate the starting data row number of each data block by sequential traversal The calculation formula is:
[0094] ;
[0095] Slave core data query step S3: Calculate the data volume based on the slave core and the starting data row number of the slave core Loop to calculate the value of each row of slave core data, according to the starting data row number of the slave core and the starting data row number of the data block Query the calculation position and reading position of each row of slave core data, determine whether the value of each row of slave core data is calculated and updated, and traverse and calculate each row of slave core data by using the column number of each node in the data storage matrix as the subscript;
[0096] Data synchronization step S4: After all parallel computing data in the full array fast thread group is calculated, the calculation results are transferred to the main memory, and after synchronously waiting for the communication to end, the calculation of the next data block is started synchronously. After the parallel computing data is transferred to the main memory, the high-speed buffer is refreshed to keep the data consistent; optionally, after all parallel computing data in the full array fast thread group is calculated, the calculation results are synchronously transferred to the main memory, which can avoid the situation where, when the amount of data is relatively large, the slave core that has not yet completed the calculation uses the updated data before waiting for the slave core array to complete the calculation and transfer it back to the main memory.
[0097] Based on the above method, by calculating the starting data row number of the slave core and the starting data row number of the data block, and finding the correct reading position of the calculated data according to the judgment method, and traversing each row of data to perform parallel calculations on the correct data, the data dependency and data conflict problems in parallel calculations are solved. By synchronously transmitting the data back to the main memory and refreshing the high-speed buffer, the data can be kept consistent.
[0098] Combined with Figure 5 -Attached Figure 6As shown, the column number of each node in the data storage matrix is used as the subscript to traverse and calculate the data from the core of each row, and the sequential traversal further includes:
[0099] First order determination step S501: When the line number of the read position Smaller than the starting data row number of the data block When, or, when reading the line number of the position Greater than or equal to the starting data row number of the slave core The number of slave core rows calculated When or , the value of each row of slave core data is obtained through the main memory;
[0100] Second order determination step S502: When the line number of the read position Greater than or equal to the starting data row number of the slave core , and when the line number of the reading position Less than the starting data row number of the slave core The number of slave core rows calculated When , the value of each row of slave core data is obtained by reading the slave core corresponding to the position;
[0101] The third order determination step S503: when the line number of the read position Greater than or equal to the starting data row number of the data block , and when the line number of the reading position Less than the starting data row number of the slave core When When , the value of each row of slave core data is obtained through inter-core communication;
[0102] By reading the line number of the position , the starting data row number of the data block , Calculate the amount of data from the core Calculate the slave core corresponding to the read position , the calculation formula is:
[0103] ;
[0104] According to the slave core corresponding to the read position , the starting data row number of the data block , Calculate the amount of data from the core Calculate the starting data row number of the read position corresponding to the slave core , the calculation formula is:
[0105] ;
[0106] Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when reading the position The data row number of the slave core corresponding to the read position is smaller than The number of slave core rows calculated When When the slave core corresponding to the read position is obtained through inter-core communication Each row in the is a value from the kernel data.
[0107] Combined with Figure 7 -Attached Figure 8 As shown, the column number of each node in the data storage matrix is used as the subscript to traverse and calculate the data from the core of each row, and the reverse traversal further includes:
[0108] First reverse order determination step S701: When the row number of the read position Greater than the starting data row number of the data block When, or, when reading the line number of the position Less than or equal to the starting data row number of the slave core The number of slave core rows calculated When or When , the value of each row of slave core data is obtained through the main memory;
[0109] Second reverse order determination step S702: When the row number of the read position Greater than the starting data row number of the slave core The sum of the number of slave core rows calculated, and the row number of the read position Less than the starting data row number of the slave core Calculate the amount of data from the kernel The sum of the corresponding number of rows, that is , the value of each row of slave core data is obtained by reading the slave core corresponding to the position;
[0110] The third reverse order determination step S703: when the row number of the read position is smaller than the starting data row number of the data block, and when the row number of the read position Greater than or equal to the starting data row number of the slave core Calculate the amount of data from the kernel The sum of the corresponding number of rows, that is When , the value of each row of slave core data is obtained through inter-core communication;
[0111] By reading the line number of the position , the starting data row number of the data block , Calculate the amount of data from the core Calculate the slave core corresponding to the read position , the calculation formula is:
[0112] ;
[0113] According to the slave core corresponding to the read position , the starting data row number of the data block , Calculate the amount of data from the core Calculate the data row number of the slave core corresponding to the read position , the calculation formula is:
[0114] ;
[0115] Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when reading the line number of the position Greater than the data row number of the slave core corresponding to the read position The number of slave core rows calculated When the sum of the read positions is obtained from the slave core corresponding to the read position through inter-core communication Each row in the is a value from the kernel data.
[0116] Based on the above method, through the two traversal modes of sequential traversal and reverse traversal, by judging the relationship between the reading position and the starting data row number of the slave core and the starting data row number of the data block, the correct position of the data to be calculated can be obtained, so that the parallel calculation results are accurate and the parallel calculation efficiency is improved.
[0117] In order to reduce the time spent on memory allocation and release, reduce communication, memory allocation and release overhead, and reduce some repeated calculations, the data initialization step S1 also includes:
[0118] Memory management step: applying for a memory pool from the memory of the core private segment, allocating and using the memory pool according to preset parallel computing requirements, and managing the memory pool through a memory pool management algorithm.
[0119] The calculation formula of the memory pool management algorithm is:
[0120]
[0121]
[0122]
[0123] By allocating and using the applied memory pool according to the parallel computing needs, the time spent on continuous memory allocation and release can be reduced, which greatly reduces the communication, memory allocation and release overhead, and reduces some repeated calculations.
[0124] After multiple rounds of iterations of the sparse matrix example, the data with data dependence was accelerated from 166.672 seconds to 13.962 seconds after parallel acceleration, and the verification calculation results were consistent with the serial case, thereby improving the efficiency of parallel computing and improving parallel processing efficiency while ensuring correctness.
[0125] It should be noted that the above is a reference method of a multi-core-based data-dependent parallel computing method, and the present invention is not limited thereto.
[0126] The embodiments of the present invention realize finding the value at the correct position by searching the starting data row number of the core and the starting data row number of the data block, and performing parallel calculation on the correct data by traversing each row of data, thereby solving the problems of data dependency and data conflict in parallel calculation, and solving the technical problems that the prior art causes performance degradation and calculation speed reduction by waiting for the dependent data calculation to be completed, increases storage overhead by setting a global array, and causes inaccurate calculation results and inconsistent data by not synchronizing the data.
[0127] Finally, it should be noted that: the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0128] The above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.
Claims
1. A data-dependent parallel computing method based on many cores, characterized in that: include: Data initialization step: obtaining parallel computing data, assembling the parallel computing data into a structure and then transmitting it to the slave core, the slave core enters the full array fast thread group, starts the slave core, and calculates the slave core load; Load balancing division steps: Configure the amount of data to be calculated from the core , according to the parallel computing data and the slave core computing data amount Calculate the total number of slave cores , according to the total number of slave cores Calculate the amount of data in the data block Divide the parallel computing tasks, and calculate the starting data row number of each slave core through sequential traversal and reverse traversal and the starting data row number of each data block ; Secondary core data query step: Calculate the data volume based on the secondary core and the starting data row number of the slave core Loop to calculate the value of each row of slave core data, according to the starting data row number of the slave core and the starting data row number of the data block Query the calculation position and reading position of each row of slave core data, determine whether the value of each row of slave core data is calculated and updated, and traverse and calculate each row of slave core data by using the column number of each node in the data storage matrix as the subscript; Among them, the column number of each node in the data storage matrix is used as the subscript to traverse and calculate the slave core data of each row, and a sequential traversal is adopted, including: The first order judgment step: when reading the line number of the position Less than the starting data row number of the data block When, or, when the line number of the read position Greater than or equal to the starting data row number of the slave core The number of slave core rows calculated When the sum is obtained, the value of each row of slave core data is obtained through the main memory; Second order judgment step: when the line number of the read position Greater than or equal to the starting data row number of the slave core , and when the line number of the read position Less than the starting data row number of the slave core The number of slave core rows calculated When the sum of the values is , the value of each row of slave core data is obtained through the slave core corresponding to the read position; The third sequential judgment step: when the line number of the read position Greater than or equal to the starting data row number of the data block , and when the line number of the read position Less than the starting data row number of the slave core When , the value of each row of slave core data is obtained through inter-core communication; Among them, the column number of each node in the data storage matrix is used as the subscript to traverse and calculate the slave core data of each row, and the reverse traversal is adopted, including: The first reverse order judgment step: when reading the line number of the position Greater than the starting data row number of the data block When, or, when the line number of the read position Less than or equal to the starting data row number of the slave core The number of slave core rows calculated When the sum is obtained, the value of each row of slave core data is obtained through the main memory; The second reverse order judgment step: when the row number of the read position Greater than the starting data row number of the slave core and the number of slave core rows calculated, and when the row number of the read position Less than the starting data row number of the slave core The amount of data calculated from the core When the sum of the corresponding number of rows is obtained, the value of each row of slave core data is obtained through the slave core corresponding to the read position; The third reverse order judgment step: when the row number of the read position is smaller than the starting data row number of the data block, and when the row number of the read position Greater than or equal to the starting data row number of the slave core The amount of data calculated from the core When the sum of the corresponding number of rows is obtained, the value of each row of slave core data is obtained through inter-core communication; Among them, the starting data row number of each slave core is calculated by sequential traversal and reverse traversal respectively. and the starting data row number of each data block The process specifically includes: Sequential slave core row number calculation steps: Calculate the starting data row number of each slave core by sequential traversal The calculation formula is: ; in, is the number of the data block; is the secondary nuclear number; Sequential data block row number calculation steps: Calculate the starting data row number of each data block by sequential traversal The calculation formula is: ; Reverse order slave row number calculation steps: Calculate the starting data row number of each slave by traversing in reverse order The calculation formula is: ; Reverse data block row number calculation steps: Calculate the starting data row number of each data block by sequential traversal The calculation formula is: ; in, is the total amount of data for the parallel calculation.
2. The data-dependent parallel computing method based on many cores according to claim 1, characterized in that: The method further comprises: Data synchronization step: After all parallel computing data in the full array fast thread group are calculated, the calculation results are transferred to the main memory and the calculation of the next data block is started synchronously. After the parallel computing data is transferred to the main memory, the high-speed buffer is refreshed to keep the data consistent.
3. The multi-core-based data-dependent parallel computing method according to claim 1, characterized in that: The third order determination step is specifically as follows: The line number of the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the slave core corresponding to the read position , the calculation formula is: ; According to the slave core corresponding to the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the starting data row number of the read position corresponding to the slave core , the calculation formula is: ; Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when the read position The data row number of the slave core corresponding to the read position is smaller than The number of slave core rows calculated When the sum of the read positions is obtained from the slave core corresponding to the read position through inter-core communication Each row in the is a value from the kernel data.
4. The data-dependent parallel computing method based on many cores according to claim 1, characterized in that: The third reverse order determination step is specifically as follows: The line number of the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the slave core corresponding to the read position , the calculation formula is: ; According to the slave core corresponding to the read position , the starting data row number of the data block 、The amount of data calculated from the core Calculate the data row number of the slave core corresponding to the read position , the calculation formula is: ; Get the slave core corresponding to the read position in real time The number of slave core rows calculated in , when the line number of the read position Greater than the data row number of the slave core corresponding to the read position The number of slave core rows calculated When the sum of the read positions is obtained from the slave core corresponding to the read position through inter-core communication Each row in the is a value from the kernel data.
5. The data-dependent parallel computing method based on many cores according to claim 1, characterized in that: The total number of slave cores The calculation formula is: ; The data block calculates the amount of data The calculation formula is: ; in, The number of slave cores in a data block.
6. The multi-core-based data-dependent parallel computing method according to any one of claims 1 to 5, characterized in that: The data initialization steps are specifically as follows: After the slave core enters the full array fast thread group, the slave core function is started through memory broadcast setting, and the slave core function is synchronously exited through the array synchronization mechanism.
7. The multi-core-based data-dependent parallel computing method according to any one of claims 1 to 5, characterized in that: The data initialization step also includes: Memory management step: applying for a memory pool from the memory of the core private segment, allocating and using the memory pool according to preset parallel computing requirements, and managing the memory pool through a memory pool management algorithm.
Citation Information
Patent Citations
Computational fluid dynamics fairing solver parallel optimization method based on SW architecture
CN115186604A
System and method for realizing inter-core communication of multiple processors based on programmable logic gate circuit
CN117909283A