VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

execution

I have 3 simulink models (.dll) assigned to different processors on my PXI-8110RT, and I have set Execution Mode to parallel. All 3 models have identical simulation time steps in Simulink, and have been set to execute at the same rate (ie. all 3 decimations set to 1). Input and output channels are mapped between the 3 models, so that they interact with one another in every time step. If one model takes longer to execute in one primary loop time, does it continue to be executed in the following primary loop cycle? What about the other two models? Will they stay synchronised?

 

My worst case CPU loading is less than 70%, but the Model Count parameter keeps increasing every now and then. What does this mean?

 

If Model A passes data to Model B (by means of channel mapping in system definition file) and I set the decimation of Model B to be 5 (Model A has decimation of 1), does it mean that Model A only passes data to Model B on every 5th primary loop cycle,  and that data from other primary loop cycles are discarded?   

0 Kudos
Message 1 of 6
(7,242 Views)

 

Hi PCT,
If you have three models, and the model doesn't complete within the specified during, it will take an additional clock cycle to complete the model.  This will mean the models are out of sync.  Furthermore, once they are out of sync, there isn't a built in way for the models to "catch up".
The increasing Model Count parameter means that the model didn't complete within the specific execution time.  Meaning the decimation of the primary control loop was insuffient time to allow the model to complete.
You are correct if Model A passes data to Model B, then the data will only be passed on the 5 iteration.
I do have a couple of questions:
1.  Are there data dependencies between all three models (meaning does model 2 depend upon the output of model 1 data in order to get the correct behavior)?
2.  What was the design decision behind parallizing the models?
If there is a data dependency between the loops there are a variety of of mechanisms to ensure correct execution, one would be to change the decimation of the PCL.  Two would be to serialize the models.
I hope this helps, let me know your thoughts related to this matter.
Regards,
A_Ryan

 

Hi PCT,

If you have three models, and the model doesn't complete within the specified time, it will take an additional clock cycle to complete the model.  For instance model 2 takes longer than period of the PCL, while model 1 and 3 complete.  On the second tick of the PCL, model 2 will finish.  On the third tick of the PCL all three models will execute once again go. See image below.

 

 

17803iF18CDC238FDC67EB



The increasing Model Count parameter means that the model didn't complete within the specific execution time.  This be could be due to a variety of things that could be identified from the Realtime Execution Trace Toolkit.

 

Furthermore, regardless of the model decimation of the PCL, if the model takes longer than one period of the PCL to execute the model count will increment and none of the models will execute.  With that being said, if you want to avoid the model count going up, you would need to adjust the PCL frequency or the time the model takes to execute.

I hope this helps, let me know if you have any additional questions related to this matter.

A_Ryan
AES
National Instruments
Message 2 of 6
(7,219 Views)

Thanks for your clear explanation.

 

I am still surprised to learn that all model execution will be delayed by one primary clock cycle regardless of decimation even if only one of the models is taking longer to execute. I have 3 models, 2 of which needs to be executed every 0.2ms and the third ones only needs to be executed every 0.4ms. The first 2 models are relatively simple and can be executed in less than 0.2ms, whilst the third one is relatively slow and takes longer than 0.2ms. If I set a primary loop time of 0.2 ms and select a decimation of 2 for the third model, the scheme will still not work since the third model takes longer than 0.2ms to execute, is this correct? Is there anything else I can do to accomodate the slow model without affecting the fast ones?

 

In your example, if I had set Execution Mode to Low Latency, does sit mean the first tick of the PCL will lengthen to accomodate model 2, and all three models will start immediately after model 2 has finished execution in the first tick of PCL?  

0 Kudos
Message 3 of 6
(7,205 Views)

Hi PCT,

 

You are correct.  There are three options to address this situation:

1. Break up the slower model into two separate parts, therefore decreasing the execution time of the slow model. 

2. Change PCL rate

3. In Simulink, you can experiment with some of the optimization techniques to see if you can decrease the model execution time.

 

With respect to the Execution Mode being set to low latency, it will effect the execution speed, and it won't get you around this situation.  With low latency, the Models execute in the PCL, therefore all of the models will wait for the slowest model one prior to executing the next clock tick of the PCL.  Furthermore, if you elect the low latency method you are going to lose the multicore capability of the Parallel Execution Method.

 

Please let me know if you have any more questions related to this matter.

A_Ryan
AES
National Instruments
0 Kudos
Message 4 of 6
(7,198 Views)

Hi A_Ryan,

 

The effect of Low Latency execution mode is still not clear to me. I thought with low latency, the PCL will be lengthened just enough to accomodate the slowest model, and the next PCL tick will start immediately  after all models have finished in the previous PCL tick. Yes, all models will be delayed slightly, but at least the delay is not integer multiples of the preset PCL time interval. Is this correct? What do you mean I will be losing multicore capability of Parallel Execution Method?

 

 

0 Kudos
Message 5 of 6
(7,184 Views)

Hi PCT,

 

You are correct, the PCL will now be dependent upon the slowest model.  The PCL operates in a single thread, therefore if you execute the model in the low latency mode, you will be isolated to a single core.

A_Ryan
AES
National Instruments
0 Kudos
Message 6 of 6
(7,140 Views)