GPU Coder - Generate CUDA code from MATLAB code - MATLAB (original) (raw)
Main Content
Generate CUDA code from MATLAB code
Description
The GPU Coder app generates CUDA® C++ code from MATLAB® code. You can generate CUDA C++ source code, static libraries, dynamically linked libraries, and executables that you can then integrate into existing CUDA C++ applications outside of MATLAB. You can also generate CUDA MEX functions for MATLAB acceleration. The GPU Coder™ app is integrated into the MATLAB desktop. You can use the app in the installed version of MATLAB and MATLAB Online™.
The app includes:
- A GPU Coder tab where you can select the output type, configure the code generator, open the Entry Points pane, generate code, and verify code.
- An Entry Points pane where you can add entry-point functions and global variables. You can define input types automatically or manually.
- A GPU Coder panel that suggests next steps. In this panel, the Input section shows the entry-point functions and global variables. The Output section shows the output from code generation. After successfully generating code, the Output section links to the generated code.
Using the app, you can:
- Generate code in MATLAB Online.
- Create a project or open an existing project. The project specifies the input files, entry-point function input types, and build configuration.
- Review code generation readiness issues, including unsupported functions.
- Switch between the MATLAB Editor and the Entry Points pane.
- Export project settings in the form of a MATLAB script.
- Access generated files.
- Package generated files as a single zip file for deployment outside of MATLAB.
- If you have an Embedded Coder® license, verify the numerical behavior of generated code using software-in-the-loop or processor-in-the-loop execution.
Open the GPU Coder App
- MATLAB Toolstrip: On the Apps tab, underCode Generation, click the app icon.
- MATLAB Command Window: Enter
gpucoder
.
Programmatic Use
Version History
Introduced in R2017b
The GPU Coder app has been redesigned to use several panes integrated into the MATLAB desktop. In previous releases, the app opened in a separate window.
The GPU Coder app is available in MATLAB Online.
By default, the GPU Coder app saves projects with the .coderprj
extension instead of a .prj
extension. If you open a GPU Coder project created in previous releases, the app saves a copy of the PRJ file as a CODERPRJ file. The app saves changes you make to the CODERPRJ file.
When opening a code generation project from a prior release, the app does not copy parameters specific to NVIDIA® Jetson™ or NVIDIA DRIVE® platforms from the PRJ file to the CODERPRJ file. If you open a project from a prior release that uses NVIDIA Jetson or NVIDIA DRIVE, verify the hardware settings before generating code.
To check for issues in generated code, use the Run Generated MEX button in the GPU Coder tab. You must provide a script that executes your entry-point functions. For more information, seeVerify Correctness of the Generated Code.
In previous releases, you verified generated CPU or GPU code using theCheck for Issues step.
The app does not support converting double-precision MATLAB code to single-precision CUDA code. Use the codegen
command with the-singleC
option instead. For more information, see Generate Single-Precision C Code at the Command Line. This option requires Fixed-Point Designer™.
The Search Paths parameter is not available in the GPU Coder app. To add additional folders to the search path, generate code using the codegen command with the-I
option.