CN111597035B - Simulation engine time propulsion method and system based on multithreading - Google Patents

Simulation engine time propulsion method and system based on multithreading Download PDF

Info

Publication number
CN111597035B
CN111597035B CN202010294261.4A CN202010294261A CN111597035B CN 111597035 B CN111597035 B CN 111597035B CN 202010294261 A CN202010294261 A CN 202010294261A CN 111597035 B CN111597035 B CN 111597035B
Authority
CN
China
Prior art keywords
model
time
event
events
service 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.)
Active
Application number
CN202010294261.4A
Other languages
Chinese (zh)
Other versions
CN111597035A (en
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.)
Beijing Simulation Center
Original Assignee
Beijing Simulation Center
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 Beijing Simulation Center filed Critical Beijing Simulation Center
Priority to CN202010294261.4A priority Critical patent/CN111597035B/en
Publication of CN111597035A publication Critical patent/CN111597035A/en
Application granted granted Critical
Publication of CN111597035B publication Critical patent/CN111597035B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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/542Event management; Broadcasting; Multicasting; Notifications
    • 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/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a simulation engine time propulsion method and a simulation engine time propulsion system based on multithreading, wherein the method comprises the following steps: creating an engine service thread and a plurality of model service threads according to the core number of the simulation host; instantiating the simulation model to obtain a plurality of model instances, and sending each model instance to one model service thread in a plurality of model service threads, wherein an event is created for the received model instance in the model service thread; all events are sequentially executed according to the creation time sequence of all events based on the communication between the multiple model service threads and the engine service threads, and the problem of low efficiency of the traditional simulation engine time propulsion method is solved by adopting a multithreading parallel simulation engine time propulsion mode.

Description

