How can one configure mex to pass compiler flags to nvcc

自古美人都是妖i 提交于 2019-12-11 11:52:15

问题


While compiling mex files with nvcc I have struggled to pass compiler options specific to CUDA to the nvcc compiler, as mex doesn't recognize them.

I found some old posts about passing compiler flags and some newer ones, but the questions are quite user-specific, and the mex compiler has changed over the years, so I cant figure out what to do.

So, my specific question: What should I do to make mex pass compiler flags to nvcc?

A bit more generic: What should one do to make mex pass compiler flags to another compiler?


回答1:


If working with the newest compiling way where the options are in an xml file, one can hardcode the default compile flags in there. For example mine looks like:

COMPILER="nvcc"
      COMPFLAGS="-gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=\"sm_50,compute_50\" --compiler-options=/c,/GR,/W3,/EHs,/nologo,/MD"
      COMPDEFINES="--compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,$MATLABMEX"
      MATLABMEX="/DMATLAB_MEX_FILE"
      OPTIMFLAGS="--compiler-options=/O2,/Oy-,/DNDEBUG"
      INCLUDE="-I"$MATLABROOT\extern\include" -I"$MATLABROOT\simulink\include""

  DEBUGFLAGS="--compiler-options=/Z7"

One can change the defaults modifiying COMPFLAGS



来源:https://stackoverflow.com/questions/33366169/how-can-one-configure-mex-to-pass-compiler-flags-to-nvcc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!