Discrete event parallel processing method, terminal device and storage medium

Through thread pool model and event queue management, the bottlenecks of parallel processing and time synchronization in parallel discrete event simulation are solved, and the computing performance of multi-core CPUs is fully utilized, and the simulation operation efficiency and the order of event processing are improved.

CN115686789BActive Publication Date: 2025-08-12XIAMEN YUANTING INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211355068.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-01
Publication Date
2025-08-12
Estimated Expiration
2042-11-01

AI Technical Summary

Technical Problem

In the existing parallel discrete event simulation system, internal serial execution is difficult to fully tap the potential of parallelism when multi-process parallel processing is processed, and the time synchronization mechanism has become a bottleneck for rapid and parallel operation of simulation, and it is difficult to ensure the order of parallel processing and execution.

Method used

Using the thread pool model, event queue management and time-driven manager are used to sort and process events according to the minimum processing timestamp of events, and multi-core CPU computing performance is used to realize parallel processing.

Benefits of technology

It improves the operation efficiency of simulation, gives full play to the computing performance of multiple CPUs, solves the bottleneck problems of parallel processing and time synchronization, and ensures the order and efficiency of event processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115686789B_ABST
    Figure CN115686789B_ABST
Patent Text Reader

Abstract

The present invention relates to a discrete event parallel processing method, terminal device, and storage medium. The method comprises: when a new event is generated during thread processing, the newly generated event is stored in the event queue corresponding to the thread in order of minimum processing time, and the minimum processing time of the event is stored in the event queue as the timestamp of the event; when all threads in the thread pool have completed execution, the event with the smallest sorted timestamp is extracted from each event queue of each thread, and the minimum value of the timestamps of all extracted events is calculated; the next frame timestamp is calculated based on the minimum timestamp and the time step; the minimum timestamp in the event queue corresponding to each thread is compared with the next frame timestamp to determine whether the thread is processing at the time corresponding to the next frame timestamp. The present invention adopts a parallel discrete event simulation method, which can fully utilize the computing performance of multiple CPUs and improve the operation efficiency of the simulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of discrete event processing, and in particular to a discrete event parallel processing method, terminal equipment and storage medium. Background Art

[0002] The existing parallel discrete event systems have the following main problems: (1) Currently, most parallel discrete event simulations can be implemented in parallel through multiple processes, but each process can only be executed serially, making it difficult to fully tap the parallel potential of the application; (2) There is a time synchronization mechanism in the parallel discrete event simulation process. How to efficiently collect, process events and control time synchronization has become one of the bottlenecks for fast and parallel simulation operation; (3) In parallel discrete events, while ensuring efficient parallel processing, the parallel processing and execution order of discrete events must also be solved. Summary of the Invention

[0003] In order to solve the above problems, the present invention proposes a discrete event parallel processing method, a terminal device and a storage medium.

[0004] The specific plan is as follows:

[0005] A discrete event parallel processing method comprises the following steps:

[0006] The discrete event time model creates a worker processor for each thread in the thread pool, and each worker processor processes events according to the timestamp of each frame;

[0007] When a new event is generated during thread processing, the newly generated event is stored in the event queue corresponding to the thread in the order of the smallest processing time, and the smallest processing time of the event is stored as the timestamp of the event in the event queue;

[0008] When all threads in the thread pool have finished executing, the event with the smallest sorting timestamp is extracted from each event queue of each thread, and the minimum value of the timestamps of all extracted events is calculated, and the calculated minimum timestamp is sent to the time-driven manager;

[0009] The time-driven manager calculates the next frame timestamp based on the received minimum timestamp and time step, and sends it to the discrete event time model;

[0010] The discrete event time model compares the minimum timestamp in the event queue corresponding to each thread with the next frame timestamp. If the minimum timestamp in the event queue corresponding to a thread is less than or equal to the next frame timestamp, the thread processes the event corresponding to the minimum timestamp in the event queue at the time corresponding to the next frame timestamp and deletes the event from the event queue; otherwise, the thread does not process the event at the time corresponding to the next frame timestamp.

[0011] Furthermore, there are three types of events: discrete events, periodic events, and disordered events.

[0012] Furthermore, the minimum processing time of disordered events is set to a minimum value.

[0013] Furthermore, a thread pool is created when the discrete event time model is first run, and the number of threads included in the thread pool is determined according to the number of CPU threads.

[0014] Furthermore, the discrete event time model also includes a thread counter for counting the number of threads that have been executed.

[0015] A discrete event parallel processing terminal device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described above are implemented.

[0016] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method described above in an embodiment of the present invention.

[0017] The present invention adopts the above technical solution and a parallel discrete event simulation method, which can give full play to the computing performance of multiple CPUs and improve the operating efficiency of the simulation. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 Shown is a flow chart of embodiment 1 of the present invention. DETAILED DESCRIPTION

[0019] To further illustrate various embodiments, the present invention provides accompanying drawings. These drawings form part of the present disclosure and are primarily used to illustrate the embodiments and, in conjunction with the relevant description in the specification, to explain the operating principles of the embodiments. By referring to these drawings, those skilled in the art will be able to understand other possible implementations and the advantages of the present invention.

[0020] The present invention will now be further described with reference to the accompanying drawings and specific embodiments.

[0021] Example 1:

[0022] The embodiment of the present invention provides a discrete event parallel processing method, such as Figure 1 As shown, the content of the method is as follows:

[0023] The discrete event time model creates a worker processor for each thread in the thread pool, and each worker processor processes events according to the timestamp of each frame.

[0024] The thread pool needs to be created when the discrete event time model is first run. The number of threads contained in the thread pool can be determined according to the number of CPU threads in the current computer.