Simulation engine time propulsion method and system based on multithreading
Technical Field
The invention relates to the technical field of simulation engine time propulsion. And more particularly, to a multithreading-based simulation engine time advancing method and system.
Background
Time advance is an important function of a simulation engine in the process of simulation operation to ensure that logic of each model is correct. The traditional time pushing method is a pushing method based on an event queue, and comprises the following implementation steps: creating an event queue which is arranged according to time sequence, adding the events created based on the model component into the queue, taking out the events with the minimum time from the event queue for execution, ending the simulation when the event queue is empty, and sequentially advancing the simulation time in the execution process of the events. The traditional time pushing method adopts a centralized event queue, so that the coupling degree between models is high, the optimization aiming at the current rapid development of the CPU of the computer is not facilitated, and the simulation efficiency is difficult to improve.
Disclosure of Invention
The invention aims to provide a multithreading-based simulation engine time propulsion method, which solves the problem of low efficiency of the traditional simulation engine time propulsion method by adopting a multithreading parallel simulation engine time propulsion mode. It is another object of the present invention to provide a multithreading-based simulation engine time propulsion system.
In order to achieve the above purpose, the invention adopts the following technical scheme:
the invention discloses a simulation engine time propulsion method based on multithreading, which comprises the following steps:
creating an engine service thread and a plurality of model service threads according to the core number of the simulation host;
instantiating the simulation model to obtain a plurality of model instances, and sending each model instance to one model service thread in a plurality of model service threads, wherein an event is created for the received model instance in the model service thread;
all events are sequentially executed in the creation time sequence of all events based on communication of the plurality of model service threads with the engine service thread, respectively.
Preferably, the instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one model service thread of the plurality of model service threads specifically includes:
forming a plurality of model examples according to each simulation model;
determining a model service thread corresponding to each model instance according to the obtained calculation complexity of the plurality of model instances;
and respectively sending the plurality of model instances to corresponding model service threads.
Preferably, the communication between the service thread and the engine service thread based on the multiple models sequentially executes all events according to the creation time sequence of all events specifically includes:
establishing an event queue in each model service thread;
arranging all events in each model service thread in the event queue according to the creation time sequence of the events;
and sequentially executing the events according to the creation time sequence of the events in all event queues based on the communication between the plurality of model service threads and the engine service threads.
Preferably, the communication between the service thread and the engine service thread based on the multiple models sequentially executes the events according to the creation time sequence of the events in all the event queues specifically includes:
for each model service thread, acquiring and executing a creation time t of a creation time latest event in the model service thread, and setting the creation time t of the creation time latest event imin Set as the logic time t of the corresponding model service thread in
Creation time t of event closest to next creation time inext Setting the time to be pushed, forming a request time pushing message according to the time to be pushed and transmitting the request time pushing message to an engine service thread so that the engine service thread transmits the time to be pushed to all other model service threads;
if the logic time t of the model service thread in And if the time is less than the time to be pushed of all other model service threads, pushing time, re-acquiring the event with the latest time in the model service thread, and executing until all the events in the event queue are executed.
The invention also discloses a simulation engine time propulsion system based on multithreading, which comprises:
the multi-thread creation unit is used for creating an engine service thread and a plurality of model service threads according to the core number of the simulation host;
the model instance creation unit is used for instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one model service thread in a plurality of model service threads, and creating an event for the received model instance in the model service thread;
and the event execution unit is used for sequentially executing all the events according to the creation time sequence of all the events based on the communication between the plurality of model service threads and the engine service threads.
Preferably, the model instance creating unit is specifically configured to form a plurality of model instances according to each simulation model, and determine a model service thread corresponding to each model instance according to the computation complexity of the obtained plurality of model instances;
and respectively sending the plurality of model instances to corresponding model service threads.
Preferably, the event execution unit is specifically configured to establish an event queue in each model service thread, arrange all events in each model service thread in the event queue according to the creation time sequence of the events, and sequentially execute the events according to the creation time sequence of the events in all the event queues based on communication between the plurality of model service threads and the engine service thread.
Preferably, the event execution unit is specifically configured to, for each model service thread, acquire and execute a creation time t of a creation time-latest event in the model service thread, and execute the creation time t of the creation time-latest event imin Set as the logic time t of the corresponding model service thread in The creation time t of the event with the latest creation time will be next inext Setting the time to be pushed, forming a request time pushing message according to the time to be pushed and transmitting the request time pushing message to an engine service thread so that the engine service thread transmits the time to be pushed to all other model service threads, and if the logic time t of the model service thread is in And if the time is less than the time to be pushed of all other model service threads, pushing time, re-acquiring the event with the latest time in the model service thread, and executing until all the events in the event queue are executed.
The invention also discloses a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor,
the processor, when executing the program, implements the method as described above.
The invention also discloses a computer readable medium, on which a computer program is stored,
the program, when executed by a processor, implements the method as described above.
According to the invention, an engine service thread and a plurality of model service threads are created according to the core number of the simulation host, the core number of the host is fully considered when the number of the model service threads is defined, and the calculation performance of the host can be utilized to the maximum extent. The simulation model is instantiated and distributed to each model service thread, each model service thread creates events for the model instance, all events are sequentially executed based on communication among the model service threads, the correct execution time sequence of the events is ensured, and different model instances perform model calculation in different model service threads, so that the correct time sequence is ensured, and the simulation efficiency can be improved. The invention has the advantages that the advantage of multithreading can be fully utilized, the scalability is realized, different model examples can be distributed according to the calculation complexity, the idle time of a host core can be effectively reduced, and the utilization efficiency of the calculation capacity of the host is further improved. The model instance is pushed in the mode of event queues in the model service thread, and the threads are pushed in the mode of inter-thread communication, so that the coupling between the models is reduced, the use of thread locks and mutexes is reduced, the complexity of the system is reduced, and the expenditure required by synchronization between the threads is reduced.
Drawings
The following describes the embodiments of the present invention in further detail with reference to the drawings.
FIG. 1 illustrates one of the flowcharts of one particular embodiment of a multithreading-based simulation engine time advancement method of the present invention;
FIG. 2 illustrates a second flowchart of one embodiment of a multithreading-based simulation engine time advancement method of the present invention;
FIG. 3 illustrates a third flowchart of one embodiment of a multithreading-based simulation engine time advancement method of the present invention;
FIG. 4 illustrates a fourth flowchart of one embodiment of a multithreading-based simulation engine time advancement method of the present invention;
FIG. 5 is a schematic diagram illustrating time pushing of one embodiment of the multithreading-based simulation engine time pushing method of the present invention;
FIG. 6 is a block diagram illustrating one embodiment of a multithreading-based simulation engine time propulsion system in accordance with the present invention;
fig. 7 shows a schematic diagram of a computer device suitable for use in implementing embodiments of the invention.
Detailed Description
In order to more clearly illustrate the present invention, the present invention will be further described with reference to preferred embodiments and the accompanying drawings. Like parts in the drawings are denoted by the same reference numerals. It is to be understood by persons skilled in the art that the following detailed description is illustrative and not restrictive, and that this invention is not limited to the details given herein.
The traditional time pushing method is based on an event queue pushing method, an event queue which is arranged according to time sequence is created, events created based on a model component are added into the queue, the events with the minimum time are taken out from the event queue to be executed, the simulation is ended until the event queue is empty, and the simulation time is sequentially pushed in the execution process of the events. The traditional time pushing method adopts a centralized event queue, so that the coupling degree between models is high, the optimization aiming at the current rapid development of the CPU of the computer is not facilitated, and the simulation efficiency is difficult to improve. The invention provides a multithreading-based simulation engine time propulsion method, which solves the problem of low efficiency of the traditional simulation engine time propulsion method by adopting a multithreading parallel simulation engine time propulsion mode.
Based on the above, according to one aspect of the present invention, the present embodiment discloses a simulation engine time pushing method based on multithreading. As shown in fig. 1, in this embodiment, the method includes:
s100: and creating an engine service thread and a plurality of model service threads according to the core number of the simulation host.
S200: instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one of a plurality of model service threads, wherein an event is created for the received model instance.
S300: all events are sequentially executed in the creation time sequence of all events based on communication of the plurality of model service threads with the engine service thread, respectively.
According to the invention, an engine service thread and a plurality of model service threads are created according to the core number of the simulation host, the core number of the host is fully considered when the number of the model service threads is defined, and the calculation performance of the host can be utilized to the maximum extent. The simulation model is instantiated and distributed to each model service thread, each model service thread creates events for the model instance, all events are sequentially executed based on communication among the model service threads, the correct execution time sequence of the events is ensured, and different model instances perform model calculation in different model service threads, so that the correct time sequence is ensured, and the simulation efficiency can be improved. The invention has the advantages that the advantage of multithreading can be fully utilized, the scalability is realized, different model examples can be distributed according to the calculation complexity, the idle time of a host core can be effectively reduced, and the utilization efficiency of the calculation capacity of the host is further improved. The model instance is pushed in the mode of event queues in the model service thread, and the threads are pushed in the mode of inter-thread communication, so that the coupling between the models is reduced, the use of thread locks and mutexes is reduced, the complexity of the system is reduced, and the expenditure required by synchronization between the threads is reduced.
In a preferred embodiment, in S100, one engine service thread and a plurality of model service threads are created according to the number of cores of the emulated host, and when the number of cores of the emulated host is n, one engine service thread and at most n-1 model service threads may be created. In practical application, no more than n-1 model service threads can be set, wherein preferably, n-1 model service threads can be set, so that simulation resources of n cores of a host are fully utilized, and simulation efficiency is improved.
In a preferred embodiment, as shown in fig. 2, the step S200 of instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one of a plurality of model service threads specifically includes:
s210: a plurality of model instances are formed separately from each simulation model.
S220: and determining a model service thread corresponding to each model instance according to the obtained calculation complexity of the plurality of model instances.
S230: and respectively sending the plurality of model instances to corresponding model service threads.
It will be appreciated that for a simulation model, multiple model instances may be formed. Because the invention adopts a plurality of threads to carry out simulation calculation, the model examples in the threads need to sequentially execute the simulation calculation according to the time sequence. The calculation complexity of different model examples is different, in order to prevent one of the threads from being in an idle state when performing simulation calculation of the model examples, and thus resource waste is caused. In this preferred embodiment, the simulation computation time required for each model instance may be predicted from the computational complexity of each model instance. And distributing all the model instances to different model service threads according to the simulation calculation time of each model instance so as to reduce the idle time of the model service threads and improve the completion efficiency of the simulation task.
In a specific example, for a model instance with high computational complexity, but the computational complexity of a plurality of model instances executed after the model instance is low, when a model service thread executes the model instance with high computational complexity, the plurality of model instances with low computational complexity can be executed in other model service threads without being sequentially distributed to all model service threads strictly according to the execution sequence of a plurality of models, and the model service thread corresponding to each model instance can be determined according to the distribution principle. Here, only one specific example of determining the model service thread corresponding to each model instance according to the obtained computational complexity of multiple model instances is shown, and in other embodiments, the model instances may be distributed in other manners, which is not limited thereto.
In a preferred embodiment, as shown in fig. 3, the step S300 may specifically include:
s310: an event queue is established in each model service thread.
S320: and arranging all the events in each model service thread in the event queue according to the creation time sequence of the events.
S330: and sequentially executing the events according to the creation time sequence of the events in all event queues based on the communication between the plurality of model service threads and the engine service threads.
It will be appreciated that in order to ensure that the timing of execution of the model instances is normal, in the preferred embodiment, by forming an event and an event queue according to each model instance, sequentially arranging the events into the event queue according to the creation time sequence, sequentially taking out the events from the event queue and executing the events, the accuracy of the sequence of execution of the events in each model service thread can be ensured. The creation time of the creation event according to the model instance can be created periodically or at any time, i.e. the creation time sequence of the event can be preset according to actual needs. Wherein each event has an attribute marking the event it created, and the model service thread orders the event queue according to the attribute of the event.
In a preferred embodiment, as shown in fig. 4, the step S330 may specifically include:
s331: for each model service thread, acquiring and executing a creation time t of a creation time latest event in the model service thread, and setting the creation time t of the creation time latest event imin Set as the logic time t of the corresponding model service thread in
S332: creation time t of event closest to next creation time inext Setting the time to be pushed, forming a request time pushing message according to the time to be pushed and transmitting the request time pushing message to an engine service thread so that the engine service thread transmits the time to be pushed to all other model service threads;
s333: if the logic time t of the model service thread in And if the time is less than the time to be pushed of all other model service threads, pushing time, re-acquiring the event with the latest time in the model service thread, and executing until all the events in the event queue are executed.
It will be appreciated that in the preferred embodiment, each model service thread may be in communication with an engine service thread through which communication between a plurality of model service threads is effected. The accuracy of time propulsion in the plurality of model service threads is realized through time information communication and time logic judgment among the plurality of model service threads, and all events are ensured to be executed according to the order of creation time.
The invention is further illustrated by the following specific example. Specifically, as shown in fig. 5, in this specific example, the time advance method based on the multithreading may be implemented by the following steps:
s1001: an engine service thread, named ServiceThread, is created that is used to coordinate the time of the entire simulation.
S1002: and (3) creating model service threads, wherein the core number of the simulation host is NProcs, and then creating NProcs-1 model service threads which are respectively named as WokerThead [0] … WokerThead [ NProcs-2].
S1003: instantiating the model to obtain model instances, named ModelA, modelB …, and so on, model instances named ModelA#1, modelA#2 …, and so on. Where Modela#1 and Modela#2 are two model instances obtained from Modela instantiation.
S1004: the model instances are assigned to the engine service threads, which in turn assign the model instances to the model service threads.
S1005: the model service thread builds an event queue, the event queue is ordered from small to large according to the occurrence time of the event, and the non-decreasing ordering of the event queue time is kept when the later generated event is inserted into the queue. Initially, events are created within the event queue for model instances assigned to all engine service threads.
S1006: the model service thread executes the event queue. Each model service thread has own logic time, and the ith model service thread WorkerThread [ i ]]Is defined as t in I=0, 1,2,3 … NProcs-2. Defining the time of the latest event in an event queue in a model service thread as t imin When the model service thread executes the event queue, taking out all the time equal to t from the event queue imin Is executed, updating the logic time t in At t imin
S1007: model service thread update time. Defining a model service thread WorkerThread [ i ]]The next time in the event queue is greater than t imin Time of event t inext The model service thread sends a request time advance message to the engine service thread requesting to advance the local time to t inext The engine service thread forwards the message to all other model service threads.
S1008: model service thread advance time. The j model service thread WorkerThread [ j ]]After the request time pushing message is sent, checking a receiving message queue, calculating and updating the minimum value of the other model service thread time when the request time pushing message of the other model service thread forwarded by the engine service thread is received, and defining the minimum value Tj=min { t of the other model service thread time knext ,k≠j},j=0,1,2,3…NProcs-2,t knext Logical time of servicing the thread for the kth model, k=0, 1,2,3 … NProcs-2, k+.j. When Tj is greater than the local logic time t of the jth model service thread jn When so, time may be advanced and execution continues at S1006 until the event queue is empty.
Based on the same principle, the embodiment also discloses a simulation engine time propulsion system based on multithreading. As shown in fig. 6, in the present embodiment, the system includes a multithread creating unit 11, a model instance creating unit 12, and an event executing unit 13.
Wherein the multithread creating unit 11 is configured to create an engine service thread and a plurality of model service threads according to the number of cores of the emulation host.
The model instance creation unit 12 is configured to instantiate a simulation model to obtain a plurality of model instances and send each model instance to one of a plurality of model service threads in which an event is created for the received model instance.
The event execution unit 13 is configured to sequentially execute all events in the creation time sequence of all events based on communication of the plurality of model service threads with the engine service thread, respectively.
In a preferred embodiment, the model instance creation unit 12 is specifically configured to form a plurality of model instances according to each simulation model, determine a model service thread corresponding to each model instance according to the computation complexity of the obtained plurality of model instances, and send the plurality of model instances to the corresponding model service threads respectively.
In a preferred embodiment, the event execution unit 13 is specifically configured to establish an event queue in each model service thread, arrange all events in each model service thread in the event queue according to the creation time sequence of the events, and sequentially execute the events according to the creation time sequence of the events in all the event queues based on communication between the plurality of model service threads and the engine service thread, respectively.
In a preferred embodiment, the event execution unit 13 is specifically configured to, for each model service thread, obtain and execute, in the model service thread, a creation time-latest event, and create the creation time-latest eventInterval t imin Set as the logic time t of the corresponding model service thread in The creation time t of the event with the latest creation time will be next inext Setting the time to be pushed, forming a request time pushing message according to the time to be pushed and transmitting the request time pushing message to an engine service thread so that the engine service thread transmits the time to be pushed to all other model service threads, and if the logic time t of the model service thread is in And if the time is less than the time to be pushed of all other model service threads, pushing time, re-acquiring the event with the latest time in the model service thread, and executing until all the events in the event queue are executed.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer device, which may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
In a typical example the computer apparatus comprises in particular a memory, a processor and a computer program stored on the memory and executable on the processor, said processor implementing the method as described above when said program is executed.
Referring now to FIG. 7, a schematic diagram of a computer device 600 suitable for use in implementing embodiments of the present application is shown.
As shown in fig. 7, the computer apparatus 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate works and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM)) 603. In the RAM603, various programs and data required for the operation of the system 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a liquid crystal feedback device (LCD), and the like, and a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on drive 610 as needed, so that a computer program read therefrom is mounted as needed as storage section 608.
In particular, according to embodiments of the present invention, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present application.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (8)

