CN115269226A - Multithreading multistage parallel communication method based on atomic message and shared cache - Google Patents

Multithreading multistage parallel communication method based on atomic message and shared cache Download PDF

Info

Publication number
CN115269226A
CN115269226A CN202210888202.9A CN202210888202A CN115269226A CN 115269226 A CN115269226 A CN 115269226A CN 202210888202 A CN202210888202 A CN 202210888202A CN 115269226 A CN115269226 A CN 115269226A
Authority
CN
China
Prior art keywords
synchronous
message
atomic
data
thread
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210888202.9A
Other languages
Chinese (zh)
Inventor
李靖舒
沈洋
夏东方
吴波
胡怀春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
724th Research Institute of CSIC
Original Assignee
724th Research Institute of CSIC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 724th Research Institute of CSIC filed Critical 724th Research Institute of CSIC
Priority to CN202210888202.9A priority Critical patent/CN115269226A/en
Publication of CN115269226A publication Critical patent/CN115269226A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)

Abstract

The invention discloses a multithreading multistage parallel communication method based on atomic messages and shared cache, which comprises the following steps: determining a multithreading hierarchical relation of the software application engineering; establishing synchronous and asynchronous relations and producer and consumer relations among threads of all levels; wherein, the thread of the synchronous relationship establishes a synchronous atomic message and a synchronous shared data cache communication set; the thread of the asynchronous relation establishes an asynchronous atomic message and an asynchronous data cache communication set; the producer thread updates the synchronous or asynchronous message in the current atomic message and puts the packaged message and data structure into a communication set; and the consumer thread acquires the synchronous atomic message in real time, analyzes the data in the message body and completes the subsequent operation. By adopting the packaged atomic message and shared buffer communication set mode, the message communication and data interaction of the multi-level threads are met, the real-time requirement is met, and the flexibility and the stability of the multi-thread communication of the application program are effectively improved.

Description

