A parallel processing method for computing tasks based on MESI protocol

By adopting hash graph structure and dynamic lock management in multi-core processors and optimizing cache management with machine learning model, the problem of cache competition and synchronization overhead in medium and high concurrency scenarios of multi-core processors is solved, and efficient parallel computing and data consistency are achieved , improves multi-core computing performance and scalability.

CN118796485BActive Publication Date: 2024-11-19JIANGSU HUAKU DATA TECH CO LTD +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411289851.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-11-19
Estimated Expiration
2044-09-14

AI Technical Summary

Technical Problem

In multi-core processors, large amounts of shared data access in high concurrency scenarios lead to increased cache competition and synchronization overhead, limiting the parallel computing power of multi-core processors, and there are bottlenecks in performance of the existing MESI protocol.

Method used

Using the parallel processing method of computing tasks based on MESI protocol, by establishing a hash graph structure and dynamic lock management in each core, combining machine learning models for cache pre-assembly and optimization, dynamically decompose tasks and perform fine-grained concurrency control, optimize cache management to Avoid pseudo-sharing and lock competition.

Benefits of technology

On the premise of ensuring data consistency, the parallel computing power of multi-core processors is fully utilized to achieve rapid response and efficient processing of complex application tasks, improving the performance and scalability of the multi-core computing environment and reducing performance bottlenecks caused by lock competition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796485B_ABST
    Figure CN118796485B_ABST
Patent Text Reader

Abstract

This invention provides a parallel processing method for computing tasks based on the MESI protocol, relating to the field of concurrency control technology. Specifically, it includes: establishing multiple cores based on the MESI protocol, where each core includes an independent task queue; establishing a hash graph structure in each core to obtain multiple first optimized cores; decomposing the task to be processed into multiple subtasks and distributing the subtasks to the multiple first optimized cores; predicting the task to be processed using a machine learning model, and pre-caching the results for each first optimized core to obtain multiple second optimized cores; and processing the task to be processed using processors established from the multiple second optimized cores. This invention reduces performance bottlenecks caused by lock contention and achieves efficient and stable processing of computing tasks in a multi-core environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of concurrency 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 single-core processors gradually reach performance bottlenecks, multi-core processor architectures have become an important solution for improving computing performance and responsiveness. However, effectively utilizing multi-core processors presents several challenges. One of these challenges is managing memory data shared between multiple cores. In parallel computing, multiple cores may access the same data simultaneously. Without proper coordination and synchronization, this can lead to data inconsistencies and erroneous computational results.

[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 cache contention and increased 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:

[0007] S1: establishing multiple cores based on the MESI protocol, wherein each core includes an independent task queue;

[0008] S2: establishing a hash graph structure in each of the cores to obtain a plurality of first optimized cores;

[0009] S3: Decompose the task to be processed into multiple subtasks using a dynamic load balancing algorithm, and distribute the subtasks to multiple first optimization cores respectively;

[0010] S4: Predicting the tasks to be processed by a machine learning model, and pre-caching each first optimization core according to the prediction results to obtain multiple second optimization cores;

[0011] S5: Processing the to-be-processed tasks by using a processor established by multiple second optimized cores.

[0012] 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 the identifier of the resource to be concurrently controlled, and the value of the hash map structure is the lock manager corresponding to the resource to be concurrently controlled.

[0013] 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.

[0014] 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:

[0015] S211: Monitoring that a task processing request accesses a resource to be controlled concurrently;

[0016] S212: searching for a key of a corresponding hash map structure according to the identifier of the accessed resource to be concurrently controlled;

[0017] S213: Searching for the corresponding hash map structure value and the corresponding lock manager according to the key of the hash map structure obtained by searching;

[0018] 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 resource to be concurrently controlled.

[0019] 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 a lock include:

[0020] S221: monitoring that the access to the concurrent control resource for the task processing request is completed;

[0021] S222: releasing the pending concurrent control resource whose access has ended based on the reference counting rule;

[0022] S223: Synchronize the hash map structure corresponding to the released concurrent control resources.

[0023] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, step S4 specifically includes:

[0024] S41: Predicting the address access requirements of the subtask using a machine learning model;

[0025] S42: According to the address access requirement, pre-fetch the data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage.

[0026] 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 includes at least Shared, Modified, and Invalid.

[0027] According to a method for parallel processing of computing tasks based on the MESI protocol provided by the present invention, step S5 further includes:

[0028] 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;

[0029] 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.

[0030] 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 the 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.

[0031] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.

[0033] Figure 1This is a flow chart of a method for parallel processing of computing tasks based on the MESI protocol provided by an embodiment of the present invention.

[0034] Figure 2 This is a flow chart 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

[0035] To make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the present invention. Obviously, the embodiments described are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0036] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean 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 can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0037] In order to better understand the present invention, the specific terms appearing in the embodiments of the present invention are explained below.

[0038] 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.

[0039] Modified (M): The cache line has been modified and exists only in the cache of the current core.

[0040] Exclusive (E): The cache line exists only in the cache of the current core and is consistent with the data in main memory.