1. A multithreading-based simulation engine time advancing method, comprising:
creating an engine service thread and a plurality of model service threads according to the core number of the simulation host;
instantiating the simulation model to obtain a plurality of model instances, and sending each model instance to one model service thread in a plurality of model service threads, wherein an event is created for the received model instance in the model service thread;
sequentially executing all events according to the creation time sequence of all events based on the communication between the plurality of model service threads and the engine service thread;
the instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one model service thread of a plurality of model service threads specifically comprises:
forming a plurality of model examples according to each simulation model;
determining a model service thread corresponding to each model instance according to the obtained calculation complexity of the plurality of model instances;
and respectively sending the plurality of model instances to corresponding model service threads.
2. The simulation engine time advancing method according to claim 1, wherein the communication between the plurality of model service threads and the engine service thread respectively sequentially executes all events in the creation time sequence of all events comprises:
establishing an event queue in each model service thread;
arranging all events in each model service thread in the event queue according to the creation time sequence of the events;
and sequentially executing the events according to the creation time sequence of the events in all event queues based on the communication between the plurality of model service threads and the engine service threads.
3. The simulation engine time advancing method according to claim 2, wherein the communication between the service threads and the engine service threads based on the plurality of models sequentially executes the events according to the creation time sequence of the events in all the event queues, specifically comprises:
aiming at each model service thread, acquiring and executing an event with the latest time in the model service thread, and setting the creation time of the event with the latest creation time as the logic time tin of the corresponding model service thread;
setting the creation time tinext of the event with the latest creation time as the time to be pushed, forming a request time pushing message according to the time to be pushed and transmitting the request time pushing message to an engine service thread so that the engine service thread can transmit the time to be pushed to all other model service threads;
if the logic time tin of the model service thread is smaller than the time to be pushed of all other model service threads, pushing time is carried out, the event with the latest time in the model service thread is newly acquired, and the event is executed until all the events in the event queue are executed.
4. A multithreading-based simulation engine time propulsion system, comprising:
the multi-thread creation unit is used for creating an engine service thread and a plurality of model service threads according to the core number of the simulation host;
the model instance creation unit is used for instantiating the simulation model to obtain a plurality of model instances and sending each model instance to one model service thread in a plurality of model service threads, and creating an event for the received model instance in the model service thread;
the event execution unit is used for sequentially executing all events according to the creation time sequence of all events based on the communication between the plurality of model service threads and the engine service thread;
the model instance creation unit is specifically configured to form a plurality of model instances according to each simulation model, and determine a model service thread corresponding to each model instance according to the computation complexity of the obtained plurality of model instances;
and respectively sending the plurality of model instances to corresponding model service threads.
5. The simulation engine time propulsion system of claim 4, wherein the event execution unit is specifically configured to establish an event queue in each model service thread, arrange all events in each model service thread in the event queue according to a creation time sequence of the events, and sequentially execute the events according to the creation time sequence of the events in all the event queues based on communication between the plurality of model service threads and the engine service threads, respectively.
6. The simulation engine time propulsion system according to claim 5, wherein the event execution unit is specifically configured to, for each model service thread, obtain a creation time tin of the creation time latest event as a logic time tin of the corresponding model service thread, set a creation time tinext of a next creation time latest event as a time to be propelled, form a request time propulsion message according to the time to be propelled and transmit the request time propulsion message to an engine service thread so that the engine service thread transmits the time to be propelled to all other model service threads, and if the logic time tin of the model service thread is smaller than the time to be propelled of all other model service threads, the propulsion time is obtained again, and the creation time latest event in the model service thread is obtained again and executed until all events in an event queue are executed.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that,
the processor implementing the method according to any of claims 1-3 when executing the program.
8. A computer readable medium having a computer program stored thereon, characterized in that,
the program, when executed by a processor, implements a method as claimed in any one of claims 1-3.
CN202010294261.4A 2020-04-15 2020-04-15 Simulation engine time propulsion method and system based on multithreading Active CN111597035B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010294261.4A CN111597035B (en) 2020-04-15 2020-04-15 Simulation engine time propulsion method and system based on multithreading

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010294261.4A CN111597035B (en) 2020-04-15 2020-04-15 Simulation engine time propulsion method and system based on multithreading