Multithreading multistage parallel communication method based on atomic message and shared cache
Technical Field
The invention relates to the field of multithread processing, in particular to a multithread multistage parallel communication method based on atomic messages and shared cache.
Background
In recent decades, multi-core processors are widely applied to various fields due to the advantages of strong parallel computing capability, multi-task processing capability, high integration, low power consumption and the like, and the performance advantages of the multi-core processors are better exerted due to the application development of the multi-thread parallel processing technology. However, the multi-thread parallel programming technology is more difficult to research, develop and debug than single-thread and serial programming, and application developers need to know various problems such as a running mechanism of threads, synchronous and asynchronous relation of threads, scheduling of threads, message communication of threads, data transmission of threads, task allocation of threads and the like, so that the problems are solved, and the powerful parallel processing advantage of the multi-core multi-thread processor cannot be truly exerted.
With the increase of the number of threads, the communication among the threads is more and more, and the time and the resources spent on the thread communication are more and more. The stable and efficient communication mode can complete the communication task and effectively reduce the communication cost; otherwise, not only the processing time is wasted, but also deadlock among threads is easily caused, and the processing performance is reduced. Therefore, good thread communication is particularly important in current multi-core multithreaded processor applications.
The current mainstream communication methods in the existing message communication methods of the multi-core processor include a timer discrimination mode and a token triggering communication method. The timer distinguishing mode is used for controlling asynchronous communication by adding data transmission communication handles generated by all threads into a linked list, and adopts the timer to distinguish success or failure of communication. The method comprises the steps that after a parallel phase is finished and a synchronization point is reached, a token is obtained, the token enters a serial phase according to the sequence of obtaining the token, after execution of the serial phase of the thread is finished, a synchronization point blocks, and after all threads finish the serial phase, a new round of transaction execution is started.
Through the analysis, the timeliness and the reliability of the communication among the threads cannot be ensured only by setting a fixed synchronization point for thread synchronization. Therefore, there is still a need for improvement and development of the prior art.
Disclosure of Invention
The invention aims to provide a multithreading multistage parallel communication method based on atomic messages and shared cache, which realizes a thread information interaction mode of atomic message driving and shared cache data by establishing atomic read-write identification messages and shared data cache structure communication sets among multiple threads in a multistage parallel relation, so that synchronous, asynchronous data communication and interaction operation are completed among multistage threads according to different message communication sets, thereby improving the stability and reliability of communication among the multistage threads in an application program.
The invention provides a multithreading multistage parallel communication method based on atomic messages and shared cache, which adopts the following technical scheme:
A. and determining the multithreading hierarchical relationship of the software application engineering, namely the thread series parallel interval, the number of parallel hierarchies and the number of threads in each layer.
B. Determining synchronous and asynchronous relations and producer and consumer relations among all hierarchical threads;
C. for the thread of the synchronization relationship, establishing a synchronous atomic message and a synchronous shared data cache communication set; for the thread with the asynchronous relation, establishing an asynchronous atomic message and an asynchronous data cache communication set; producer and consumer threads of a synchronization relationship share an atomic message and a data cache communication set; producer and consumer threads in asynchronous relation own respective atomic message and data cache communication sets;
D. a producer thread of a producer and consumer relation acquires synchronous or asynchronous atomic messages in a current communication set, and updates synchronous messages and synchronous shared data cache or updates asynchronous messages and asynchronous data cache;
E. and the consumer thread of the relationship between the producer and the consumer acquires the synchronous or asynchronous atomic message in the corresponding communication set, analyzes the buffer data in the message body and completes the subsequent operation.
Furthermore, in the serial-parallel interval of the multiple threads in the step A, the output of one thread module is not used as the input of another thread module as the basis for distinguishing; the main threads of the multi-thread parallel relation are used as primary parallel, the main threads of the parallel task units are used as secondary parallel, and the sub-threads derived from the main threads of the parallel task units are used as tertiary parallel; and determining the specific application requirements of the thread data in each layer of parallel relation.
Further, wherein step C comprises:
c1, synchronous atom messages and synchronous shared data cache communication sets of all levels of threads in a synchronous relation are established on a shared memory; the asynchronous atomic message and the asynchronous data cache communication set of the asynchronous relation thread are both established on a shared memory;
c2, sharing an atomic message and a data cache communication set column by the producer and the consumer threads of the synchronous relation; producer and consumer threads in asynchronous relation own atomic message and data cache communication sets respectively;
further, the atomic message and data cache communication set in the step C is independent of threads at all levels;
further, the original sub-message in step C is divided into a write identifier lwritcount and a read identifier lReadCnt; the Size and number Num of the data buffer area are determined according to different application requirements.
Further, step D further includes:
d1, after the producer threads in the synchronous relation finish the processing operation, atomic operation updates the write identifier, and circularly traverses the data of the buffer area according to the write identifier to update the data of the buffer area in the corresponding synchronous shared data cache;
d2, after the producer threads in the asynchronous relation complete the processing operation, atomic operation updates the write identifier, and buffer data in respective data caches are updated according to the write identifier by circularly traversing the buffer data;
further, step E further includes:
e1, consumer threads in the synchronization relation acquire the synchronization messages in the synchronization message communication set, circularly read the write identification, then circularly traverse the buffer area data in the synchronous shared cache communication set according to the read identification to update the read identification through real-time atomic operation, and complete subsequent processing;
e2, a consumer thread in the asynchronous relation acquires the asynchronous message in the asynchronous message communication set, reads the write identifier circularly, updates the read identifier by atomic operation, and circularly traverses the buffer area data in the asynchronous data cache communication set according to the read identifier to complete subsequent processing;
furthermore, the producer completes data processing to update the writing identifier lWriteCnt and writes the processing result into the data buffer area corresponding to the identifier; and the consumer acquires the writing identifier lWriteCnt, updates the corresponding reading identifier lReadCnt and circularly traverses the data of the buffer area according to the reading identifier. The difference value of the read-write identification represents the processing speed difference value between the producer and the consumer, and when the difference value is larger than the critical value of the buffer area, the consumer is overtaken by the producer and cannot be processed in time; when the difference is smaller than the buffer critical value, the processing is normally performed.
Further, the producer updates the writing identifier lwritcount, writes the processing result into the buffer area communication set according to the writing identifier, does not block at the synchronization point until the consumer completes the processing, but immediately returns to the beginning, continues to wait for a new data processing request, and completes a new round of data processing, updates the writing identifier lwritcount and updates the buffer area data; the consumer can circularly process one by one according to the read-write identification difference value, thereby reducing the time consumption caused by synchronous blocking of the producer.
According to the multithreading multistage parallel communication method based on the atomic message and the shared cache, message communication among multiple threads is carried out among the multistage parallel threads in an atomic operation read-write identification and shared data cache structure communication set mode, one-to-one, one-to-many, many-to-one and many-to-many flexible communication between a producer and a consumer is achieved, the thread interaction relation in different application scenes is guaranteed, and the flexibility and the reliability of multithreading communication among multi-core multithreading systems are greatly improved.
Drawings
FIG. 1 is an operational flow diagram of a method of multi-threaded multi-level parallel communication based on atomic messages and shared caches;
FIG. 2 is a multi-thread relationship diagram of a multi-threaded multi-level parallel communication method based on atomic messages and shared cache;
FIG. 3 is a flow diagram of a method of multi-threaded, multi-level, parallel communication based on atomic messages and shared caches.
Detailed Description
The following describes a multithreading multi-level parallel communication method based on atomic message and shared cache in detail with reference to the embodiments and the accompanying drawings.
Fig. 1 is an operation flowchart of an embodiment of a multithreading multi-level parallel communication method based on atomic messages and shared cache, and the specific operation steps include:
step 1: determining a multithreading hierarchical relation of the software application engineering, namely a thread series-parallel interval, the number of parallel hierarchies and the number of threads in each layer;
and 2, step: determining synchronous and asynchronous relations and producer and consumer relations among all hierarchical threads;
and step 3: establishing a synchronous atomic message and a synchronous shared data cache structure communication set for the threads of the synchronous relation; for the thread of the asynchronous relation, establishing an asynchronous atomic message and an asynchronous data cache structure communication set; producer and consumer threads of the synchronous relation share an atomic message and a data cache structure communication set; producer and consumer user threads of the asynchronous relation have respective atomic message and data cache structure communication sets;
and 4, step 4: a producer thread of a producer and consumer relation acquires synchronous or asynchronous atomic messages in a current communication set, and updates synchronous messages, shared data cache or updates asynchronous messages and asynchronous data cache;
and 5: and the consumer thread of the relationship between the producer and the consumer acquires the synchronous or asynchronous atomic message in the corresponding communication set, analyzes the buffer data in the message body and completes the subsequent operation.
As shown in fig. 2, a thread relationship diagram of a multithread multilevel parallel communication method based on atomic messages and shared cache is shown, where a main thread is used as a producer to generate data, and an atomic update write identifier and a buffer communication set are sent to a next level parallel thread consumer; after the consumer thread reads the write identifier, updating the read identifier and processing the buffer communication set data to serve as a next-level parallel thread producer, and atomically updating a new-level write identifier and a buffer communication set, wherein the producer and the consumer belong to a synchronous relation; the main thread is derived into multi-channel sub-threads which serve as consumers, data interaction does not exist among the sub-threads, and the sub-threads belong to an asynchronous relation at the moment.
Fig. 3 is a thread communication flow chart of a multithreading multi-level parallel communication method based on atomic messages and shared cache, which includes the following steps:
step 1: the producer completes the processing of the current data, updates the writing identifier through atomic operation, updates the data in the buffer area according to the writing identifier in a traversing way, and puts the packaged message and the data structure body into a message queue; then, the producer continues to process the next round of data;
step 2: the consumer side circularly judges whether the written mark of the producer is updated, if so, the step 3 is carried out; otherwise, entering the step 1;
and step 3: the consumer reads the write identification and judges whether the write identification of the producer is larger than the read identification of the consumer; if yes, entering step 4; otherwise, returning to the step 2;
and 4, step 4: the consumer end calculates whether the difference value between the producer writing identification and the consumer reading identification is larger than the critical value of the buffer area; if yes, entering step 5; otherwise, entering step 6; setting a critical value of the buffer area according to the actual use size;
and 5: when the value is larger than the critical value, namely the consumer is overtaken by the producer, the processing is not in time, and the data is reloaded after the read-write identification queue is initialized;
step 6: and when the value is smaller than the critical value, the consumer thread performs atomic operation to update the read identifier, the subsequent processing is completed, and the data in the buffer area is updated circularly according to the difference value of the read identifier and the read identifier.

