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

8 次查看(过去 30 天)
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?

回答(1 个)

Nathaniel
Nathaniel 2025-2-6
编辑:Nathaniel 2025-2-6
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 个评论
Jeffrey
Jeffrey 2025-2-6
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 2025-2-7
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with GPU Coder 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by