Publications (2)

Publication Number Publication Date
CN111597035A CN111597035A (en) 2020-08-28
CN111597035B true CN111597035B (en) 2024-03-19

Family

ID=72187559

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010294261.4A Active CN111597035B (en) 2020-04-15 2020-04-15 Simulation engine time propulsion method and system based on multithreading

Country Status (1)

Country Link
CN (1) CN111597035B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112256243B (en) * 2020-11-05 2024-04-02 苏州同元软控信息技术有限公司 Behavior customization method, apparatus, device and storage medium
CN113691615A (en) * 2021-08-23 2021-11-23 广联达科技股份有限公司 Service request processing method, system and data gateway
CN114757057B (en) * 2022-06-14 2022-08-23 中国人民解放军国防科技大学 Multithreading parallel combat simulation method and system based on hybrid propulsion

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760176A (en) * 2011-04-29 2012-10-31 无锡江南计算技术研究所 Hardware transaction level simulation method, engine and system
CN104866374A (en) * 2015-05-22 2015-08-26 北京华如科技股份有限公司 Multi-task-based discrete event parallel simulation and time synchronization method
CN104915482A (en) * 2015-05-27 2015-09-16 中国科学院遥感与数字地球研究所 Satellite data receiving simulation analysis platform
CN107193639A (en) * 2017-06-05 2017-09-22 北京航空航天大学 A kind of multi-core parallel concurrent simulation engine system for supporting combined operation

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20160046223A (en) * 2014-10-20 2016-04-28 한국전자통신연구원 Apparatus and Method for performing multi-core emulation based on multi-threading

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760176A (en) * 2011-04-29 2012-10-31 无锡江南计算技术研究所 Hardware transaction level simulation method, engine and system
CN104866374A (en) * 2015-05-22 2015-08-26 北京华如科技股份有限公司 Multi-task-based discrete event parallel simulation and time synchronization method
CN104915482A (en) * 2015-05-27 2015-09-16 中国科学院遥感与数字地球研究所 Satellite data receiving simulation analysis platform
CN107193639A (en) * 2017-06-05 2017-09-22 北京航空航天大学 A kind of multi-core parallel concurrent simulation engine system for supporting combined operation

