02-01-2011 09:06 AM
Hi,
I am running a model at 5 kHz rate in a core 2 quad computer at 2.6 GHz.
If I set Execution mode to "parallel" the model count increases fast but the model rate keeps at 5 kHz.
Changing Execution mode to "Low latency" the model count stays in 0, model rate goes to 2.5 kHz and HP Count increases.
The total CPU allocation of each core never goes above 58% in "Low latency" but reaches 98 % in "Parallel".
I tried several combinations of core allocations (auto / manual) for the loops and model but the main factor is always Execution mode.
I observed that, when using Low latency, the HP loop duration reaches 218000 ns that explains why the model rate drops.
Is there some other setting that I can use to let the system without overruns?
Cheers,
Claudio H.
Solved! Go to Solution.
02-02-2011 10:05 AM
Hi,
More information to help.
There are 3 files:
- PackScrPause.txt: it shows the CPU occupation while the model is paused.
- PackScrRun.txt: it shows the CPU when the model is running.
- Exec_Mdl.jpg: a application print screen with same information.
Cheers,
Cláudio H.
02-03-2011 05:12 AM
Hi Claudio,
Changing the execution mode between Parallel and Low-Latency won't actually make your model run any faster, it just affects whether the Primary Control Loop waits for the model loop(s) to finish. In Parallel mode, the model loops run in parallel with the PCL, which introduces a 1 tick delay but allows you to take better advantage of multicore systems. In Low-Latency mode, the models essentially run inside the PCL, which eliminates the 1 tick delay but causes the PCL to wait for models to complete before moving on. This is why you see the Model Count loop increase in Parallel mode, but the HP Count increase in Low-Latency mode. The cause for both is the same: your model is not able to complete in the 200 us (5 kHz) that you are trying to run your system at.
However, looking at your numbers, it seems like you are almost making the 5kHz rate, so there may be something you can do to squeeze out a bit of extra performance. Take a look at your BIOS settings on your computer and see whether there is anything you can disable that could increase your performance or reduce jitter (such as setting Legacy USB support to auto/disabled). You can also try switching between interrupt and polling mode for your network adaptor in Measurement and Automation Explorer.
It sounds like the CPU usage is primarily due to your one large model, with the rest of the system adding only a minimal amount of proccesing. This makes it difficult to move things around on the cores and realize any perfomance increases. If you are able to split your large model up into multiple smaller models (and map them together in System Explorer), you could then run different parts of the model on different cores and probably meet your desired 5kHz rate. This obviously will take some work by whoever created the model, but it may be worth it in order to take advantage of your quad core system.
Another possibility, if you want to keep it as one big model, may be to disable some of the cores on your system. Some processors will be able to take advantage of higher clock speeds if cores are disabled. For example, our PXIe-8133 controller, which has an Intel Core i7-820 processor, runs at 1.73 GHz on 4 cores. However, if you disable 2 of the cores in the BIOS you can run at 2.8 GHz, and moving down to a single core will yield a max 3.06 GHz. If your system is capable of something similar, you could maybe move down to 2 cores and have the PCL running on core 0 and your model running on core 1.
02-03-2011 06:12 AM
Hi Devin,
Ok, I understood your explanation but is there any compiler optimization that can speed-up the model?
We are using a desktop PC hardware as RT target. I will check what I can do in the BIOS but if we have something to do with during code generation it would be more productive.
Cheers,
Cláudio H.
02-03-2011 12:07 PM
Hi Devin,
We simplified the model and got better CPU occupation when running in "Parallel" mode (49%) but we still have the model count increasing.
What is causing this (low CPU and model overrun)?
Is there any way to measure the model loop duration?
I set to "Low Latency" but allocate different CPUs for Main Loop and Model loop and got model and HP count increasing.
Cheers,
Cláudio H.
02-03-2011 01:05 PM
Hi,
I found this comment in the NI makefile:
#----------------- Compiler and Linker Options --------------------------------
# Optimization Options
!if "$(NIOPT)" == "Default"
OPT_OPTS = $(DEFAULT_OPT_OPTS)
!elseif "$(NIOPT)" == "Favor fast code"
# We see a performance hit with /Oi, so we don't use /O2 which uses it
OPT_OPTS = /Og /Oy /Ob1 /Gs /GF /Gy /Ot
!elseif "$(NIOPT)" == "Favor small code"
OPT_OPTS = /O1
!elseif "$(NIOPT)" == "None"
OPT_OPTS =
!endif
How can I set "Favor fast code" in simulink?
Cheers,
Cláudio H.
02-04-2011 04:33 AM
Hi,
I manage to include the optimization options during the code generation.
In Simulation > Configuration parameters > RealTime Workshop > NI Configuration > Compiler optimizations I set to "Favor fast code" and got:
- dll size from 452 kb to 404 kb
- Model Loop CPU occupation from 98% to 82%
- Control loop from 7 % to 23 %
- Data loop from 8 % to 49 %
- Model count from fast growing to very slow.
It looks that now the model is running more time and Control Loop and Data Loop have more job.
We will work in the model to make it simplest we can.
Cheers.