当前位置:网站首页>SystemC simulation scheduling mechanism

SystemC simulation scheduling mechanism

2022-06-12 13:55:00 123axj

By default , We directly use the CMake Compilation parameter compilation .so file , So we are running a SystemC When it comes to programming , Even if there are many in the code SC_THREAD / SC_METHOD Registration function for , You will also find that the program only occupies one physical CPU core.

If we compile enable 了 SC_USE_PTHREADS This macro , There will be different phenomena : every last SC_THREAD / SC_METHOD Will create a CPU Threads ; But this situation has a great impact on our simulation speed , When in our code SC_THREAD / SC_METHOD Especially when , It will seriously slow down our simulation speed , because SystemC kernel Scheduling of these threads The cost of CPU Time It's far beyond The parallel effect of multithreading . So in general , We all will disable SC_USE_PTHREADS This macro . The following is for SystemC The explanation of the scheduling mechanism also defaults that this macro is not opened .

Synopsys The company's VDK (Virtualizer Development Kit,Virtualizer Development Kit (VDK) ) The software integrates a method that can realize real parallel multi CPU Solutions for physical thread execution , This scheme is applicable to DSP 、AI There are many data processing functions such as chips 、 There are many cores SystemC module Quite friendly , Can greatly improve module Simulation speed of .

Elaboration and Simulation Phases are executed serially .

Simulation Stage , In a certain SystemC Simulation time point ,SystemC kernel Will call each one in turn SC_THREAD correlation function , Will look at each SC_METHOD Whether the sensitive event of is triggered .

In calling a SC_THREAD When associating functions , It is equivalent to that the procedural control is temporarily controlled by SystemC kernel Transfer to this function , The function will always execute , Until you encounter explicit or implicit wait call , This function is suspended , Then the control of the program turns back to SystemC kernel;SystemC kernel Then start calling the next SC_THREAD correlation function .SC_THREAD The starting point of the correlation function needs to be recorded , next SystemC Simulation moment ,SystemC kernel When you call this function again , Execute from the last hanging point . If wait The event was triggered , or wait Of ( SystemC Simulation ) Time has come to , You can jump out of wait, So let's keep going , Until I met wait Suspended again .

SC_METHOD By SystemC kernel The scheduling process is relatively simple : Look at this. SC_METHOD Whether the corresponding sensitive event is triggered , Triggered , Execute the correlation function completely once , Otherwise, we will not deal with it . because SC_METHOD Cannot have... In the correlation function of wait, therefore SystemC Simulation time does not advance .

SystemC kernel Dispatch SC_THREAD The specific process of the correlation function is complex , For details, please refer to spec Medium 4.2 Simulation chapter , Specific for evaluation 、update、delta notification 、timed notification phase. Here are spec Some key statements in .

From the set of runnable processes, select a process instance, remove it from the set, and only then trigger or resume its execution. Run the process instance immediately and without interruption up to the point where it either returns or, in the case of a thread or clocked thread process, calls the function wait or calls the member function suspend of a process handle associated with the process instance itself.

Since process instances execute without interruption, only a single process instance can be running at any one time, and no other process instance can execute until the currently executing process instance has yielded control to the kernel. A process shall not pre-empt or interrupt the execution of another process. This is known as co-routine semantics or co-operative multitasking.

Repeat this step(evaluation phase) until the set of runnable processes is empty; then go on to the update phase.

If, at the end of the delta notification phase, the set of runnable processes is non-empty, go back to the evaluation phase.

From can run processes Select a process instance in the collection , Remove it from the collection , Then trigger or resume its execution . Run the process instance now , And without interruption , Until the instance returns or ( In the case of threads or threaded processes with clocks ) Call the function of the process handle associated with the process instance itself wait Or member functions suspend until .

Because process instances execute without interruption , Therefore, only one process instance can be run at any time , And before the currently executing process instance hands control to the kernel , Other process instances cannot be executed . One process cannot preempt or interrupt the execution of another process . This is called collaborative routine semantics or cooperative multitasking .

SystemC Execution process , Need to prevent because Problems caused by scheduling sequence .

Because the order in which processes are run within the evaluation phase is not under the control of the application, access to shared storage should be explicitly synchronized to avoid non-deterministic behavior.

原网站

版权声明
本文为[123axj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010514261033.html