Also Published As

Publication number Publication date
CN111597035A (en) 2020-08-28

Similar Documents

Publication Publication Date Title
CN111597035B (en) Simulation engine time propulsion method and system based on multithreading
US11762697B2 (en) Method and apparatus for scheduling resource for deep learning framework
CN110262901B (en) Data processing method and data processing system
CN114020470B (en) Resource allocation method and device, readable medium and electronic equipment
CN107704310B (en) Method, device and equipment for realizing container cluster management
CN112905339B (en) Task scheduling execution method, device and system
CN114429195B (en) Performance optimization method and device for training mixed expert model
CN113127564B (en) Parameter synchronization method and device
CN110673959A (en) System, method and apparatus for processing tasks
CN115297008A (en) Intelligent computing network-based collaborative training method and device, terminal and storage medium
CN108228323B (en) Hadoop task scheduling method and device based on data locality
CN113791876A (en) System, method and apparatus for processing tasks
CN116821187A (en) Database-based data processing method and device, medium and electronic equipment
CN112486825A (en) Multi-lane environment architecture system, message consumption method, device, equipment and medium
CN112463340A (en) Tensorflow-based multi-task flexible scheduling method and system
CN111694670A (en) Resource allocation method, device, equipment and computer readable medium
CN116737370A (en) Multi-resource scheduling method, system, storage medium and terminal
CN115361382B (en) Data processing method, device, equipment and storage medium based on data group
US10635336B1 (en) Cache-based partition allocation
CN115495256A (en) Service calling method and device, electronic equipment and storage medium
CN111694672B (en) Resource allocation method, task submission method, device, electronic equipment and medium
CN113821313A (en) Task scheduling method and device and electronic equipment
CN117940934A (en) Data processing apparatus and method
CN111245909A (en) Distributed dynamic scheduling method and device, electronic equipment and storage medium
CN114866612B (en) Electric power micro-service unloading method and device

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
GR01 Patent grant
GR01 Patent grant