Claims (8)

1. A multithreading multi-level parallel communication method based on atomic messages and shared cache comprises the following steps:
A. determining a multithreading hierarchical relationship of a software application project, namely a thread serial-parallel interval, the number of parallel hierarchies and the number of threads on each layer;
B. determining synchronous and asynchronous relations and producer and consumer relations among all hierarchical threads;
C. establishing a synchronous atomic message and a synchronous shared data cache structure communication set for the threads of the synchronous relation; for the thread with an asynchronous relation, establishing an asynchronous atomic message and an asynchronous data cache structure communication set;
D. a producer thread of a producer and consumer relation acquires synchronous or asynchronous atomic messages in a current communication set, and updates a synchronous message and a synchronous shared data cache or updates an asynchronous message and an asynchronous data cache;
E. and the consumer thread of the relationship between the producer and the consumer acquires the synchronous or asynchronous atomic message in the corresponding communication set, analyzes the buffer data in the message body and completes the subsequent operation.
2. The method of claim 1, wherein the method comprises: in the step A, the output of one thread module is not used as the input of another thread module as the basis for distinguishing the multi-thread serial-parallel interval; the main threads of the multi-thread parallel relation are used as primary parallel, the main threads of the parallel task units are used as secondary parallel, and the sub-threads derived from the main threads of the parallel task units are used as tertiary parallel; the number of threads in the parallel relation of each layer is determined according to the specific application requirements.
3. The method of claim 1, wherein the method comprises: and C, the communication set of the original messages and the data cache in the step C is independent of threads at all levels.
4. The method of claim 1, wherein the method comprises: in the step C, the atomic message is divided into a writing identification atomic message lWriteCnt and a reading identification atomic message lReadCnt; the Size of the data buffer area and the number Num of the buffer areas are determined according to different application requirements; the atomic message and data buffer queues are established on the shared memory.
5. The multi-threaded multi-level parallel communication method based on the atomic message and the shared cache as claimed in claim 1, wherein: the producer and consumer threads of the synchronization relation in the step C share the atomic message and the data cache communication set; threads of an asynchronous relationship own respective sets of atomic messages and data cache communications.
6. The method of claim 1, wherein the method comprises: after the producer thread in the synchronization relation completes the processing operation, atomically updating the synchronous atomic message write identifier in the current communication set, and updating the buffer area data in the corresponding synchronous data cache according to the write identifier; and circularly acquiring the synchronous atomic message writing identifier in the synchronous communication set by the consumer thread in the synchronous relation, then updating the reading identifier by atomic operation, acquiring the buffer area data in the corresponding data cache set according to the reading identifier, and finishing the subsequent processing.
7. The method of claim 6, wherein the method comprises: the producer completes data processing to update the writing identifier lWriteCnt, and writes the processing result into the data buffer area corresponding to the identifier in a writing identifier residue-taking mode; a consumer acquires a writing identifier lWriteCnt, updates a corresponding reading identifier lReadCnt, and circularly traverses the data of the buffer area according to the reading identifier; the difference value of the read-write identification represents the processing speed difference value between the producer and the consumer, and when the difference value is larger than the critical value of the buffer area, the consumer is overtaken by the producer and cannot be processed in time; when the difference is smaller than the buffer critical value, the processing is normally performed.
8. The method of claim 7, wherein the atomic message and shared cache based multithreaded multistage parallel communication method comprises: the producer updates the writing identifier lWriteCnt, writes the processing result into the buffer area communication set according to the writing identifier, does not block at a synchronization point until the consumer finishes processing, but immediately returns to the beginning to continuously wait for a new data processing request to finish a new round of data processing, updating the writing identifier lWriteCnt and updating the data in the buffer area; the consumer can circularly process one by one according to the read-write identification difference value on one side; the producer and the consumer do not have simultaneous read and write operations for respective write and read identification atomic operations, thereby avoiding read-write competition and reducing time consumption caused by synchronous blocking of the producer.
CN202210888202.9A 2022-07-27 2022-07-27 Multithreading multistage parallel communication method based on atomic message and shared cache Pending CN115269226A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210888202.9A CN115269226A (en) 2022-07-27 2022-07-27 Multithreading multistage parallel communication method based on atomic message and shared cache

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210888202.9A CN115269226A (en) 2022-07-27 2022-07-27 Multithreading multistage parallel communication method based on atomic message and shared cache

