Simulation calculation method and device of simulation system, equipment, product and medium
By allocating parallel computing tasks to target simulation threads in the SystemC simulation system and using operating system threads to execute tasks, the physical parallelization of the simulation system is achieved by using target blocking method, which solves the problem of low operating performance of the SystemC simulation system, improves simulation efficiency and is suitable for models with loose clocks.
Patent Information
- Application Number
- CN202510534771.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-27
AI Technical Summary
The SystemC simulation system does not support true parallel simulation, resulting in low operating performance limits, especially when there are many simulation threads or large computing volume, the performance overhead is large and affecting the user experience.
By assigning parallel computing tasks to the target simulation thread, and using the operating system thread corresponding to the target simulation thread to perform tasks, the target blocking method blocks the operation of the simulation thread, realizing physical parallelization of the simulation system.
It improves the operating efficiency of the simulation system, reduces performance overhead, is suitable for simulation models with loose clocks, and does not require modification of the SystemC kernel or substantially modifying the simulation system framework.
Smart Images

Figure CN120066685A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of simulation, and particularly to a simulation calculation method, device, equipment, product and medium of a simulation system. Background Art
[0002] SystemC is a hardware description language based on C++ (a high-level computer programming language). SystemC is widely used in simulations at various levels and scenarios. For a simulation system developed by SystemC, due to the limitations of the SystemC simulation framework, it does not support true parallel simulation, but simulates concurrency through multiple simulation threads. That is to say, these simulation threads are actually sequentially executed in a single operating system thread, which also makes the upper limit of the running performance of the simulation system not high; when there are more simulation threads or the computational workload of a single simulation content is large, the huge performance overhead will reduce the efficiency of the entire simulation system, seriously affecting the user experience.
[0003] In related technologies, in order to solve the problem of low running efficiency of the SystemC simulation system, physical parallelization of the simulation system is often achieved by modifying the SystemC kernel and modifying the compiler. However, both methods will make different degrees of changes to the existing SystemC standard, are difficult to be compatible with other standard interfaces, and require reconstruction of the simulation architecture and interfaces, are difficult to be quickly applied to the simulation model, and are not applicable to simulation models with loose clocks. Therefore, how to provide a physical parallelization simulation solution that conforms to the SystemC standard, improves the running efficiency and development speed of the simulation system, and ensures the applicability to simulation models with loose clocks is an urgent problem to be solved today. Summary of the Invention
[0004] The purpose of the present invention is to provide a simulation calculation method, device, equipment, computer program product and computer-readable storage medium of a simulation system to implement a physical parallelization simulation solution that conforms to the SystemC standard, has less modification to the simulation model, and is applicable to simulation models with loose clocks, and improves the running efficiency of the simulation system.
[0005] To solve the above technical problems, the present invention provides a simulation calculation method of a simulation system, including:
[0006] Allocating the current parallel computing task to a target simulation thread; wherein, the target simulation thread is a parallel simulation thread other than the conventional simulation threads in the simulation system, and both the conventional simulation threads and the parallel simulation threads are threads of a hardware description language based on C++.
[0007] Execute the current parallel computing task using the operating system thread corresponding to the target simulation thread, and block the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task; wherein, the target blocking manner is a blocking manner that does not block the simulation time of the simulation system;
[0008] If the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task, block the operation of the target simulation thread in a non-target blocking manner;
[0009] If the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, use other simulation threads to process the corresponding simulation computing tasks.
[0010] On the other hand, the target blocking manner includes a wait function.
[0011] On the other hand, before executing the current parallel computing task using the operating system thread corresponding to the target simulation thread, it further includes: creating the operating system thread using the target simulation thread.
[0012] On the other hand, the method further includes: destroying the operating system thread using the target simulation thread after the operating system thread has completed the current parallel computing task.
[0013] On the other hand, after executing the current parallel computing task using the operating system thread corresponding to the target simulation thread and blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task, it further includes: adjusting the preset simulation time according to the execution situation of the current parallel computing task and / or the target simulation task; wherein, the current parallel computing task is one of the computing tasks in the target simulation task.
[0014] On the other hand, the method further includes: determining the parallel computing tasks in the target simulation task according to the performance consumption information of each computing task in the target simulation task; wherein, the current parallel computing task is any one of the parallel computing tasks, and the performance consumption information includes data volume information.
[0015] On the other hand, using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task includes: if the operating system thread needs to perform a call subtask for calling the internal interface of the simulation system during the execution of the current parallel computing task, then using the operating system thread, sending the call subtask to the target simulation thread, and controlling to pause the blocking of the target simulation thread; using the target simulation thread to process the call subtask, and after the call subtask is completed, resuming the blocking of the target simulation thread.
[0016] On the other hand, using the operating system thread to send the call subtask to the target simulation thread and controlling to pause the blocking of the target simulation thread includes:
[0017] Using the operating system thread, when a mutex lock is acquired, sending the call subtask to the target simulation thread; releasing the mutex lock, and controlling to pause the blocking of the target simulation thread;
[0018] Using the target simulation thread to process the call subtask, and after the call subtask is completed, resuming the blocking of the target simulation thread includes: using the target simulation thread, when a mutex lock is acquired, processing the call subtask; after the call subtask is completed, releasing the mutex lock, and resuming the blocking of the target simulation thread.
[0019] On the other hand, controlling to pause the blocking of the target simulation thread includes: using the operating system thread to send an update request to the simulation system scheduler; using the simulation system scheduler to update the shared synchronization flag to a true flag according to the update request; wherein, the target simulation thread pauses the blocking of the target blocking mode when the shared synchronization flag is a true flag.
[0020] On the other hand, after the call subtask is completed, releasing the mutex lock and resuming the blocking of the target simulation thread includes: after the call subtask is completed, updating the shared call result flag to a true flag, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared call result flag; releasing the mutex lock, and blocking the operation of the target simulation thread in a target blocking mode according to the current waiting blocking duration of the target simulation thread; wherein, the current waiting blocking duration is the difference between the previous waiting blocking duration and the current blocking duration, and the initial value of the previous waiting blocking duration is the preset simulation time.
[0021] On the other hand, sending the call subtask to the target simulation thread includes: sending the call subtask to a shared buffer queue, so that the target simulation thread reads the call subtask from the shared buffer queue.
[0022] On the other hand, when using the target simulation thread and obtaining the mutex lock, processing the call sub-task includes: using the target simulation thread, when obtaining the mutex lock, determining whether the shared buffer queue is empty; if it is not empty, processing the call sub-task; if it is empty, releasing the mutex lock and resuming the blocking of the target simulation thread.
[0023] On the other hand, when using the operating system thread and obtaining the mutex lock, before sending the call sub-task to the target simulation thread, it further includes: using the target simulation thread to obtain the mutex lock after creating the operating system thread, and blocking the operation of the target simulation thread in a non-target blocking manner; if the target simulation thread obtains the mutex lock, using the target simulation thread to determine whether the shared buffer queue is empty; wherein, the shared buffer queue is used to store the call sub-task;
[0024] If it is empty, execute the step of blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task;
[0025] If it is not empty, use the target simulation thread to process the call sub-task; after the call sub-task is completed, execute the step of blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task, and update the shared call result flag to a true flag, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared call result flag.
[0026] On the other hand, when using the operating system thread and obtaining the mutex lock, sending the call sub-task to the target simulation thread includes: using the newly created operating system thread to execute the current parallel computing task; if there is a call sub-task, obtaining the mutex lock and blocking the execution of the current parallel computing task to wait for the shared call result flag to be updated to a true flag; if the operating system thread obtains the mutex lock, adding the call sub-task to the shared buffer queue.
[0027] On the other hand, after blocking the operation of the target simulation thread in accordance with the preset simulation time of the current parallel computing task by using the target blocking method, the following steps are further included: using the target simulation thread to determine whether a shared flag bit is a true flag after the blocking duration reaches the preset simulation time; if the shared flag bit is a true flag, execute the step of using other simulation threads to process the corresponding simulation computing tasks; if the shared flag bit is a false flag, execute the step of blocking the operation of the target simulation thread by using a non-target blocking method.
[0028] On the other hand, after using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, the following steps are further included: using the operating system thread to apply for a mutex lock after completing the current parallel computing task; if the mutex lock is successfully applied, update the shared flag bit to a true flag and release the mutex lock.
[0029] The present invention also provides a simulation computing device for a simulation system, including:
[0030] An allocation module, configured to allocate a current parallel computing task to a target simulation thread; wherein the target simulation thread is a parallel simulation thread other than the regular simulation threads in the simulation system, and both the regular simulation threads and the parallel simulation threads are threads based on a C++ hardware description language;
[0031] A parallel module, configured to use the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and block the operation of the target simulation thread in accordance with the preset simulation time of the current parallel computing task by using a target blocking method; wherein the target blocking method is a blocking method that does not block the simulation time of the simulation system;
[0032] A waiting module, configured to block the operation of the target simulation thread by using a non-target blocking method if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task;
[0033] A completion module, configured to use other simulation threads to process the corresponding simulation computing tasks if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task.
[0034] The present invention also provides a computer program product, including a computer program / instructions, which when executed by a processor, implement the steps of the simulation computing method of the simulation system as described above.
[0035] The present invention also provides a simulation computing device for a simulation system, including: a memory for storing a computer program; a processor for implementing the steps of the simulation computing method of the simulation system as described above when executing the computer program.
[0036] In addition, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the simulation computing method of the simulation system as described above are implemented.
[0037] A simulation computing method for a simulation system provided by the present invention includes: allocating a current parallel computing task to a target simulation thread; wherein the target simulation thread is a parallel simulation thread other than the regular simulation threads in the simulation system, and both the regular simulation threads and the parallel simulation threads are threads based on a C++ hardware description language; using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task; wherein the target blocking manner is a blocking manner that does not block the simulation time of the simulation system; if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task, then blocking the operation of the target simulation thread in a non-target blocking manner; if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, then using other simulation threads to process the corresponding simulation computing tasks.
[0038] It can be seen that the present invention uses the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and blocks the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task, and can make the operation of other simulation threads parallel to the execution of the current parallel computing task by the operating system thread during the process of blocking the target simulation thread in the target blocking manner, so that it is possible to parallelize the construction of some key areas with high performance consumption without modifying the SystemC kernel or significantly modifying the simulation system framework, and can improve the running efficiency of the entire simulation system while retaining the SystemC standard. Moreover, the present invention couples the clock of the operating system thread with the simulation clock of the SystemC simulation thread to a certain extent, which is not only applicable to simulation models with accurate clocks, but also applicable to simulation models with loose clocks that cannot be well applied in the related art, and has better application universality. In addition, the present invention also provides a simulation computing device, equipment, computer program product and computer-readable storage medium for the simulation system, which also have the above beneficial effects. Description of the Drawings
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on the provided accompanying drawings.
[0040] Figure 1 Flowchart of a simulation calculation method for a simulation system provided by an embodiment of the present invention;
[0041] Figure 2 Schematic diagram of the architecture of a parallel simulation system provided by an embodiment of the present invention;
[0042] Figure 3 Simulation calculation timing diagram of a scenario where an operating system thread first obtains a mutex provided by an embodiment of the present invention;
[0043] Figure 4 Simulation calculation timing diagram of a scenario where a target simulation thread first obtains a mutex provided by an embodiment of the present invention;
[0044] Figure 5 Flowchart of another simulation calculation method for a simulation system provided by an embodiment of the present invention;
[0045] Figure 6 Flowchart of the call process of an internal interface of a simulation system provided by an embodiment of the present invention;
[0046] Figure 7 Block diagram of the structure of a simulation calculation device of a simulation system provided by an embodiment of the present invention;
[0047] Figure 8 Schematic diagram of the structure of a simulation calculation device of a simulation system provided by an embodiment of the present invention. Detailed implementation manners
[0048] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some but not all of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
[0049] Please refer to Figure 1 , Figure 1 which is a flowchart of a simulation calculation method for a simulation system provided by an embodiment of the present invention. The method may include:
[0050] Step 101: Allocate the current parallel computing task to the target simulation thread.
[0051] Among them, the target simulation thread is a parallel simulation thread outside the regular simulation threads in the simulation system. Both the regular simulation threads and the parallel simulation threads are threads based on the C++ hardware description language.
[0052] It can be understood that the simulation system in this embodiment can be a simulation system developed by SystemC (i.e., the SystemC simulation program). The regular simulation threads in this embodiment can be the simulation threads (i.e., SystemC threads) that execute computing tasks in the simulation system, such as Figure 2 the simulation threads 1-m in, that is, the conventional SystemC threads in the related art that perform simulation calculations on the computing content during the simulation process; the parallel simulation threads in this embodiment can be the simulation threads that use the corresponding operating system threads to execute computing tasks (i.e., parallel computing tasks) (such as Figure 2 the simulation thread n in), as Figure 2 shown, the simulation system simulation program (i.e., the SystemC simulation program) can form a larger parallel simulation system with the operating system threads that execute parallel computing tasks to achieve parallel processing of each computing task.
[0053] Correspondingly, the current parallel computing task in this embodiment can be a computing task that needs to be executed by the operating system thread in the simulation task (i.e., the target simulation task) to be processed by the simulation system, such as Figure 2 the computing task of the key calculation content (Key_Calculation) with relatively high performance consumption (such as a relatively large amount of data to be calculated) in. For the specific division and acquisition method of the parallel computing task in this embodiment, it can be set by the designer according to the practical scenario and user requirements. For example, the processor can determine the parallel computing task in the target simulation task according to the performance consumption information of each computing task in the target simulation task; among them, the current parallel computing task is any parallel computing task, and the performance consumption information includes data volume information; for example, the computing task with the data volume information greater than the data volume threshold in the target simulation task can be determined as the parallel computing task. The processor can also determine the computing task with the performance consumption flag bit being the high-consumption identifier as the parallel computing task according to the performance consumption flag bits of each computing task in the target simulation task.
[0054] Correspondingly, for the specific method of allocating the current parallel computing task to the target simulation thread in this embodiment, it can be set by the designer himself. For example, it can be implemented in the same or similar way as the method of serially scheduling simulation threads by the simulation system scheduler (i.e., the SystemC scheduler) in the related art, such as Figure 2As shown, in this step, the simulation system scheduler can be used to allocate the current parallel computing task to the target simulation thread. This embodiment does not impose any restrictions on this.
[0055] Step 102: Use the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and block the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task; wherein, the target blocking manner is a blocking manner that does not block the simulation time of the simulation system.
[0056] It can be understood that the operating system thread in this embodiment can be used to execute the current parallel computing task allocated to the target simulation thread; this embodiment does not limit the specific number of operating system threads for executing the current parallel computing task. For example, the number of operating system threads can be 1; correspondingly, this embodiment does not limit the number of operating system threads that execute their respective parallel computing tasks in parallel, that is, the number of operating system threads parallel to the SystemC simulation program. For example, the number of operating system threads parallel to the SystemC simulation program can be 1 or a value greater than 1, that is, there can be multiple operating system threads that respectively execute their respective parallel computing tasks to further improve the operation efficiency of the entire simulation system.
[0057] Correspondingly, the preset simulation time in this embodiment can be the estimated execution time of the current parallel computing task set in advance, that is, the time that the target simulation thread needs to be blocked in a target blocking manner. Among them, the target blocking manner in this embodiment can be a blocking manner that allows the simulation time (SystemC simulation time) of the simulation system to continue to advance. That is, during the process of blocking the operation of the target simulation thread in a target blocking manner, other simulation threads in the simulation system can continue to perform simulation calculations, so that the execution of the current parallel computing task by the operating system thread can be parallel to the calculations of other simulation threads.
[0058] Correspondingly, this embodiment does not limit the specific selection of the target blocking manner. For example, the target blocking manner can be the wait() function to use the wait() in SystemC to block the operation of the target simulation thread; it can also be other blocking manners that can allow the simulation time of the simulation system to continue to advance during the process of blocking the target simulation thread.
[0059] Among them, for the specific value setting of the preset simulation time in this embodiment, it can be set by the designer or user according to the practical scenario and user requirements. For example, the preset simulation time can be a time value set in advance or configured by the user, or it can be a time value determined by the processor according to the calculation content information (such as the data volume) of the current parallel computing task to achieve automatic evaluation and configuration of the preset simulation time. This embodiment does not impose any restrictions on this.
[0060] It should be noted that for the specific manner of executing the current parallel computing task by using the operating system thread corresponding to the target simulation thread in this step, it can be set by the designer himself. For example, the current parallel computing task can be executed by using a newly created operating system thread, that is, the target simulation thread can create a new operating system thread after being assigned the current parallel computing task for executing the current parallel computing task. That is to say, before executing the current parallel computing task by using the operating system thread corresponding to the target simulation thread in this embodiment, it may further include: creating an operating system thread by using the target simulation thread. Correspondingly, after the operating system thread has completed the current parallel computing task, the operating system thread can be destroyed by using the target simulation thread.
[0061] In some other embodiments, the processor can also execute the current parallel computing task by using the created operating system thread, that is, one or more operating system threads can be preset for executing the corresponding parallel computing tasks, reducing the creation and destruction processes of the operating system threads.
[0062] Correspondingly, for the specific process of blocking the operation of the target simulation thread in this step according to the preset simulation time of the current parallel computing task by using the target blocking method, it can be set by the designer according to the practical scenario and user requirements. For example, wait() in SystemC can be used to block the operation of the target simulation thread, and the blocking duration is the preset simulation time (Time_During).
[0063] Among them, the time unit of the preset simulation time (Time_During) is the simulation time unit (sc_time) in SystemC, such as the commonly used SC_NS (nanosecond), SC_US (microsecond), and SC_SEC (second), etc., which is not the real physical time unit. Therefore, when blocking the target simulation thread for a duration of Time_During, the concept of duration is introduced, and the target blocking method used (such as wait()) ensures the coupling of the external physical clock of the operating system thread and the internal simulation clock of SystemC to a certain extent, enabling the SystemC thread and each parallel external thread (operating system thread) to perform state communication and control inside and outside the simulation system under the synchronous clock scheduling, making the method provided in this embodiment applicable not only to the simulation model with accurate clock but also to the simulation model with loose clock that cannot be well applied in the related technology, such as the TLM (Transaction Level Modeling) model, having better application universality.
[0064] Step 103: If the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task, then block the operation of the target simulation thread in a non-target blocking manner.
[0065] It can be understood that the non-target blocking manner in this embodiment can be a blocking manner that blocks the simulation time of the simulation system. That is, during the process of blocking the target simulation thread in a non-target blocking manner, other simulation threads in the simulation system will also be blocked, so that the simulation time of the simulation system will not advance and change.
[0066] That is to say, in this embodiment, when the blocking duration of the target simulation thread reaches the preset simulation time, the target simulation thread can be used to detect whether the operating system thread has completed the current parallel computing task; if the operating system thread has not completed the current parallel computing task, the operation of the target simulation thread can continue to be blocked (the blocking manner used here should exclude all blocking manners that cause the simulation time to continue to advance, including wait()), so as to wait for the operating system thread to complete the current parallel computing task and then enter Step 104; if the operating system thread has completed the current parallel computing task, Step 104 can be entered to continue to process the simulation computing tasks of other subsequent simulation threads, such as a regular simulation thread executing a computing task or a parallel simulation thread using the corresponding operating system thread to execute a parallel computing task.
[0067] Correspondingly, for the specific manner of using the target simulation thread to detect whether the operating system thread has completed the current parallel computing task, it can be set by the designer. For example, the target simulation thread and the operating system thread can jointly maintain a shared flag (Done_Flag); after the operating system thread has completed the current parallel computing task, the shared flag can be updated from the default false flag (False) to the true flag (True); using the target simulation thread, after the blocking duration reaches the preset simulation time, it can be determined whether the shared flag is the true flag; if the shared flag is the false flag, it is determined that the operating system thread has not completed the current parallel computing task, and Step 103 can be entered; if the shared flag is the true flag, it is determined that the operating system thread has completed the current parallel computing task, and Step 104 can be entered.
[0068] For example, in some embodiments, after using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, the operating system thread can be used to apply for a mutex lock (such as applying for a mutex lock from the operating system) after completing the current parallel computing task; if the mutex lock is obtained, the shared flag is updated to the true flag and the mutex lock is released. That is to say, the thread safety can be guaranteed in this embodiment by setting the mutex lock.
[0069] Step 104: If the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, use other simulation threads to process the corresponding simulation computing tasks.
[0070] Wherein, in this step, after the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, other simulation threads can be used to continue processing the corresponding simulation computing tasks, or the target simulation thread can be used to execute other simulation computing tasks; if the operating system thread is a thread created only for executing the current parallel computing task, in this step, the operating system thread can also be destroyed using the target simulation thread first, and then other simulation threads can be used to process the corresponding simulation computing tasks.
[0071] In this embodiment, the embodiment of the present invention uses the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and according to the preset simulation time of the current parallel computing task, adopts the target blocking method to block the operation of the target simulation thread, which can make the operation of other simulation threads parallel to the execution of the current parallel computing task by the operating system thread during the process of blocking the target simulation thread using the target blocking method. Thus, without the need to modify the SystemC kernel or significantly modify the simulation system framework, parallel construction can be carried out for some key areas with high performance consumption, the running efficiency of the entire simulation system can be improved while maintaining the SystemC standard, and the present invention couples the clock of the operating system thread with the simulation clock of the SystemC simulation thread to a certain extent, which is not only applicable to simulation models with accurate clocks but also applicable to simulation models with loose clocks that cannot be well applied in related technologies, having better application universality.
[0072] Based on the above embodiment, since there may be a situation where it is necessary to call the internal interface of the simulation system (SystemC internal interface) during the process of using the operating system thread to execute the current parallel computing task in step 102, such as obtaining the status or function interface in other SystemC threads, and the external operating system thread parallel to other SystemC threads usually cannot directly call various interfaces of the SystemC simulation threads inside the SystemC simulation system. To ensure the normal execution of the current parallel computing task in this case, in some embodiments, the process of using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task can include:
[0073] Step 1021: If the operating system thread needs to perform a call subtask of calling the internal interface of the simulation system during the execution of the current parallel computing task, use the operating system thread to send the call subtask to the target simulation thread and control the suspension of the blocking of the target simulation thread.
[0074] Step 1022: Use the target simulation thread to process the invoked subtask, and after the invoked subtask is completed, resume the blocking of the target simulation thread.
[0075] That is to say, the operating system thread can send the invoked subtask to the target simulation thread by calling the internal interface of the simulation system, and use the target simulation thread to complete the call of the internal interface of the simulation system.
[0076] Furthermore, to ensure the security between the operating system thread and the target simulation thread, in this embodiment, the operating system thread and the target simulation thread can use a mutex lock to perform information interaction. For example, step 1021 may include using the operating system thread to send the invoked subtask to the target simulation thread when the mutex lock is acquired; releasing the mutex lock and controlling the suspension of the blocking of the target simulation thread; step 1022 may include using the target simulation thread to process the invoked subtask when the mutex lock is acquired; after the invoked subtask is completed, releasing the mutex lock and resuming the blocking of the target simulation thread.
[0077] Correspondingly, this embodiment does not limit the specific process of sending the invoked subtask to the target simulation thread. For example, the operating system thread can send the invoked subtask to the shared buffer queue (Call_Queue) so that the target simulation thread can read the invoked subtask from the shared buffer queue. For example, when the target simulation thread is running, it can determine whether the shared buffer queue is empty when the mutex lock is acquired; if it is not empty, perform a dequeue operation on the shared buffer queue, obtain the unexecuted invoked subtask and process it.
[0078] Correspondingly, the process of using the target simulation thread to process the invoked subtask when the mutex lock is acquired may include: using the target simulation thread to determine whether the shared buffer queue is empty when the mutex lock is acquired; if it is not empty, process the invoked subtask; if it is empty, release the mutex lock and resume the blocking of the target simulation thread.
[0079] Among them, the process of releasing the mutex lock and resuming the blocking of the target simulation thread after the sub-task is called may include: after the sub-task is called, updating the shared call result flag (Func_Flag) to a true identifier, so that the operating system thread continues to execute the current parallel computing task according to the true identifier of the shared call result flag; releasing the mutex lock, and blocking the operation of the target simulation thread in a target blocking manner according to the current blocking duration to be awaited by the target simulation thread; where the current blocking duration to be awaited is the difference between the previous blocking duration to be awaited and the current blocking duration, and the initial value of the previous blocking duration to be awaited is a preset simulation time; that is to say, each time the target simulation thread pauses due to blocking in a target blocking manner, it can use the current blocking duration (i.e., the current blocking duration) before the pause to adjust the previous blocking duration to be awaited (Time_During) to obtain the current blocking duration to be awaited required for resuming the pause this time, so that the total blocking duration of the target simulation thread blocked in a target blocking manner is the preset simulation time.
[0080] In some embodiments, in order to further improve the operation efficiency of the entire simulation system, the total blocking duration (i.e., the preset simulation time) of the target simulation thread blocked in a target blocking manner may also be adjusted during the execution of the current parallel computing task by the operating system thread, so as to implement the function of extending or shortening the blocking duration of the target simulation thread blocked in a target blocking manner. For example, the processor may adjust the preset simulation time (i.e., the total blocking duration of the target simulation thread blocked in a target blocking manner) according to the execution conditions of the current parallel computing task and / or the target simulation task, such as by correspondingly adjusting the above-mentioned current blocking duration to be awaited to adjust the preset simulation time; where the current parallel computing task is a computing task in the target simulation task. For example, in practical applications, Time_During may be modified during the parallel process according to factors such as the computing time (such as the executed time) of the current parallel computing task and the progress speed of the target simulation task. For example, when it is necessary to adjust and increase the preset simulation time, the current blocking duration to be awaited may be correspondingly increased before blocking the operation of the target simulation thread in a target blocking manner according to the current blocking duration to be awaited by the target simulation thread.
[0081] Furthermore, the process of controlling the blocking of the target simulation thread can be implemented by a simulation system scheduler (i.e., SystemC scheduler) to ensure the normal operation of the serial scheduling of SystemC threads. For example, an operating system thread is used to send an update request to the simulation system scheduler. The simulation system scheduler controls the blocking of the target simulation thread according to the update request. For instance, the simulation system scheduler updates the shared synchronization flag bit (Synchro_Flag) to a true flag to block in the target blocking mode. Correspondingly, the target simulation thread can block in the target blocking mode when the shared synchronization flag bit is a true flag. When the target simulation thread blocks using wait() (i.e., the target blocking mode), it can stop blocking when the blocking duration reaches the preset simulation time (e.g., Time_During is 0) or the shared synchronization flag bit is updated to a true flag. The use of wait() here has not only Time_During representing the simulation clock but also Synchro_Flag representing the simulation event (sc_event). When the wait() ends due to the update of Synchro_Flag to True, the simulation clock will also advance.
[0082] Correspondingly, the update request sent by the operating system thread to the SystemC scheduler is implemented through specific update functions in SystemC (such as async_request_update()); this method enables external operating system threads to notify the SystemC scheduler of update requests for the current SystemC channels in a thread-safe manner. After the SystemC scheduler receives the update request, it adds the request to the scheduling queue and will call the callback function (update()) declared by the aforementioned channel in subsequent simulations to complete the expected update operation of the external thread. Specifically, when the operating system thread issues an update request, SystemC will process the request after the simulation clock advances for a period of time, and then perform an update operation on Synchro_Flag. The purpose of introducing this request-update mechanism and performing a series of processes in this embodiment is as follows: on the one hand, when an external operating system thread needs to call an internal interface of SystemC, due to the limitations of communication between SystemC threads and the external, as well as the non-coupling relationship between the SystemC simulation clock and the physical clock, it is very difficult for external threads to accurately complete the call to the expected internal interface at a certain simulation moment. In order to ensure the accuracy of the call results, blocking all SystemC threads will greatly reduce the running efficiency. Using the request-update mechanism can couple the external physical clock and the internal simulation clock to a certain extent. For example, through the setting of Time_During, the calls made during this period can ensure the accuracy of the results, and at the same time have less impact on the execution efficiency of other SystemC threads; on the other hand, due to the uncertainty of mutex allocation, using the request-update mechanism can ensure that when any thread obtains the mutex first, the call request can be processed in a timely manner, and the situation where the call execution of the operating system thread is missed because the target simulation thread obtains the mutex first will not occur.
[0083] For example, in the case of using a newly created operating system thread to execute the current parallel computing task, in the initial stage after the target simulation thread creates a new operating system thread, both the operating system thread and the target simulation thread need to obtain a mutex to ensure the thread safety of the subsequent process. Which thread can obtain the mutex first can be jointly determined by the scheduling mechanism of the operating system and the computing content of the current parallel computing task. The situation where any thread applies for the mutex first may occur. For example, Figure 3 The process shown can be carried out when the operating system thread (OS_Thread) obtains the mutex first, as shown in Figure 4 The process shown can be carried out when the target simulation thread (Par_Thread) obtains the mutex first.
[0084] For example, before step 1021, it may further include: using the target simulation thread to apply for a mutex lock after creating an operating system thread, and blocking the operation of the target simulation thread in a non-target blocking manner, such as Figure 3 the processes ⑨ and ⑩ in
[0085] If the target simulation thread successfully applies for the mutex lock, use the target simulation thread to determine whether the shared buffer queue is empty; where the shared buffer queue is used to store call subtasks; if it is empty, block the operation of the target simulation thread in a target blocking manner according to the preset simulation time; if it is not empty, use the target simulation thread to process the call subtasks; after the call subtasks are completed, block the operation of the target simulation thread in a target blocking manner according to the preset simulation time, and update the shared call result flag to a true flag, so that the operating system thread can continue to execute the current parallel computing task according to the true flag of the shared call result flag.
[0086] Based on the above embodiments, please refer to Figure 5 , Figure 5 which is a flowchart of another simulation calculation method of the simulation system provided by the embodiments of the present invention. The method may include:
[0087] Step 201: Allocate the current parallel computing task to the target simulation thread.
[0088] Wherein, the current parallel computing task in this step may be the computing task of Key_Calculation in the SystemC simulation system, that is, it needs to be physically parallelized to improve the simulation performance of the entire simulation system; the current parallel computing task can be expected to require a simulation time of the preset simulation time (Time_During) to complete all executions.
[0089] Step 202: Use the target simulation thread to create an operating system thread; use the operating system thread to execute the current parallel computing task.
[0090] For example, in this embodiment, a new SystemC thread can be created in the SystemC simulation system as the target simulation thread (Par_Thread). After Par_Thread completes other non-performance-critical initialization operations other than the current parallel computing task and has more interactions with other parts of the SystemC simulation system, it creates a new operating system thread OS_Thread and executes the current parallel computing task in OS_Thread.
[0091] Step 203: If the operating system thread needs to perform a calling subtask of calling the internal interface of the simulation system during the execution of the current parallel computing task, the target simulation thread is called to complete the calling subtask, and then the current parallel computing task is executed.
[0092] It can be understood that in this step, when the operating system thread is executing the current parallel computing task, if it needs to interact with other simulation system threads and needs to call the simulation system internal interface (Call_Func), the Call method can be used to complete the call of Call_Func using the target simulation thread, such as Figure 6 As shown, it may include:
[0093] Step 301: The operating system thread applies for a mutex lock, adds the calling subtask to the shared buffer queue, and releases the mutex lock.
[0094] Among them, in this step, OS_Thread applies for a mutex lock used to ensure the thread safety between it and Par_Thread. After adding the call interface wait() (i.e., calling the subtask) to Call_Queue, OS_Thread releases the mutex lock.
[0095] Step 302: The operating system thread sends an update request to the simulation system scheduler and blocks the execution of the current parallel computing task.
[0096] Correspondingly, in this step, OS_Thread sends an update request to the SystemC scheduler and blocks the execution of Key_Calculation, waiting for the update notification of the condition variable Func_Flag representing the state of the call interface wait().
[0097] Step 303: the target simulation thread applies for a mutex lock, and when it is found that the shared buffer queue is not empty, executes the calling subtask in the shared buffer queue.
[0098] Among them, since Par_Thread fails to obtain the mutex lock, it is blocked after creating OS_Thread until the mutex lock is acquired; after obtaining the mutex lock, Par_Thread queries that Call_Queue is not empty, so it dequeues Call_Queue, obtains the unexecuted call interface wait() and executes it.
[0099] Step 304: After the target simulation thread finishes executing the call subtask, it updates the shared call result flag to a true flag.
[0100] Correspondingly, after Par_Thread finishes executing the call interface wait(), it performs an update notification operation on the condition variable Func_Flag.
[0101] Step 305: The target simulation thread releases the mutex lock and uses the wait function to block the operation of the target simulation thread until the blocking duration reaches the preset simulation time or the shared synchronization flag is updated to a true flag.
[0102] Step 306: After the shared call result flag is updated to a true flag, the operating system thread is awakened, stops blocking and continues to execute the current parallel computing task.
[0103] Step 307: After the operating system thread finishes executing the current parallel computing task, it enters a blocked state and waits to obtain the mutex lock.
[0104] Step 308: When the target simulation thread is blocked using the wait function, the simulation system scheduler starts to process the update request and updates the shared synchronization flag to a true flag.
[0105] Among them, when Par_Thread is blocked using the wait() method and waits for Time_During to be consumed or Synchro_Flag to be updated, the internal simulation clock of SystemC starts to advance, the SystemC scheduler starts to process the update request sent by OS_Thread in step 302, and completes the update of Synchro_Flag.
[0106] Step 309: The target simulation thread is awakened after the shared synchronization flag is updated to a true flag, calculates the current blocking duration, and uses non-target blocking to block and wait to obtain the mutex lock.
[0107] Correspondingly, after Synchro_Flag is updated, Par_Thread is awakened, then calculates this Time_Wait, and enters a blocked state again, waiting to obtain the mutex lock.
[0108] Step 310: After the target simulation thread acquires the mutex lock, it stops blocking, subtracts the current blocking duration from the previous blocking duration to be blocked, and obtains the current blocking duration to be blocked.
[0109] Correspondingly, in this step, after Par_Thread acquires the mutex lock, Par_Thread stops blocking, and updates by subtracting Time_Wait from the initial value of Time_During.
[0110] Step 311: The target simulation thread checks that the shared buffer queue is empty, releases the mutex lock, and blocks using a wait function according to the current blocking duration to be blocked.
[0111] It can be understood that in this step, Par_Thread queries Call_Queue again. Since OS_Thread does not continue to send a call request (i.e., calls the interface wait()), Call_Queue is empty at this time. Par_Thread does not perform other operations on Call_Queue, so it releases the mutex lock and enters the blocked state again until the updated Time_During is consumed or Synchro_Flag is updated.
[0112] Step 312: When the blocking duration reaches the blocking duration to be blocked, the target simulation thread stops blocking, calculates the current blocking duration, and blocks using a non-target blocking method, waiting to acquire the mutex lock.
[0113] Correspondingly, when the blocking duration reaches Time_During, Par_Thread stops this blocking, calculates the current blocking duration Time_Wait again, and enters the blocked state again until it acquires the mutex lock.
[0114] Step 313: After the target simulation thread acquires the mutex lock, it stops blocking, subtracts the current blocking duration from the previous blocking duration to be blocked, obtains the current blocking duration to be blocked, and releases the mutex lock.
[0115] Among them, Par_Thread acquires the mutex lock, updates Time_During according to Time_Wait again, and then releases the mutex lock to determine whether the shared flag bit is a true flag after Time_During is 0 (i.e., the total blocking duration reaches the preset simulation time).
[0116] Step 204: Using the operating system thread, after completing the current parallel computing task and acquiring the mutex lock, update the shared flag bit to a true flag.
[0117] It is understandable that after OS_Thread completes all executions of Key_Calculation and acquires the mutex lock, it can update the shared variable Done_Flag (i.e., the shared flag bit) from the default value False to True, as Figure 3 in the process and Figure 4 in the process.
[0118] Step 205: Using the target simulation thread, after the blocking duration reaches the preset simulation time, determine whether the shared flag bit is a true flag; if not, proceed to Step 206; if so, proceed to Step 208.
[0119] Step 206: Block the target simulation thread until the shared flag bit is updated to a true flag.
[0120] Among them, the blocking caused by waiting for the update of Done_Flag in this step will adopt a non-target blocking method and will not cause a change in the simulation time.
[0121] Step 207: Using the target simulation thread, destroy the operating system thread.
[0122] Step 208: Using the target simulation thread, execute other simulation calculation tasks.
[0123] Among them, after the current parallel computing task is executed using the operating system thread, other simulation calculation tasks can be continued to be executed using the target simulation thread, which is a non-performance-consuming key task without physical parallelism; or other simulation threads can be continued to be used to process the corresponding simulation calculation tasks.
[0124] It is understandable that after OS_Thread in Step 204 completes the current parallel computing task, it will enter a blocked state and wait for the allocation of the mutex lock to update Done_Flag to True after acquiring the mutex lock. Since there is no absolute mapping relationship between the internal simulation clock of SystemC and the external physical clock, and the execution time of the current parallel computing task is also unknown, there are multiple situations for the time when OS_Thread acquires the mutex lock again - it is possible that the execution of the current parallel computing task is very fast and the operations of the SystemC scheduler to process update requests and other operations consume a long physical time, or it is possible that the execution of the current parallel computing task is slow and the processing speed on the SystemC side is very fast. Therefore, OS_Thread may stop this blocking at three moments: 1. After the SystemC scheduler processes the update request, when the blocked Par_Thread has not been woken up by Synchro_Flag and acquires the subsequent mutex lock, as Figure 3 in to Procedure; 2. After Par_Thread acquires the mutex lock and queries that the Call_Queue is empty and releases the mutex lock, but before updating Time_During, as Figure 3 in to Procedure; 3. After Par_Thread acquires the mutex lock, updates Time_During, and releases the mutex lock, but before performing the destruction operation on OS_Thread, as Figure 4 in to Procedure. After OS_Thread is allocated the mutex lock and stops the current block, it immediately updates Done_Flag to True and releases the mutex lock.
[0125] It should be noted that this embodiment shows an example of using a mutex lock to ensure thread safety when accessing multiple shared variables (such as Time_During, Done_Flag, and Call_Queue, etc.), mainly to reduce the occurrence of deadlocks. That is, the more mutex locks, the higher the possibility of deadlocks. To improve the degree of parallelization, two or more mutex locks can also be set, such as using different mutex locks for different shared variables. This embodiment does not make any restrictions on this.
[0126] Corresponding to the above method embodiment, the embodiment of the present invention also provides a simulation calculation device for a simulation system. The following description of a simulation calculation device for a simulation system corresponds to the above-described simulation calculation method of a simulation system and can be referred to each other.
[0127] Please refer to Figure 7 , Figure 7 which is a structural block diagram of a simulation calculation device for a simulation system provided by an embodiment of the present invention. The device may include:
[0128] An allocation module 10 for allocating the current parallel computing task to a target simulation thread; wherein, the target simulation thread is a parallel simulation thread other than the regular simulation threads in the simulation system, and both the regular simulation threads and the parallel simulation threads are threads based on a C++ hardware description language;
[0129] A parallel module 20 for using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task and blocking the operation of the target simulation thread according to the preset simulation time of the current parallel computing task by using a target blocking method; wherein, the target blocking method is a blocking method that does not block the simulation time of the simulation system;
[0130] The waiting module 30 is configured to block the operation of the target simulation thread in a non-target blocking manner if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task.
[0131] The completion module 40 is configured to, if the blocking duration of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, use other simulation threads to process the corresponding simulation computing tasks.
[0132] In some embodiments, the target blocking method includes a waiting function.
[0133] In some embodiments, the apparatus may further include: a creation module configured to create an operating system thread using the target simulation thread.
[0134] In some embodiments, the apparatus may further include: a destruction device configured to, after the operating system thread has completed the current parallel computing task, destroy the operating system thread using the target simulation thread.
[0135] In some embodiments, the apparatus may further include: an adjustment module configured to adjust the preset simulation time according to the execution status of the current parallel computing task and / or the target simulation task; wherein the current parallel computing task is a computing task in the target simulation task.
[0136] In some embodiments, the apparatus may further include: a parallel determination module configured to determine the parallel computing tasks in the target simulation task according to the performance consumption information of each computing task in the target simulation task; wherein the current parallel computing task is any parallel computing task, and the performance consumption information includes data volume information.
[0137] In some embodiments, the parallel module 20 may include:
[0138] The call pause sub-module is configured to, if the operating system thread needs to perform a call sub-task of calling the internal interface of the simulation system during the execution of the current parallel computing task, use the operating system thread to send the call sub-task to the target simulation thread and control the suspension of the blocking of the target simulation thread.
[0139] The call resume sub-module is configured to process the call sub-task using the target simulation thread and resume the blocking of the target simulation thread after the call sub-task is completed.
[0140] In some embodiments, the call pause sub-module may be specifically configured to use the operating system thread to send the call sub-task to the target simulation thread when a mutex lock is acquired; release the mutex lock and control the suspension of the blocking of the target simulation thread.
[0141] The call recovery sub-module can be specifically used to utilize the target simulation thread to process the call sub-task when the mutex lock is acquired, and after the call sub-task is completed, release the mutex lock and resume the blocking of the target simulation thread.
[0142] In some embodiments, the call pause sub-module may include:
[0143] An update request unit, configured to use the operating system thread to send an update request to the simulation system scheduler;
[0144] An update processing unit, configured to use the simulation system scheduler to update the shared synchronization flag to a true flag according to the update request; wherein, when the shared synchronization flag is the true flag, the target simulation thread pauses the blocking of the target blocking mode.
[0145] In some embodiments, the call recovery sub-module may include:
[0146] A result update unit, configured to update the shared call result flag to a true flag after the call sub-task is completed, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared call result flag;
[0147] A blocking recovery unit, configured to release the mutex lock and block the operation of the target simulation thread in the target blocking mode according to the current blocking duration to be awaited by the target simulation thread; wherein, the current blocking duration to be awaited is the difference between the previous blocking duration to be awaited and the current blocking duration, and the initial value of the previous blocking duration to be awaited is a preset simulation time.
[0148] In some embodiments, the call pause sub-module may include: a call sending unit, configured to send the call sub-task to the shared buffer queue, so that the target simulation thread reads the call sub-task from the shared buffer queue.
[0149] In some embodiments, the call recovery sub-module may include: a queue judgment unit, configured to use the target simulation thread to judge whether the shared buffer queue is empty when the mutex lock is acquired; if not empty, process the call sub-task; if empty, release the mutex lock and resume the blocking of the target simulation thread.
[0150] In some embodiments, the parallel module 20 may further include:
[0151] A create blocking sub-module, configured to use the target simulation thread to acquire a mutex lock after creating the operating system thread, and block the operation of the target simulation thread in a non-target blocking mode;
[0152] A blocking judgment sub-module, configured to, if the target simulation thread acquires the mutex lock, use the target simulation thread to judge whether the shared buffer queue is empty; wherein, the shared buffer queue is used to store call sub-tasks;
[0153] The first blocking sub-module is used to block the operation of the target simulation thread in a target blocking manner according to a preset simulation time if it is empty.
[0154] The second blocking sub-module is used to process the called sub-task by using the target simulation thread if it is not empty; after the called sub-task is completed, block the operation of the target simulation thread in a target blocking manner according to a preset simulation time, and update the shared call result flag to a true flag, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared call result flag.
[0155] In some embodiments, the call pause sub-module may include:
[0156] Create an execution unit for executing the current parallel computing task by using the newly created operating system thread.
[0157] Apply for a blocking unit to apply for a mutex lock and block the execution of the current parallel computing task if there is a called sub-task, so as to wait for the shared call result flag to be updated to a true flag.
[0158] The task sending unit is used to add the called sub-task to the shared buffer queue if the operating system thread obtains the mutex lock.
[0159] In some embodiments, the device may further include: a flag judgment module for using the target simulation thread to judge whether the shared flag is a true flag after the blocking duration reaches the preset simulation time; if the shared flag is a true flag, execute the step of processing the corresponding simulation computing task by using other simulation threads; if the shared flag is a false flag, send a start signal to the completion module 40.
[0160] In some embodiments, the device may further include:
[0161] An application module for applying for a mutex lock by using the operating system thread after executing the current parallel computing task.
[0162] A release module for updating the shared flag to a true flag and releasing the mutex lock if the mutex lock is obtained.
[0163] In this embodiment, the embodiment of the present invention uses the operating system thread corresponding to the target simulation thread through the parallel module 20 to execute the current parallel computing task, and blocks the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task. During the process of blocking the target simulation thread in the target blocking manner, the operation of other simulation threads can be parallel to the execution of the current parallel computing task by the operating system thread. Therefore, without modifying the SystemC kernel or significantly modifying the simulation system framework, parallel construction can be carried out for some key areas of performance consumption, the operation efficiency of the entire simulation system can be improved while maintaining the SystemC standard, and the present invention couples the clock of the operating system thread with the simulation clock of the SystemC simulation thread to a certain extent, which is applicable not only to simulation models with accurate clocks but also to simulation models with loose clocks that cannot be well applied in related technologies, and has better application universality.
[0164] Corresponding to the above method embodiment, the embodiment of the present invention also provides a simulation computing device for a simulation system. The simulation computing device for a simulation system described below can be correspondingly referred to the simulation computing method for a simulation system described above.
[0165] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of a simulation computing device for a simulation system provided by the embodiment of the present invention. The device may include:
[0166] A memory D1 for storing a computer program; a processor D2 for implementing the steps of the simulation computing method for a simulation system provided by the above method embodiment when executing the computer program.
[0167] Among them, the simulation computing device for a simulation system provided by this embodiment may specifically be a host device (such as a server) or a computer.
[0168] Corresponding to the above method embodiment, the embodiment of the present invention also provides a computer program product. The computer program product described below can be correspondingly referred to the simulation computing method for a simulation system described above.
[0169] A computer program product includes a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the simulation computing method for a simulation system provided by the above method embodiment are implemented.
[0170] Corresponding to the above method embodiment, the embodiment of the present invention also provides a computer-readable storage medium. The computer-readable storage medium described below can be correspondingly referred to the simulation computing method for a simulation system described above.
[0171] A computer-readable storage medium stores a computer program thereon. When the computer program is executed by a processor, it implements the steps of the simulation calculation method of the simulation system provided in the above method embodiment. Specifically, the computer-readable storage medium can be various readable storage media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc that can store program codes.
[0172] The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same and similar parts between the various embodiments, reference can be made to each other. For the devices, equipment, computer program products, and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.
[0173] The above has introduced in detail a simulation calculation method, a device, equipment, a computer program product, and a computer-readable storage medium provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present invention, several improvements and modifications can still be made to the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A simulation calculation method for a simulation system, characterized in that: include: Allocate the current parallel computing task to a target simulation thread; wherein the target simulation thread is a parallel simulation thread other than a conventional simulation thread in the simulation system, and both the conventional simulation thread and the parallel simulation thread are threads based on the C++ hardware description language; Utilize the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and according to the preset simulation time of the current parallel computing task, use the target blocking mode to block the operation of the target simulation thread; wherein the target blocking mode is a blocking mode that will not block the simulation time of the simulation system; If the blocking time of the target simulation thread reaches the preset simulation time, and the operating system thread has not completed the current parallel computing task, a non-target blocking method is used to block the operation of the target simulation thread; If the blocking time of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task, other simulation threads are used to process the corresponding simulation computing task.
2. The simulation calculation method of the simulation system according to claim 1, characterized in that: The target blocking mode includes a wait function.
3. The simulation calculation method of the simulation system according to claim 1, characterized in that: Before using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, the method further includes: The operating system thread is created using the target simulation thread.
4. The simulation calculation method of the simulation system according to claim 3, characterized in that: Also includes: After the operating system thread has completed the current parallel computing task, the target simulation thread is used to destroy the operating system thread.
5. The simulation calculation method of the simulation system according to claim 1, characterized in that: After using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task and blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task, the method further includes: The preset simulation time is adjusted according to the execution status of the current parallel computing task and / or the target simulation task; wherein the current parallel computing task is a computing task in the target simulation task.
6. The simulation calculation method of the simulation system according to claim 1, characterized in that: Also includes: According to the performance consumption information of each computing task in the target simulation task, the parallel computing tasks in the target simulation task are determined; wherein the current parallel computing task is any of the parallel computing tasks, and the performance consumption information includes data volume information.
7. The simulation calculation method of the simulation system according to any one of claims 1 to 6, characterized in that: Utilizing the operating system thread corresponding to the target simulation thread to execute the current parallel computing task includes: If the operating system thread needs to perform a calling subtask of calling the internal interface of the simulation system during the execution of the current parallel computing task, the operating system thread is used to send the calling subtask to the target simulation thread, and control the suspension of the blocking of the target simulation thread; The target simulation thread is used to process the calling subtask, and after the calling subtask is completed, the blocking of the target simulation thread is restored.
8. The simulation calculation method of the simulation system according to claim 7, characterized in that: Utilizing the operating system thread, sending the calling subtask to the target simulation thread, and controlling the blocking of the target simulation thread to be suspended, including: Using the operating system thread, in the case of applying for a mutex lock, the calling subtask is sent to the target simulation thread; the mutex lock is released, and the blocking of the target simulation thread is suspended; Utilizing the target simulation thread to process the calling subtask, and after the calling subtask is completed, resuming the blocking of the target simulation thread, comprises: The target simulation thread is used to process the calling subtask when a mutex lock is applied for; after the calling subtask is completed, the mutex lock is released and the blocking of the target simulation thread is restored.
9. The simulation calculation method of the simulation system according to claim 8, characterized in that: Controlling the suspension of blocking of the target simulation thread includes: Using the operating system thread, sending an update request to the simulation system scheduler; The simulation system scheduler is used to update the shared synchronization flag to a true flag according to the update request; wherein, when the shared synchronization flag is a true flag, the target simulation thread suspends the blocking of the target blocking mode.
10. The simulation calculation method of the simulation system according to claim 8, characterized in that: After the calling subtask is completed, the mutex lock is released and the blocking of the target simulation thread is restored, including: After the calling subtask is completed, the shared calling result flag is updated to a true flag, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared calling result flag; Release the mutex lock, and block the target simulation thread in a target blocking manner according to the current blocking time of the target simulation thread; wherein the current blocking time is the difference between the last blocking time and the current blocking time, and the initial value of the last blocking time is the preset simulation time.
11. The simulation calculation method of the simulation system according to claim 8, characterized in that: Sending the calling subtask to the target simulation thread includes: The calling subtask is sent to a shared buffer queue, so that the target simulation thread reads the calling subtask from the shared buffer queue.
12. The simulation calculation method of the simulation system according to claim 11, characterized in that: Using the target simulation thread, in the case of applying for a mutex lock, processing the calling subtask includes: Using the target simulation thread, when a mutex lock is applied, determining whether the shared buffer queue is empty; If it is not empty, process the calling subtask; If it is empty, the mutex lock is released and the blocking of the target simulation thread is restored.
13. The simulation calculation method of the simulation system according to claim 8, characterized in that: Using the operating system thread, in the case of applying for a mutex lock, before sending the calling subtask to the target simulation thread, the method further includes: Using the target simulation thread, applying for the mutex lock after creating the operating system thread, and blocking the operation of the target simulation thread in a non-target blocking manner; If the target simulation thread applies for the mutex lock, the target simulation thread is used to determine whether the shared buffer queue is empty; wherein the shared buffer queue is used to store the calling subtask; If it is empty, the step of blocking the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task is executed; If it is not empty, the target simulation thread is used to process the calling subtask; after the calling subtask is completed, the step of blocking the running of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task is executed, and the shared call result flag is updated to a true flag, so that the operating system thread continues to execute the current parallel computing task according to the true flag of the shared call result flag.
14. The simulation calculation method of the simulation system according to claim 13, characterized in that: Using the operating system thread, in the case of applying for a mutex lock, sending the calling subtask to the target simulation thread, including: Use the newly created operating system thread to execute the current parallel computing task; If there is a calling subtask, apply for the mutex lock and block the execution of the current parallel computing task to wait for the shared calling result flag to be updated to a true flag; If the operating system thread applies for the mutex lock, the calling subtask is added to the shared buffer queue.
15. The simulation calculation method of the simulation system according to claim 7, characterized in that: After blocking the running of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task, the method further includes: Using the target simulation thread, after the blocking time reaches the preset simulation time, determining whether the shared flag is a true flag; If the shared flag is a true flag, executing the step of using other simulation threads to process the corresponding simulation computing task; If the shared flag is a false flag, the step of blocking the running of the target simulation thread in a non-target blocking manner is executed.
16. The simulation calculation method of the simulation system according to claim 15, characterized in that: After the operating system thread corresponding to the target simulation thread is used to execute the current parallel computing task, the method further includes: Using the operating system thread, after executing the current parallel computing task, apply for a mutex lock; If the mutex lock is applied for, the shared flag is updated to a true flag and the mutex lock is released.
17. A simulation computing device for a simulation system, characterized in that: include: An allocation module, used for allocating the current parallel computing task to a target simulation thread; wherein the target simulation thread is a parallel simulation thread other than a conventional simulation thread in the simulation system, and both the conventional simulation thread and the parallel simulation thread are threads based on the C++ hardware description language; A parallel module, used to use the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, and block the operation of the target simulation thread in a target blocking manner according to the preset simulation time of the current parallel computing task; wherein the target blocking manner is a blocking manner that will not block the simulation time of the simulation system; A waiting module, used for blocking the operation of the target simulation thread in a non-target blocking manner if the blocking time of the target simulation thread reaches the preset simulation time and the operating system thread has not completed the current parallel computing task; The completion module is used to use other simulation threads to process corresponding simulation computing tasks if the blocking time of the target simulation thread reaches the preset simulation time and the operating system thread has completed the current parallel computing task.
18. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the simulation calculation method of the simulation system as claimed in any one of claims 1 to 16 are implemented.
19. A simulation computing device for a simulation system, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the simulation calculation method of the simulation system as claimed in any one of claims 1 to 16 when executing the computer program.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the simulation calculation method of the simulation system according to any one of claims 1 to 16 are implemented.
Citation Information
Patent Citations
Hardware transaction level simulation method, engine and system
CN102760176A
Multi-thread optimization method and system for SystemC simulation scheduling core and medium
CN109783239A
Multi-thread parallel processing method and device and storage medium
CN114416364A
Hardware simulation method and device, equipment and storage medium
CN114428722A
Multi-thread data transmission system based on SystemC and C + +
CN115185718A