Computing task parallel processing method based on MESI protocol
By combining the hash map structure and machine learning model in multi-core processors to optimize cache management and dynamically control lock and cache status, the performance bottleneck of the MESI protocol in high concurrency scenarios is solved, and efficient parallel computing and data consistency are achieved, improving Improved performance and scalability of multi-core processors.
Patent Information
- Application Number
- CN202411289851.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-09-14
AI Technical Summary
In multi-core processors, the MESI protocol has cache competition and increased synchronization overhead in high-concurrency scenarios, which limits the parallel computing capabilities of multi-core processors. Especially when managing data shared between multiple cores, it may lead to data inconsistency and Wrong calculation result.
Adopting a parallel processing method for computing tasks based on the MESI protocol, by establishing a hash map structure and a dynamic load balancing algorithm in each core, the task is decomposed into subtasks, and a machine learning model is used for cache pre-storage, combined with fine-grained concurrency control strategies and MESI cache coherence protocol, dynamically creates and deletes locks, optimizes cache management to avoid false sharing problems.
Under the premise of ensuring data consistency, the parallel computing capabilities of multi-core processors are fully utilized to achieve rapid response and efficient processing of complex application tasks, improve the performance and scalability of multi-core computing environments, and reduce performance bottlenecks caused by lock competition.
Smart Images

