GPU coder configured for MinGW-w64 C/C++/Fortran compiler passes invalid options to nvcc. How to remove?

5 views (last 30 days)
Passing MATLAB code to GPU coder (v24.02) fails while building MEX as the build script invokes nvcc with bare options like "-Wno-stringop-overflow", which I'm guessing should be "-Xcompiler -Wno-stringop-overflow" as nvcc (v12.8) does not accept the warning disabling options but g++ does. From settings or coder.gpuConfig, I can only add compiler flags, but how do I remove or change the build script to correct the options/flags sent to nvcc?

Answers (1)

Nathaniel
Nathaniel on 6 Feb 2025
Edited: Nathaniel on 6 Feb 2025
Hey Jeffrey,
I see you're using GPU Coder with MinGW to build MEX, and the compiler is receiving some invalid options. Please note that GPU Coder does not support MinGW. It only supports using the Microsoft Visual C/C++ compiler. See the supported compilers for GPU Coder in R2024b here:
GPU Coder uses CUDA version 12.2 to build MEX in R2024b, so the compiler should be compatible with CUDA 12.2. This version of CUDA supports both Visual Studio 2017 or 2019. See Visual Studio Older Downloads to get Visual Studio 2017 or 2019.
You can also use Microsoft Visual Studio 2022, but CUDA 12.2 only supports Visual Studio 2022 version 17.0.
Is Visual C/C++ available to you? If you have it installed, you can enter mex -setup C++ in the MATLAB command line to select the Visual C/C++ compiler.
Thanks,
Nathaniel
  2 Comments
Jeffrey
Jeffrey on 6 Feb 2025
First, thanks for your response. I understand that it is not officially supported in MinGW environment, but the issue is not necessarily anything specific with MinGW environment but with the MEX build configuration. MEX does support MinGW and both support GCC in the Linux environment where the MEX build in GPU Coder makes the same calls to nvcc and correctly passes the flags to g++.
There are .yaml config files for MEX where the flags passed to the compiler can be modified, but it does not look like GPU coder uses them as they are hard-coded for g++ and not nvcc. To make my question more explicit and regardless of the particular versions Visual Studio or MEX, does MATLAB GPU Coder have a similar config file anywhere where the compiler flags passed to nvcc can be removed or at least modified in place?
I can see how I can add flags in the settings, but I need to insert flags in a particular position in the call or remove them. The UI interface does not allow this.
Chao Luo
Chao Luo on 7 Feb 2025
Hi Jeffrey,
Many flags are hardcoded and cannot be removed using config files. You can modify the genearted build.ninja to remove the flags in the codegen folder. You can run !YouFcn_mex.bat to recompile the generated code.
However, even if you removed the unsupported flags, the compilation would still fail since NVCC would error out complaining cl.exe not found.

Sign in to comment.

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!