- Make sure min, max, overflow instrumentation is only only on when doing analysis or conversion. If it is on during simulation, there will be a message in the Diagnostic Viewer window.
- Utilize a simulation mode other than Normal Mode. Fixed-point simulations can be much faster when using accelerator modes and rapid accelerator. Simulink Performance Advisor will help find many speed improvements including the use of accelorator modes. When you need maximum simulation speed, it is highly recommended you run Performance Advisor for all your models, fixed-point, floating-point, or any mixture.
Why is matlab fixed pint arithmetic so slow?
11 ビュー (過去 30 日間)
古いコメントを表示
I don't have a very strong FPU (no video card). I intended to accelerate my computation representing floating point numbers as 32.32 for 64-bit dwords. However, Matlab's fixed point arithmetic doesn't seem to support 64-bit numbers, and moreover, turns out to be not just not faster, but actually orders of magnitude slower than floating point.
Why? Is there any reasonable way to switch from floading point arithmetic to integer arithmetic (actually representing floating point numbers)?
0 件のコメント
回答 (1 件)
MathWorks Fixed Point Team
2020 年 8 月 31 日
編集済み: MathWorks Fixed Point Team
2020 年 8 月 31 日
Hi,
There are two aspects to speed that you may be concerned about.
The first is the speed of generated code running on your embedded chip.
The second is the speed of simulation while running MATLAB or Simulink.
For speed on the embedded device,
you want to pick data types that match what the chip's hardware supports efficiently. Among the types that are supported efficiently, you also generally want to pick the smallest type that still provides enough accuracy to pass your functional behavior.
For example on an ARM Cortex M, scalar operations are most efficiently computed on 32 bit integers. The long long 64 bit integers are about 2 to 4 times less efficient, so use them sparingly. Smaller types like 8 and 16 bit are more efficient at storage and moving memory.
As another example, a typical FPGA can efficiently do multiplies and accumulates with 18 bit and smaller inputs.
For both these example, if 64 bits where used everywhere, then it would be expected that the design would be slow and inefficient. In contrast, if the data types are reduced to just what's need to pass functional behavior test, then huge speed ups and reduced power usage can be expected.
Please check out this link for a tool that can automatically find the optimal data types for each Simulink signal in your model.
For simulation speed,
it is possible to get huge speed ups, especially for intensive behavioral testing.
In MATLAB, for intensive behavior simulations using fixed-point fi objects, it is very highly recommended to investigate fiaccel and the techniques mentioned here. Use of these techniques can increase simulation speed by 2 or 3 orders of magnitude. Note, when using fi objects in a Simulink MATLAB Function Block, you will automatically get the same benefits that fiaccel would provide.
In Simulink, significant increases in the speed of simulation can be obtained with two simple steps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Iterative Fixed-Point Conversion in Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!