[0025] Each thread can be used to process events generated by one or more entity models, and different threads process different entity models.

[0026] When a new event is generated during thread processing, the newly generated event is stored in the event queue corresponding to the thread in order of the minimum processing time, and the minimum processing time of the event is stored in the event queue as the timestamp of the event.

[0027] In this embodiment, events include three types: discrete events, periodic events, and unordered events. Discrete events, also known as ordered events, have requirements for their processing. For example, if a discrete event is to turn in 3 seconds, it must be executed in 3 seconds. Unordered events are events without a time limit, but these events often have a higher priority and need to be executed first. For example, if a disordered event is to brake as quickly as possible, this type of event should be prioritized over discrete events and periodic events. Periodic events are events that are executed at fixed time intervals, such as taking a photo every 2 seconds.

[0028] Because out-of-order events should be processed first, in this embodiment, the minimum processing time of out-of-order events is set to a minimum value, such as 0.

[0029] When all threads in the thread pool have completed execution, the event with the smallest sorted timestamp is extracted from each thread's event queue. The minimum timestamp of all extracted events is calculated and sent to the event-driven manager. For example, if there are 10 threads, 10 events are extracted from 10 event queues, and the minimum timestamp of these 10 events is calculated.

[0030] In order to better determine whether all threads have been executed, this embodiment also includes creating a thread counter in the discrete event time model to calculate the number of threads that have been executed. When the number is equal to the total number of threads included in the thread pool, it is determined that all threads have been executed.

[0031] The time-driven manager calculates the next frame timestamp based on the received minimum timestamp and time step and sends it to the discrete event time model.

[0032] Because the timestamp of each frame should be a multiple of the time step, the time step must also be considered when calculating the timestamp of the next frame. For example, if the time offset is 0.1 seconds and the minimum timestamp is 0.05 seconds, the calculated timestamp of the next frame should be 0.1 seconds.

[0033] The discrete event time model compares the minimum timestamp in the event queue corresponding to each thread with the next frame timestamp. If the minimum timestamp in the event queue corresponding to a thread is less than or equal to the next frame timestamp, the thread processes the event corresponding to the minimum timestamp in the event queue at the time corresponding to the next frame timestamp and deletes the event from the event queue; otherwise, the thread does not process the event at the time corresponding to the next frame timestamp.

[0034] The embodiment of the present invention adopts a parallel discrete event simulation method for the current mainstream computer configuration of multi-core CPUs, which can give full play to the computing performance of multiple CPUs and improve the running efficiency of the simulation.

[0035] Example 2:

[0036] The present invention also provides a discrete event parallel processing terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned method embodiment of the first embodiment of the present invention are implemented.

[0037] Furthermore, as an executable solution, the discrete event parallel processing terminal device can be a computing device such as a desktop computer or a laptop. The discrete event parallel processing terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the above-described discrete event parallel processing terminal device configuration is merely an example and does not limit the discrete event parallel processing terminal device. The discrete event parallel processing terminal device may include more or fewer components than those described above, or may combine certain components or different components. For example, the discrete event parallel processing terminal device may also include input / output devices, network access devices, buses, etc., but this is not limited in the present embodiment.

[0038] Furthermore, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the discrete event parallel processing terminal device, and utilizes various interfaces and lines to connect various parts of the entire discrete event parallel processing terminal device.

[0039] The memory can be used to store the computer programs and / or modules. The processor implements the various functions of the discrete event parallel processing terminal device by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created based on the use of the mobile phone, etc. In addition, the memory can include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0040] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.

[0041] If the module / unit integrated in the discrete event parallel processing terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can also implement all or part of the processes in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution medium.

[0042] Although the present invention has been particularly shown and described in conjunction with preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made to the present invention without departing from the spirit and scope of the invention as defined in the appended claims, and all such changes are within the scope of protection of the present invention.

Claims

1. A discrete event parallel processing method, characterized in that: include: The discrete event time model creates a worker processor for each thread in the thread pool, and each worker processor processes events according to the timestamp of each frame; When a new event is generated during thread processing, the newly generated event is stored in the event queue corresponding to the thread in the order of the smallest processing time, and the smallest processing time of the event is stored as the timestamp of the event in the event queue; When all threads in the thread pool have finished executing, the event with the smallest sorting timestamp is extracted from each event queue of each thread, and the minimum value of the timestamps of all extracted events is calculated, and the calculated minimum timestamp is sent to the time-driven manager; The time-driven manager calculates the next frame timestamp based on the received minimum timestamp and time step, and sends it to the discrete event time model; The discrete event time model compares the minimum timestamp in the event queue corresponding to each thread with the next frame timestamp. If the minimum timestamp in the event queue corresponding to a thread is less than or equal to the next frame timestamp, the thread processes the event corresponding to the minimum timestamp in the event queue at the time corresponding to the next frame timestamp and deletes the event from the event queue. Otherwise, the thread does not process at the time corresponding to the next frame timestamp.

2. The discrete event parallel processing method according to claim 1, wherein: There are three types of events: discrete events, periodic events, and disordered events.

3. The discrete event parallel processing method according to claim 2, wherein: Set the minimum processing time for out-of-order events to the minimum value.

4. The discrete event parallel processing method according to claim 1, wherein: The thread pool is created when the discrete event time model is first run, and the number of threads contained in the thread pool is determined by the number of CPU threads.

5. The discrete event parallel processing method according to claim 1, wherein: The discrete event time model also includes a thread counter, which is used to count the number of threads that have completed execution.

6. A discrete event parallel processing terminal device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Simulation execution method and system for event centralized emission type multi-heterogeneous event queue optimization

    CN111651864A

  • Event centralized emission type simulation execution method and system for parallel discrete events

    CN111651865A