Hauptinhalt

Ausführungsgeschwindigkeit

R2026b
Verbessern der Ausführungsgeschwindigkeit von generiertem C/C++ Code

Optimieren Sie den generierten Code im Hinblick auf Ausführungsgeschwindigkeit. Zur Erhöhung der Ausführungsgeschwindigkeit können Sie:

  • die dynamische Speicherzuweisung verändern oder deaktivieren,

  • OpenMP-fähigen Code mithilfe von parfor-Schleifen oder automatischer Parallelisierung generieren,

  • SIMD-vektorisierten Code generieren,

  • Code generieren, der optimierte externe Bibliotheken aufruft,

  • Codeersetzungsbibliotheken verwenden, um MATLAB-Funktionen während der Codegenerierung durch benutzerdefinierte, optimierte C/C++ Funktionen zu ersetzen.

Weitere Informationen zur Optimierung Ihres Codes für bestimmte Bedingungen finden Sie unter Optimize Generated C/C++ and MEX Code.

Funktionen

alle erweitern

coder.timeitMeasure execution time of generated C/C++ code (Seit R2024b)
coder.perfCompareCompare execution times of MATLAB code and code generated using multiple configuration objects (Seit R2024b)
coder.loop.interchangeInterchange loop indices in generated code (Seit R2023a)
coder.loop.parallelizeParallelize for-loops in generated code or disable automatic parallelization
coder.loop.reverseReverse loop iteration order in generated code (Seit R2023a)
coder.loop.tileTile for-loops in generated code (Seit R2023a)
coder.loop.unrollAndJamUnroll and jam for-loops in generated code (Seit R2023a)
coder.loop.vectorizeVectorize for-loops in generated code (Seit R2023a)
coder.unrollUnroll for-loop by making a copy of the loop body for each loop iteration
parforParallel for-loop
coder.inlineControl inlining of current function in generated code
coder.inlineCallInline called function in generated code (Seit R2024a)
coder.nonInlineCallPrevent inlining of called function in generated code (Seit R2024a)
coder.areUnboundedVariableSizedArraysSupportedCheck if current configuration settings allow unbounded variable-size arrays (Seit R2024a)
coder.varsizeResolve size incompatibility errors and declare upper bounds
coder.constFold expressions into constants in generated code
coder.cevalCall C/C++ function from generated code

Klassen

coder.BLASCallbackAbstract class for specifying the BLAS library and CBLAS header and data type information for BLAS calls in generated code
coder.LAPACKCallbackAbstract class for specifying the LAPACK library and LAPACKE header file for LAPACK calls in generated code
coder.fftw.StandaloneFFTW3Interface Abstract class for specifying an FFTW library for FFTW calls in generated code
coder.loop.ControlLoop optimizations in generated code (Seit R2023a)

Themen

Optimierung von generiertem Code

Optimierung von memcpy und memset

Arrays variabler Größe

Array-Layout

Schleifen

Code-Austausch

  • What Is Code Replacement?
    Why and how to replace code. Code replacement libraries that MathWorks provides. Contents of a code replacement library and how the code generator uses the contents. Terminology and limitations.
  • Choose a Code Replacement Library
    Explore available code replacement libraries and library content to find a suitable match for your code requirements.

Funktionsaufrufe

Numerische Edge Cases

Integration von externem Code

Fehlersuche

Troubleshooting parfor-Loops

Diagnose errors for code generation of parfor-loops.

Resolve Issue: coder.inline("never") and coder.nonInlineCall Do Not Prevent Function Inlining

Troubleshoot instances of coder.inline('never') not preventing inlining.

MEX Generated on macOS Platform Stays Loaded in Memory

Troubleshoot issues that occur when the source MATLAB code contains global or persistent variables that are reachable from the body of a parfor-loop.

Enthaltene Beispiele