[0041] Shared (S): The cache line may exist in the cache of multiple cores, and all copies are consistent with the data in main memory.

[0042] Invalid (I): The cache line is invalid or no longer exists in the cache of the current core.

[0043] When the active core attempts to modify 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 changed to the M state. At this time, the active core notifies other cores to invalidate their own cache copies. Other cores must invalidate their own cache copies before obtaining the latest data from main memory or other cores.

[0044] The following combination Figures 1 to 2 Embodiments of the present invention are described.

[0045] like Figure 1 As shown, the present invention provides a method for parallel processing of computing tasks based on the MESI protocol, comprising:

[0046] S1: establishing multiple cores based on the MESI protocol, wherein each core includes an independent task queue;

[0047] In this phase, we establish multiple processor cores to design a multi-core processor system, where each core is equipped with an independent task queue. In 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 based on the current load of each core.

[0048] S2: establishing a hash graph structure in each of the cores to obtain a plurality of first optimized cores;

[0049] In step S2, we create a key-value hash map structure within each core, where the key is the resource identifier to be controlled concurrently and the value is the lock manager corresponding to that resource. Each lock manager uses mechanisms such as segmented locks or fine-grained read-write locks to support finer operation granularity.

[0050] The hash map structure in step S2 is in the form of a key-value pair, the key of the hash map structure is the identifier of the resource to be concurrently controlled, and the value of the hash map structure is the lock manager corresponding to the resource to be concurrently controlled.

[0051] 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.

[0052] 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, when the load is low, some locks can be merged to reduce overhead, and in high-concurrency scenarios, locks can be split to improve concurrency.

[0053] 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.

[0054] like Figure 2 As shown, the specific steps of dynamically creating a lock include:

[0055] S211: Monitoring that a task processing request accesses a resource to be controlled concurrently;

[0056] S212: searching for a key of a corresponding hash map structure according to the identifier of the accessed resource to be concurrently controlled;

[0057] S213: Searching for the corresponding hash map structure value and the corresponding lock manager according to the key of the hash map structure obtained by searching;

[0058] 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 resource to be concurrently controlled.

[0059] Specifically, when a core needs to access a specific resource, it first queries the local hash map to obtain the lock status and obtains locks on demand, such as segmented locks and fine-grained read-write locks, thereby achieving precise synchronization control of resource access and reducing 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.

[0060] The specific steps of dynamically deleting a lock include:

[0061] S221: monitoring that the access to the concurrent control resource for the task processing request is completed;

[0062] S222: releasing the pending concurrent control resource whose access has ended based on the reference counting rule;

[0063] S223: Synchronize the hash map structure corresponding to the released concurrent control resources.

[0064] The above-mentioned dynamic lock creation process can also be implemented based on the reference counting rule. 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.

[0065] When a 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 references the lock anymore, then the lock is considered available and can be acquired by other threads or code snippets.

[0066] S3: Decompose the task to be processed into multiple subtasks using a dynamic load balancing algorithm, and distribute the subtasks to multiple first optimization cores respectively;

[0067] In this phase, 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 based on the current load of each core.

[0068] S4: Predicting the tasks to be processed by a machine learning model, and pre-caching each first optimization core according to the prediction results to obtain multiple second optimization cores;

[0069] 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 changes in program behavior.

[0070] Wherein, step S4 specifically includes:

[0071] S41: Predicting the address access requirements of the subtask using a machine learning model;

[0072] S42: According to the address access requirement, pre-fetch the data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage.

[0073] Furthermore, a reinforcement learning algorithm is used to design an adaptive cache replacement strategy that can determine 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.

[0074] In step S4, we optimized the processor core, or in other words, 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, used AI to identify potential false sharing issues, 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.

[0075] S5: Processing the to-be-processed tasks by using a processor established by multiple second optimized cores.

[0076] The cache status of the cache line of the processor in step S5 at least includes Shared, Modified and Invalid.

[0077] Wherein, step S5 further includes:

[0078] 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;

[0079] 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.

[0080] In the established processor, the cache hierarchy 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 simultaneously 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.

[0081] 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.

[0082] 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 separately, 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.

[0083] 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.

[0084] 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.

[0085] 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 various embodiments of the present invention.

Claims

1. A method for parallel processing of computing tasks based on the MESI protocol, It is 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; 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; 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; 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; 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 to-be-processed tasks by using a machine learning model, and pre-caching each of the first optimized cores according to the prediction results to obtain a plurality of second optimized cores; Step S4 specifically includes: S41: predicting the address access requirement of the subtask by a machine learning model; S42: According to the address access requirement, pre-fetching data corresponding to the address access requirement from the main memory to the cache to complete cache pre-storage; S5: Processing the to-be-processed tasks by processors established by multiple second optimized cores.

2. A method for parallel processing of computing tasks based on the MESI protocol according to claim 1, It is 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 1, It is characterized in that The cache status of the cache line of the processor in step S5 at least includes Shared, Modified and Invalid.

4. The method for parallel processing of computing tasks based on the MESI protocol according to claim 3, It is 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