A simulation calculation method, device, equipment, product and medium of a simulation system
By introducing the coordinated work of parallel simulation threads and operating system threads in the SystemC simulation system, the target blocking method and mutex locking mechanism are adopted, the problem of low operating efficiency of SystemC simulation system is solved, and the parallelization of the simulation system is realized, and it is suitable for a variety of simulation models.
Patent Information
- Application Number
- CN202510534771.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-27
AI Technical Summary
SystemC simulation systems have low operating efficiency, especially when multi-threading or high computing volume, it is difficult for the prior art to achieve physical parallelization and are not suitable for simulation models with loose clocks.
By introducing a parallel simulation thread into the SystemC simulation system, the operating system thread of the target simulation thread performs parallel computing tasks, and the target blocking method blocks the operation of the simulation thread, combining the waiting function and the mutex mechanism, the parallelization of the simulation system is achieved.
It improves the operation efficiency of the simulation system, is suitable for simulation models with accurate clocks and loose clocks, maintains compatibility with SystemC standards, and does not require significant modification of the simulation architecture.
Smart Images

Figure CN120066685B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of simulation technology, and particularly relates to a simulation calculation method, device, equipment, product and medium of a simulation system. Background Technique
[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 calculation amount 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 nowadays. 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 achieve 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 calculation 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 the hardware description language of 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 of calling an 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 bit 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 bit is the 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 bit 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 bit; releasing the mutex lock, and blocking the operation of the target simulation thread in the 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, using the target simulation thread, when the mutex lock is acquired, processing the call sub-task includes: using the target simulation thread, when the mutex lock is acquired, determining whether the shared buffer queue is empty; if not empty, processing the call sub-task; if empty, releasing the mutex lock and resuming the blocking of the target simulation thread.
[0023] On the other hand, using the operating system thread, before sending the call sub-task to the target simulation thread when the mutex lock is acquired, it further includes: using the target simulation thread, after creating the operating system thread, acquiring the mutex lock and blocking the operation of the target simulation thread in a non-target blocking manner; if the target simulation thread acquires 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, using 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, using the operating system thread, when the mutex lock is acquired, 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, acquiring 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 acquires 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 method further includes: 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, performing the step of using other simulation threads to process corresponding simulation computing tasks; if the shared flag bit is a false flag, performing 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 method further includes: 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, updating the shared flag bit to a true flag and releasing 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 a conventional simulation thread in the simulation system, and both the conventional simulation thread and the parallel simulation thread 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 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 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 completed the current parallel computing task, then use 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, so that 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. Thus, it is possible to perform parallel construction on some key areas of performance consumption without modifying the SystemC kernel or significantly modifying the simulation system framework, and improve the operation 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 a 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 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 lock 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 lock 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 scope of protection of the present invention.
[0049] Please refer to Figure 1 , Figure 1 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 more performance consumption (such as a larger 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, a 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, enabling the execution of the current parallel computing task by the operating system thread to be parallel with 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 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 using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task in this step, it can be set by the designer himself. For example, the newly created operating system thread can be used to execute the current parallel computing task, that is, the target simulation thread can create an operating system thread after being assigned the current parallel computing task for executing the current parallel computing task. That is to say, before using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task in this embodiment, it may also include: creating an operating system thread 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 using the target simulation thread.
[0061] In some other embodiments, the processor can also use the created operating system thread to execute the current parallel computing task, that is, one or more operating system threads can be preset to execute the corresponding parallel computing tasks, reducing the creation and destruction process 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 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, the target simulation thread is blocked from running 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 running 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 processing 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 executing 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 ensured in this embodiment through the setting of 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] Among them, 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 by 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 blocks the operation of the target simulation thread in the 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 the parallel construction of some key areas of performance consumption can be carried out without modifying the SystemC kernel or significantly modifying the simulation system framework, the operation efficiency of the entire simulation system can be improved while retaining 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 the related art, and has 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 may 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 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 is acquired; releasing the mutex 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 is acquired; after the invoked subtask is completed, releasing the mutex 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 is acquired; if it is not empty, perform a dequeue operation on the shared buffer queue to 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 is acquired may include: using the target simulation thread to determine whether the shared buffer queue is empty when the mutex is acquired; if it is not empty, process the invoked subtask; if it is empty, release the mutex and resume the blocking of the target simulation thread.
[0079] Among them, after the sub-task is called and completed, releasing the mutex lock and resuming the blocking of the target simulation thread may include: after the sub-task is called and completed, updating the shared call result flag (Func_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 manner according to the current blocking duration to be waited for by the target simulation thread; where the current blocking duration to be waited for is the difference between the previous blocking duration to be waited for and the current blocking duration, and the initial value of the previous blocking duration to be waited for 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 of this time (i.e., the current blocking duration) before the pause to adjust the previous blocking duration to be waited for (Time_During), so as to obtain the current blocking duration to be waited for required when 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 can also be adjusted during the process of the operating system thread executing the current parallel computing task, 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 can 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 situation of the current parallel computing task and / or the target simulation task, such as by correspondingly adjusting the current blocking duration to be waited for 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 can 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 waited for can 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 waited for 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, and 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 according to the update request 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. For example, when the target simulation thread uses wait() (i.e., the target blocking mode) to block, 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 the update request for the current SystemC channel in a thread-safe manner. After the SystemC scheduler receives the update request, it will add the request to the scheduling queue and call the callback function (update()) declared by the aforementioned channel in the subsequent simulation 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 SystemC interface, due to the limitations of the 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 the external thread to accurately complete the call to the expected internal interface at a certain simulation moment. In order to ensure the accuracy of the call result, blocking each SystemC thread 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, the setting of Time_During can ensure the accuracy of the result during this period, and at the same time has little 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 there will be no situation where the call execution of the operating system thread is missed because the target simulation thread obtains the mutex first.
[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 calculation 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 applies for and obtains 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 embodiment 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 a 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 it acquires the mutex lock. After obtaining the mutex lock, Par_Thread checks 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 by 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 duration of this block, and uses a non-target blocking method to block and waits to obtain the mutex lock.
[0107] Correspondingly, after Synchro_Flag is updated, Par_Thread is awakened, then calculates Time_Wait this time, 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 the 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 re-enters the blocked state 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 true 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 shown in Figure 3 the process and Figure 4 the process.
[0118] Step 205: Use 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, go to Step 206; if so, go 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: Use the target simulation thread to destroy the operating system thread.
[0122] Step 208: Use the target simulation thread to execute other simulation calculation tasks.
[0123] Among them, after using the operating system thread to complete the current parallel computing task, the target simulation thread can be used to continue executing other simulation calculation tasks, which are non-performance-consuming key tasks without physical parallelism; or other simulation threads can continue 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 while 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 shown in Figure 3 the to Procedure; 2. After Par_Thread acquires the mutex lock and queries that Call_Queue is empty, 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 this blockage, it immediately updates Done_Flag to True and releases the mutex lock.
[0125] It should be noted that this embodiment is shown by taking using a mutex lock to ensure thread safety when accessing multiple shared variables (such as Time_During, Done_Flag, and Call_Queue, etc.) as an example, 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. A simulation calculation device for a simulation system described below can be mutually corresponding and referred to with a simulation calculation method for a simulation system described above.
[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, configured to allocate 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 based on a C++ hardware description language;
[0129] A parallel module 20, configured to execute the current parallel computing task by using the operating system thread corresponding to the target simulation thread, and block 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] A waiting module 30, configured to block the operation of a target simulation thread in a non-target blocking manner if the blocking duration of the target simulation thread reaches a preset simulation time and the operating system thread has not completed the current parallel computing task.
[0131] A completion module 40, configured to, if the blocking duration of the target simulation thread reaches a 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 manner 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 conditions 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 task 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] A call pause sub-module, configured to, if the operating system thread needs to perform a call sub-task of calling an 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] A call resume sub-module, configured to use the target simulation thread to process the call sub-task 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 release the mutex lock after the call sub-task is completed, 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 bit to a true identifier according to the update request; wherein, when the shared synchronization flag bit is the true identifier, 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 bit to a true identifier 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 identifier of the shared call result flag bit;
[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 waited of the target simulation thread; wherein, the current blocking duration to be waited is the difference between the previous blocking duration to be waited and the current blocking duration, and the initial value of the previous blocking duration to be waited is the 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 it is not empty, process the call sub-task; if it is 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 the 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 the call sub-task;
[0153] The first blocking sub-module is configured to, if it is empty, block the operation of the target simulation thread in a target blocking manner according to a preset simulation time.
[0154] The second blocking sub-module is configured to, if it is not empty, use the target simulation thread to process the called sub-task; 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, if there is a called sub-task, apply for a mutex lock and block the execution of the current parallel computing task to wait for the shared call result flag to be updated to a true flag.
[0158] The task sending unit is configured to, if the operating system thread obtains the mutex lock, add the called sub-task to the shared buffer queue.
[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 using the operating system thread to apply for a mutex lock after executing the current parallel computing task.
[0162] A release module for, if the mutex lock is obtained, updating the shared flag to a true flag and releasing the mutex lock.
[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, it is possible to perform parallel construction on some key areas of performance consumption, 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 applicable not only to simulation models with accurate clocks but also to simulation models with loose clocks that cannot be well applied in the related art, having better application universality.
[0164] Corresponding to the above method embodiment, the embodiment of the present invention further provides a simulation computing device for a simulation system. The following description of a simulation computing device for a simulation system can be correspondingly referred to with the above-described simulation computing method for a simulation system.
[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 further provides a computer program product. The following description of a computer program product can be correspondingly referred to with the above-described simulation computing method for a simulation system.
[0169] A computer program product includes computer programs / instructions, and when the computer programs / 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 further provides a computer-readable storage medium. The following description of a computer-readable storage medium can be correspondingly referred to with the above-described simulation computing method for a simulation system.
[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 embodiments. The computer-readable storage medium may specifically 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. The same or similar parts among the various embodiments can be referred 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 descriptions are 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 herein 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 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, Including: 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 the C++ hardware description language; Executing the current parallel computing task by 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; wherein, the target blocking manner is a blocking manner that does not block the simulation time of the simulation system; the operating system thread is used to execute the current parallel computing task allocated to the target simulation thread; 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; 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 use other simulation threads to process the corresponding simulation computing tasks; Wherein, before executing the current parallel computing task by using the operating system thread corresponding to the target simulation thread, it further includes: Creating the operating system thread by using the target simulation thread.
2. The simulation calculation method of the simulation system according to claim 1, characterized in that, The target blocking manner includes a wait function.
3. The simulation calculation method of the simulation system according to claim 1, wherein It further includes: After the operating system thread has completed the current parallel computing task, destroying the operating system thread by using the target simulation thread.
4. The simulation calculation method of the simulation system according to claim 1, wherein, After executing the current parallel computing task by 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 a computing task in the target simulation task.
5. The simulation calculation method of the simulation system according to claim 1, wherein It 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.
6. The simulation calculation method of the simulation system according to any one of claims 1 to 5, characterized in that, Executing the current parallel computing task by using the operating system thread corresponding to the target simulation thread includes: If the operating system thread needs to perform a call subtask of calling an internal interface of the simulation system during the execution of the current parallel computing task, then 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; Processing the call subtask by using the target simulation thread and resuming the blocking of the target simulation thread after the call subtask is completed.
7. The simulation calculation method of the simulation system according to claim 6, characterized in that, Using 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 includes: Using the operating system thread, when the mutex lock is acquired, send the call sub-task to the target simulation thread; release the mutex lock, and control to pause the blocking of the target simulation thread. Using the target simulation thread to process the call sub-task, and after the call sub-task is completed, resume the blocking of the target simulation thread, including: Using the target simulation thread, when the mutex lock is acquired, process the call sub-task; after the call sub-task is completed, release the mutex lock, and resume the blocking of the target simulation thread.
8. The simulation calculation method of the simulation system according to claim 7, characterized in that, Controlling to pause the blocking of the target simulation thread, including: 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, when the shared synchronization flag is the true flag, the target simulation thread pauses the blocking of the target blocking mode.
9. The simulation calculation method of the simulation system according to claim 7, characterized in that, After the call sub-task is completed, release the mutex lock, and resume the blocking of the target simulation thread, including: After the call sub-task is completed, 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; Release the mutex lock, and block the operation of the target simulation thread in a target blocking mode according to the current blocking duration to be waited of the target simulation thread; wherein, the current blocking duration to be waited is the difference between the previous blocking duration to be waited and the current blocking duration, and the initial value of the previous blocking duration to be waited is the preset simulation time.
10. The simulation calculation method of the simulation system according to claim 7, characterized in that, Sending the call sub-task to the target simulation thread, including: Sending 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.
11. The simulation calculation method of the simulation system according to claim 10, characterized in that, Using the target simulation thread to process the call sub-task when the mutex lock is acquired, including: Using the target simulation thread to judge whether the shared buffer queue is empty when the mutex lock is acquired; If it is not empty, process the call sub-task; If it is empty, release the mutex lock, and resume the blocking of the target simulation thread.
12. The simulation calculation method of the simulation system according to claim 7, characterized in that, Using the operating system thread, before sending the call sub-task to the target simulation thread when the mutex lock is acquired, further including: Using the target simulation thread to acquire the mutex lock after creating the operating system thread, and block the operation of the target simulation thread in a non-target blocking mode; 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 the call sub-task; If it is empty, execute the step of blocking the operation of the target simulation thread in a target blocking mode according to the preset simulation time of the current parallel computing task. If it is not empty, use the target simulation thread to process the call subtask; after the call subtask 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.
13. The simulation calculation method of the simulation system according to claim 12, characterized in that, Using the operating system thread, when the mutex lock is acquired, send the call 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 call subtask, apply for the mutex lock and block 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 acquires the mutex lock, add the call subtask to the shared buffer queue.
14. The simulation calculation method of the simulation system according to claim 6, characterized in that, After 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: Using the target simulation thread, after the blocking duration reaches the preset simulation time, determine whether the shared flag is a true flag; If the shared flag is a true flag, execute the step of using other simulation threads to process the corresponding simulation computing tasks; If the shared flag is a false flag, execute the step of blocking the operation of the target simulation thread in a non-target blocking manner.
15. The simulation calculation method of the simulation system according to claim 14, characterized in that, After using the operating system thread corresponding to the target simulation thread to execute the current parallel computing task, it further includes: Using the operating system thread, after executing the current parallel computing task, apply for a mutex lock; If the mutex lock is acquired, update the shared flag to a true flag and release the mutex lock.
16. A simulation calculation device of a simulation system, characterized in that, It includes: An allocation module 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 the C++ hardware description language; A parallel module 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 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; the operating system thread is used to execute the current parallel computing task allocated to the target simulation thread; A waiting module for 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 not completed the current parallel computing task; A completion module for using 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; Wherein, the device further includes: A creation module for creating the operating system thread by using the target simulation thread.
17. 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 according to any one of claims 1 to 15 are implemented.
18. A simulation computing device of a simulation system, characterized in that Comprising: A memory for storing a computer program; A processor for implementing the steps of the simulation calculation method of the simulation system according to any one of claims 1 to 15 when executing the computer program.
19. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, 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 15 are implemented.
Citation Information
Patent Citations
Multi-thread optimization method and system for SystemC simulation scheduling core and medium
CN109783239A
Hardware simulation method and device, equipment and storage medium
CN114428722A