Publications (1)

Publication Number Publication Date
CN115269226A true CN115269226A (en) 2022-11-01

Family

ID=83768973

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210888202.9A Pending CN115269226A (en) 2022-07-27 2022-07-27 Multithreading multistage parallel communication method based on atomic message and shared cache

Country Status (1)

Country Link
CN (1) CN115269226A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117785767A (en) * 2024-02-27 2024-03-29 苏州仰思坪半导体有限公司 Message synchronization method, system and related device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117785767A (en) * 2024-02-27 2024-03-29 苏州仰思坪半导体有限公司 Message synchronization method, system and related device
CN117785767B (en) * 2024-02-27 2024-04-23 苏州仰思坪半导体有限公司 Message synchronization method, system and related device

Similar Documents

Publication Publication Date Title
US8458721B2 (en) System and method for implementing hierarchical queue-based locks using flat combining
US8675006B2 (en) Apparatus and method for communicating between a central processing unit and a graphics processing unit
US9619301B2 (en) Multi-core memory model and speculative mode processor management
US9098918B2 (en) Graphics processor with non-blocking concurrent architecture
US7962923B2 (en) System and method for generating a lock-free dual queue
EP0330836A2 (en) Method for multiprocessor system having self-allocating processors
US20120159495A1 (en) Non-blocking wait-free data-parallel scheduler
JP2013191244A (en) Mechanism for scheduling thread on os isolated sequencer without interposition of operating system
US8973009B2 (en) Allocation and control unit for controlling parallel execution of threads on auxiliary processing units
US20110265093A1 (en) Computer System and Program Product
US9830157B2 (en) System and method for selectively delaying execution of an operation based on a search for uncompleted predicate operations in processor-associated queues
CN110032450B (en) Large-scale deep learning method and system based on solid-state disk extended memory
CN112199173A (en) Data processing method for dual-core CPU real-time operating system
US20050066149A1 (en) Method and system for multithreaded processing using errands
CN112612523A (en) Embedded equipment driving system and method
CN115269226A (en) Multithreading multistage parallel communication method based on atomic message and shared cache
EP2282265A1 (en) A hardware task scheduler
Singh et al. A non-database operations aware priority ceiling protocol for hard real-time database systems
CN111597035A (en) Simulation engine time advancing method and system based on multiple threads
CN113094260B (en) Distributed system time sequence relation modeling and simulation analysis method
Singh Communication Coroutines For Parallel Program Using DW26010 Many Core Processor
Fukuoka et al. An efficient inter-node communication system with lightweight-thread scheduling
Deshpande et al. Analysis of the Go runtime scheduler
US5386586A (en) System and method for construction of lists of deferred service requests
CN117407182B (en) Process synchronization method, system, equipment and medium based on Poll instruction

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 210003 No. 346, Zhongshan North Road, Jiangsu, Nanjing

Applicant after: 724 Research Institute of China Shipbuilding Corp.

Address before: 210003 No. 346, Zhongshan North Road, Jiangsu, Nanjing

Applicant before: 724TH RESEARCH INSTITUTE OF CHINA SHIPBUILDING INDUSTRY Corp.

CB02 Change of applicant information