Figure CN118796485A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of concurrent control, and in particular to a method for parallel processing of computing tasks based on the MESI protocol. Background Art
[0002] In modern computer systems, as the performance of single-core processors gradually reaches a bottleneck, multi-core processor architecture has become an important solution to improve computing performance and responsiveness. However, the effective use of multi-core processors faces some challenges. One of them is how to manage memory data shared between multiple cores. In parallel computing, multiple cores may access the same data at the same time, which will lead to data inconsistency and incorrect computing results if not properly coordinated and synchronized.
[0003] To solve this problem, researchers proposed the MESI (Modified, Exclusive, Shared, Invalid) cache consistency protocol, which manages data sharing among multiple cores by defining multiple cache states. When a core modifies shared data, the data is marked as Modified. Other cores need to first invalidate their own cache copies and then obtain the latest data from the main memory or other cores. In this way, the MESI protocol can ensure the consistency and correctness of shared data.
[0004] However, in practical applications, the performance of the MESI protocol still has some bottlenecks, especially in high-concurrency scenarios, where a large amount of shared data access may lead to increased cache contention and synchronization overhead, thereby limiting the parallel computing capabilities of multi-core processors. Summary of the invention
[0005] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides a method for parallel processing of computing tasks based on the MESI protocol.
[0006] The present invention provides a method for parallel processing of computing tasks based on the MESI protocol, comprising: S1: Establish multiple cores based on the MESI protocol, wherein each core includes an independent task queue; S2: A hash graph structure is established in each of the cores to obtain a plurality of first optimized cores; S3: Decompose the task to be processed into multiple subtasks through a dynamic load balancing algorithm, and send the multiple subtasks to multiple first optimization cores respectively; S4: predicting the tasks to be processed by using a machine learning model, and pre-caching each of the first optimized cores according to the prediction results to obtain multiple second optimized cores; S5: Processing the to-be-processed tasks by processors established by multiple second optimized cores.
[0007] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, the hash map structure in step S2 is in the form of a key-value pair, the key of the hash map structure is an identifier of the resource to be concurrently controlled, and the value of the hash map structure is a lock manager corresponding to the resource to be concurrently controlled.
[0008] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, the hash map structure in step S2 is used to control the resources to be concurrently controlled in each core, specifically including dynamic creation of locks and dynamic deletion of locks.
[0009] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, the specific steps of dynamically creating a lock include: S211: monitoring that a task processing request accesses a resource to be concurrently controlled; S212: searching for a key of a corresponding hash map structure according to an identifier of the resource to be accessed and to be concurrently controlled; S213: searching for the value of the corresponding hash map structure and the corresponding lock manager according to the key of the hash map structure obtained by searching; S214: When the corresponding lock manager is not found, a new lock manager is created and inserted into the hash map structure corresponding to the accessed concurrent control resource.
[0010] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, the specific steps of dynamically deleting locks include: S221: monitoring that the access to the concurrent control resource to be used for the task processing request is completed; S222: releasing the concurrent control resources whose access has ended based on the reference counting rule; S223: Synchronize the hash map structure corresponding to the released concurrent control resources.
[0011] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, step S4 specifically includes: S41: predicting the address access demand of the subtask by using the urgency-seeking bad habit model; S42: According to the address access requirement, pre-fetch data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage.
[0012] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, the cache status of the cache line of the processor in step S5 at least includes Shared, Modified and Invalid.
[0013] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, step S5 further includes: When a subtask is read and modified by any second optimization core, the state of the cache line corresponding to the subtask to be read and modified is converted from Shared to Modified, or from Shared to Invalid; When a plurality of the second optimized cores read the same subtask and the same subtask is not modified, the Shared state is maintained through the MESI protocol.
[0014] The present invention provides a method for parallel processing of computing tasks based on the MESI protocol, and proposes a multi-core split acceleration executor that combines the MESI cache consistency protocol and a fine-grained concurrency control strategy to address challenges in high-performance computing, large-scale database transaction processing, and other application scenarios that require efficient concurrent execution. By optimizing cache management and avoiding problems such as false sharing, the executor can fully utilize the parallel computing capabilities of multi-core processors while ensuring data consistency, achieve rapid response and efficient processing of complex application tasks, and further promote performance improvement and scalability optimization in a multi-core computing environment.
[0015] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a flowchart of a method for parallel processing of computing tasks based on the MESI protocol provided by an embodiment of the present invention.
[0018] Figure 2 It is a flowchart of dynamically creating locks in a method for parallel processing of computing tasks based on the MESI protocol provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.
[0020] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0021] In order to better understand the present invention, the special terms appearing in the embodiments of the present invention are explained below.
[0022] MESI cache consistency protocol: is a protocol widely used in modern multi-core processors to maintain data consistency between caches. This protocol ensures that when multiple CPU cores each have cached copies of data at the same location in memory, they can correctly synchronize these copies to ensure that all cores see the same latest data at any time.
[0023] Modified (M): The cache line has been modified and exists only in the cache of the current core.
[0024] Exclusive (E): The cache line exists only in the cache of the current core and is consistent with the data in the main memory.
[0025] Shared (S): The cache line may exist in the cache of multiple cores, and all copies are consistent with the data in main memory.
[0026] Invalid (I): The cache line is invalid or no longer exists in the cache of the current core.
[0027] When the active core attempts to change a cache line in the S state, it must first use the cache coherence protocol to set the cache line in other cores to the I state before it can be set to the M state for modification. At this time, the active core will notify other cores to invalidate their own cache copies. Other cores need to invalidate their own cache copies first, and then obtain the latest data from the main memory or other cores.
[0028] Combine the following Figure 1 to Figure 2 Embodiments of the present invention are described.
[0029] like Figure 1 As shown, the present invention provides a method for parallel processing of computing tasks based on the MESI protocol, comprising: S1: Establish multiple cores based on the MESI protocol, wherein each core includes an independent task queue; In this stage, we establish multiple processor cores to design a multi-core processor system, in which each core is equipped with an independent task queue. In the subsequent steps, a dynamic load balancing algorithm is used to decompose complex tasks into multiple fine-grained subtasks, which are evenly distributed to the local queues of each core according to the current load of each core. S2: A hash graph structure is established in each of the cores to obtain a plurality of first optimized cores;
[0030] In step S2, we create a hash map structure in the form of key-value pairs inside each core, where the key is the resource identifier to be concurrently controlled and the value is the lock manager corresponding to the resource. Each lock manager uses mechanisms such as segmented locks or fine-grained read-write locks to support finer operation granularity.
[0031] The hash map structure in step S2 is in the form of a key-value pair, the key of the hash map structure is an identifier of the resource to be concurrently controlled, and the value of the hash map structure is a lock manager corresponding to the resource to be concurrently controlled.
[0032] In addition, for different parts of the same resource, such as array elements or object properties, hash maps can be used to independently assign locks to each part, thereby reducing lock contention during concurrent access. In addition, optimistic concurrency control or CAS operations can be introduced, combined with the version number mechanism to handle potential concurrent modification conflicts.
[0033] It should be noted that multiple processor cores also have adaptive learning capabilities and can dynamically adjust the granularity of locks based on the current system load conditions and resource access patterns. For example, some locks can be merged to reduce overhead when the load is low, and locks can be split in high-concurrency scenarios to improve concurrency.
[0034] The hash map structure in step S2 is used to control the resources to be concurrently controlled in each core, specifically including dynamically creating locks and dynamically deleting locks.
[0035] like Figure 2 As shown, the specific steps of dynamically creating a lock include: S211: monitoring that a task processing request accesses a resource to be concurrently controlled; S212: searching for a key of a corresponding hash map structure according to an identifier of the resource to be accessed and to be concurrently controlled; S213: searching for the value of the corresponding hash map structure and the corresponding lock manager according to the key of the hash map structure obtained by searching; S214: When the corresponding lock manager is not found, a new lock manager is created and inserted into the hash map structure corresponding to the accessed concurrent control resource.
[0036] Specifically, when a core needs to access a specific resource, it first queries the local hash map to obtain the lock status and acquires locks on demand, such as segmented locks, fine-grained read-write locks, etc., to achieve precise synchronization control of resource access and reduce lock contention. At the same time, the hash map is used to support the ability to dynamically create and recycle lock resources to adapt to concurrent access requirements of different scales and modes.
[0037] The specific steps of dynamically deleting the lock include: S221: monitoring that the access to the concurrent control resource to be used for the task processing request is completed; S222: releasing the concurrent control resources whose access has ended based on the reference counting rule; S223: Synchronize the hash map structure corresponding to the released concurrent control resources.
[0038] The above-mentioned process of dynamically creating locks can also be implemented based on reference counting rules. Specifically, when a thread or code snippet needs to access a protected resource, it tries to acquire the lock. If the lock is available (that is, the reference count is 0), the thread or code snippet acquires the lock and increases the reference count by 1. If the lock is not available (that is, the reference count is greater than 0), the thread or code snippet may need to wait until the lock is released.
[0039] When the thread or code snippet completes access to the protected resource, it should release the lock. Specifically, the process of releasing the lock includes reducing the reference count by 1. If the reference count becomes 0, it means that no thread or code snippet is referencing the lock anymore, then the lock is considered available and can be acquired by other threads or code snippets. S3: Decompose the task to be processed into multiple subtasks through a dynamic load balancing algorithm, and send the multiple subtasks to multiple first optimization cores respectively;
[0040] In this stage, we use a dynamic load balancing algorithm to decompose complex tasks into multiple fine-grained subtasks, that is, multiple task blocks, and evenly distribute them to the local queue of each core according to the current load of each core. S4: predicting the tasks to be processed by using a machine learning model, and pre-caching each of the first optimized cores according to the prediction results to obtain multiple second optimized cores;
[0041] In step S4, we use machine learning models to analyze program execution behavior and memory access patterns, dynamically predict future memory access addresses, and pre-fetch data from main memory to cache based on the prediction results. This can reduce latency and bus traffic caused by cache misses. The AI model can continuously optimize its prediction capabilities through online learning and adapt to program behavior changes.
[0042] Wherein, step S4 specifically includes: S41: predicting the address access demand of the subtask by using the urgency-seeking bad habit model; S42: According to the address access requirement, pre-fetch data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage.
[0043] Furthermore, a reinforcement learning algorithm is used to design an adaptive cache replacement strategy that can decide which cache lines should be retained or replaced based on the current workload and predicted future needs. This strategy can be adjusted based on the MESI status and the results of AI predictions.
[0044] In step S4, we optimized the processor core, or the MESI protocol, through a machine learning model. In addition to the cache pre-storage optimization mentioned above, we also analyzed the concurrent behavior of the application, identified potential false sharing issues through AI, and optimized data layout based on this to avoid unnecessary cache consistency conflicts. For complex concurrent scenarios, AI can help determine the optimal lock granularity or lock-free programming strategy, thereby reducing excessive cache synchronization overhead under the MESI protocol.
[0045] S5: Processing the to-be-processed tasks by processors established by multiple second optimized cores.
[0046] Wherein, the cache status of the cache line of the processor in step S5 at least includes Shared, Modified and Invalid.
[0047] Wherein, step S5 further includes: When a subtask is read and modified by any second optimization core, the state of the cache line corresponding to the subtask to be read and modified is converted from Shared to Modified, or from Shared to Invalid; When a plurality of the second optimized cores read the same subtask and the same subtask is not modified, the Shared state is maintained through the MESI protocol.
[0048] In the established processor, the cache level of each processor core uses the MESI protocol to ensure consistency between caches. Specifically, when a core modifies the data in the cache, it notifies other cores of the corresponding cache line status change through the bus, triggering the cache status to change from Shared to Modified or Invalid. For data blocks under fine-grained concurrency control, when they are read by multiple cores at the same time but not modified, the MESI protocol can be used to maintain the Shared state, allowing data to be shared in multiple core caches, effectively improving memory access efficiency.
[0049] In addition, communication between cores is achieved through an efficient point-to-point messaging mechanism. When it comes to cross-core lock requests or cache status updates, non-blocking messaging technology is used to reduce latency. In addition, the processor is designed with a set of flexible and compatible API interfaces, allowing upper-level applications to transparently use this accelerated executor to complete efficient concurrent task execution.
[0050] The present invention provides a method for parallel processing of computing tasks based on the MESI protocol. When updating a shared data structure in a large-scale concurrent environment, the system can automatically divide a large data set into multiple small particles and control the concurrent access of each part respectively, which significantly improves the overall throughput and response speed of the system and reduces the blocking phenomenon caused by lock contention; in addition, it also solves the problem of how to efficiently perform task allocation, resource access control and cache consistency management in large-scale parallel computing and data sharing scenarios.
[0051] In general, the present invention effectively improves the parallel computing capability and data consistency guarantee of the multi-core processor system by combining the dynamic fine-grained concurrency control strategy based on hash graph with the MESI cache consistency protocol, reduces the performance bottleneck caused by lock contention, and realizes efficient and stable operation in a multi-core environment.
[0052] The application prospects of the present invention mainly include task allocation, resource access control and cache consistency management in large-scale parallel computing and data sharing scenarios. For example, in a cloud computing environment, by utilizing a multi-core split acceleration executor, efficient parallel processing of large-scale computing tasks can be achieved, thereby improving computing efficiency and performance. In addition, in a distributed system, the present invention can be used to solve resource competition and data consistency problems between multi-core processor nodes, thereby improving system reliability and scalability.
[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for parallel processing of computing tasks based on the MESI protocol, characterized in that: include: S1: Establish multiple cores based on the MESI protocol, wherein each core includes an independent task queue; S2: A hash graph structure is established in each of the cores to obtain a plurality of first optimized cores; S3: Decompose the task to be processed into multiple subtasks through a dynamic load balancing algorithm, and send the multiple subtasks to multiple first optimization cores respectively; S4: predicting the tasks to be processed by using a machine learning model, and pre-caching each of the first optimized cores according to the prediction results to obtain multiple second optimized cores; S5: Processing the to-be-processed tasks by processors established by multiple second optimized cores.
2. The method for parallel processing of computing tasks based on the MESI protocol according to claim 1, characterized in that: The hash map structure in step S2 is in the form of a key-value pair, the key of the hash map structure is an identifier of the resource to be concurrently controlled, and the value of the hash map structure is a lock manager corresponding to the resource to be concurrently controlled.
3. The method for parallel processing of computing tasks based on the MESI protocol according to claim 2, characterized in that: The hash map structure in step S2 is used to control the resources to be concurrently controlled in each core, specifically including dynamically creating locks and dynamically deleting locks.
4. The method for parallel processing of computing tasks based on the MESI protocol according to claim 3, characterized in that: The specific steps of dynamically creating a lock include: S211: monitoring that a task processing request accesses a resource to be concurrently controlled; S212: searching for a key of a corresponding hash map structure according to an identifier of the resource to be accessed and to be concurrently controlled; S213: searching for the value of the corresponding hash map structure and the corresponding lock manager according to the key of the hash map structure obtained by searching; S214: When the corresponding lock manager is not found, a new lock manager is created and inserted into the hash map structure corresponding to the accessed concurrent control resource.
5. The method for parallel processing of computing tasks based on the MESI protocol according to claim 4, characterized in that: The specific steps of dynamically deleting a lock include: S221: monitoring that the access to the concurrent control resource to be used for the task processing request is completed; S222: releasing the concurrent control resources whose access has ended based on the reference counting rule; S223: Synchronize the hash map structure corresponding to the released concurrent control resources.
6. The method for parallel processing of computing tasks based on the MESI protocol according to claim 1, characterized in that: Step S4 specifically includes: S41: predicting the address access demand of the subtask by using the urgency-seeking bad habit model; S42: According to the address access requirement, pre-fetch data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage.
7. The method for parallel processing of computing tasks based on the MESI protocol according to claim 1, characterized in that: The cache status of the cache line of the processor in step S5 at least includes Shared, Modified and Invalid.
8. The method for parallel processing of computing tasks based on the MESI protocol according to claim 7, characterized in that: Step S5 also includes: When a subtask is read and modified by any second optimization core, the state of the cache line corresponding to the subtask to be read and modified is converted from Shared to Modified, or from Shared to Invalid; When a plurality of the second optimized cores read the same subtask and the same subtask is not modified, the Shared state is maintained through the MESI protocol.
Citation Information
Patent Citations
Unlocked flow table routing lookup algorithm adopting high-speed parallel execution manner
CN102938000A
Apparatus, method, and system for providing a decision mechanism for conditional commits in an atomic region
CN103119556A
Hash table concurrent access performance optimization method under multi-core environment
CN104536724A
Method for accelerating GPU directed at deep learning super-resolution technology
CN105869117A
Deep hash learning method and device
CN108629414A
Cited By
Cloud platform resource scheduling optimization method and system of multi-chip architecture
CN120104308A
