320 likes | 899 Views
PC deployment solutions of MATLAB-based applications – MATLAB Compiler vs. MATLAB Coder. Michael Donnenfeld Roy Fahn Application Engineer Application Engineer. Agenda. Mathworks tools for PC deployment - overview MATLAB Compiler vs. MATLAB Coder
E N D
PC deployment solutions of MATLAB-based applications – MATLAB Compiler vs. MATLAB Coder Michael Donnenfeld Roy Fahn Application Engineer Application Engineer
Agenda • Mathworks tools for PC deployment - overview • MATLAB Compiler vs. MATLAB Coder • MATLAB Compiler Deployment and GPU solution • Retinal Blood Vessel Extraction Using Kirsch's Templates • Speeding-Up Image Processing Applications using the GPU • Break • C code generation using MATLAB Coder • MATLAB Coder flow • Signal processing example • System Objects overview • Embedded coder features
הצטרפו לכנס ראשון מסוגו, במהלכו תוכלו: • להרחיב את ידיעותיכם על השימוש בכלי MATLAB ו-Simulink • להחליף רעיונות, לשתף בסיפורי הצלחה של עמיתים, ולהיפגש עם מומחי MATLAB מחברות אחרות • לחלוק את חוויית העבודה שלכם בסביבת MATLAB http://tinyurl.com/nozbmyt OR: http://www.systematics.co.il/MathWorks/Events/Conference/2013/MWUserConf-CFP01.html
MATLAB Compiler vs. MATLAB Coder fetal_ecg.m
MATLABCoder MATLABCompiler fetal_ecg.m .dll .exe .lib .lib .dll .exe
Choosing the Right Deployment SolutionMATLAB Coder and MATLAB Compiler MATLAB Coder MATLAB Compiler
MATLAB Coder generates embeddable C-code directly and automatically from M-Code What is Supported for code generation? • A subset of MATLAB language • More than 400 MATLAB operators and functions • More than 100 Fixed-point toolbox functions • More than 200 functions from signal processing video/image processing and communication (Some available as System Objects with the new System Toolboxes) Supported for codegen MATLAB
Fixed-Point Toolbox What is not supported? MATLAB visualization Communication System Toolbox variable-sized data File I/O functions struct java malloc numeric Sparse global sparse System objects Visualization cell arrays complex arrays fixed-point Cell Computer Vision Toolbox recursion persistent nested functions try-catch classes Object Oriented nested functions Recursion anonymous functions DSP System toolbox
Using MATLAB Coder • 3. Generate C or C++ source code • Iterate in MATLAB to optimize . .DLL • 1. Develop/prepare MATLAB code • Separate algorithm code from other code • Use supported language features • Make implementation choices (e.g., data types, memory allocation) • 2. Execute generated code in MATLAB • Validate that MATLAB program generates code • Accelerate execution of user-written algorithm
How MATLAB Coder Accelerates Development .DLL .DLL Develop algorithm Test Convert to C/C++ Test Iterate Test Deploy Time savings Develop algorithm Test and Iterate Test Deploy Generate code
Adaptive Noise Canceling (ANC) Applied to Fetal Electrocardiography
Fetal ECG Referenced signal: maternal thorax ECG Error signal: fetal ECG Noisy signal: maternal abdominal ECG Adaptive filter
Lets go to example…… C Code
System Objects MATLAB objects that represent time-based and data-driven algorithms, sources, and sinks • Simplify streaming in MATLAB • Provide more algorithms in MATLAB • Support of fixed-point data types • Generate C code automatically
System Objects Two functionally-equivalent options • >> X = fft(x,1024) • >> hfft = dsp.FFT(‘BitReversedOutput’,true); • … • >> X = hfft.step(x);
System Objects persistent hfft ; % instatiate if isempty(hfft) hfft = dsp.FFT(‘BitReversedOutput’,true); end % iteratively process streamed data while(…) … % process hfftData = hfft.step(data); … end • Separate instantiation and runtime calls • Call compiled object code
System Objects Where can System Objects be found? Video and Image Processing Blockset Communications Toolbox Communication System Toolbox Phased Array System Toolbox Computer Vision System Toolbox Communications Blockset Signal Processing Blockset DSP System Toolbox Image Processing Toolbox Filter Design Toolbox Signal Processing Toolbox • Learn more: Designing Signal Processing Systems with MATLAB (online webinar)
Code Optimization – Cont. Embedded Coder features: • Target Code Replacement Libraries (CRL) for embedded targets • Generate reentrant code • Customize the code style such as defining name rules for variables • Links between C-code and MATLAB code for better traceability
What’s new R2012 • Code Generation for MATLAB Classes • Selective Dynamic Memory Allocation Based on Size • C/C++ Dynamic Library Generation (DLL) • Package generated code in zip file for relocation (packNGo command) • parfor function support for MEX code generation, enabling execution on multiple cores • Visualization functions in generated MEX functions
What’s new R2013 • Code generation support for Statistics Toolbox and Phased Array System Toolbox • parfor function support for standalone code generation, enabling execution on multiple cores • Generation of simplified code using built-in C types • Change to passing structures by reference (Entry Point function) • Code Generation Support for int64, uint64 data types • Custom toolchain registration
לסיום אתר סיסטמטיקס – סמינרים, קורסים ועוד MATLAB CENTRAL תמיכה מלאה ע"י חברת סיסטמטיקס 03-7660101 תודה על השתתפותכם!
MathWorks Code Generation Products: Old and New MATLAB Coder New features Embedded MATLAB feature of Real-Time Workshop Simulink Coder Real-Time Workshop Stateflow Coder Embedded IDE Link Embedded Coder Real-Time Workshop Embedded Coder Target Support Package