microsoft / GSL

Guidelines Support Library
Other
6.13k stars 737 forks source link

Fix GSL_SUPPRESS definition when nvcc is in-use #1064

Closed snnn closed 1 year ago

snnn commented 1 year ago

This change is very similar to #906. It seems that nvcc compiler, though is it based on msvc, does not support this namespace.

Sample build: https://dev.azure.com/onnxruntime/onnxruntime/_build/results?buildId=802911&view=logs&j=6df8fe70-7b8f-505a-8ef0-8bf93da2bac7&t=38e4b5a4-9041-5949-6670-6ace666c420b&l=4492

Error message:

D:\a_work\1\b\RelWithDebInfo_deps\gsl-src\include\gsl\util(101,0): Error #2803-D: attribute namespace "gsl" is unrecognized

It happens only when compiling *.cu files.

The command that generated the above warning:

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe" -gencode=arch=compute_75,code=\"compute_75,compute_75\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" -x cu -ID:\a\work\1\s\include\onnxruntime -ID:\a\work\1\s\include\onnxruntime\core\session -ID:\a\work\1\b\RelWithDebInfo -ID:\a\_work\1\s\onnxruntime -I"D:\a\_work\1\b\RelWithDebInfo\_deps\abseil_cpp-src" -ID:\a\_work\1\s\cmake\external\SafeInt -ID:\a\_work\1\s\cmake\external\mp11\include -I"D:\a\_work\1\b\RelWithDebInfo\_deps\gsl-src\include" -ID:\a\_work\1\s\cmake\external\pytorch_cpuinfo\include -ID:\a\_work\1\s\cmake\external\onnx -ID:\a\_work\1\b\RelWithDebInfo\external\onnx -ID:\a\_work\1\s\cmake\external\protobuf\src -ID:\a\_work\1\s\cmake\external\flatbuffers\include -ID:\a\_work\1\s\cmake\external\eigen -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\extras\CUPTI\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" --keep-dir x64\RelWithDebInfo -maxrregcount=0 --machine 64 --compile -cudart shared --expt-relaxed-constexpr --Werror default-stream-launch -Xcudafe --diag_suppress=bad_friend_decl -Xcudafe --diag_suppress=unsigned_compare_with_zero -Xcudafe --diag_suppress=expr_has_no_effect --threads 1 -std=c++17 -Werror all-warnings -Xcompiler="/EHsc -Zi -Ob1 /utf-8 /sdl /wd4251 /wd4201 /wd5054 /w15038 /guard:cf /Qspectre /wd4251 /wd4201 /wd5054 /w15038 /wd4834 /wd4127" -D_WINDOWS -DNDEBUG -DEIGEN_USE_THREADS -DPLATFORM_WINDOWS -DNOGDI -DNOMINMAX -D_USE_MATH_DEFINES -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -DUSE_CUDA=1 -DCPUINFO_SUPPORTED_PLATFORM=1 -DONNX_NAMESPACE=onnx -DONNX_ML=1 -DONNX_USE_LITE_PROTO=1 -D\_ONNX_NO_DOC_STRINGS -DWIN32_LEAN_AND_MEAN -DEIGEN_MPL2_ONLY -DEIGEN_HAS_CONSTEXPR -DEIGEN_HAS_VARIADIC_TEMPLATES -DEIGEN_HAS_CXX11_MATH -DEIGEN_HAS_CXX11_ATOMIC -DEIGEN_STRONG_INLINE=inline -DORT_RUN_EXTERNAL_ONNX_TESTS -DENABLE_CUDA_PROFILING -DWINAPI_FAMILY=100 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DNTDDI_VERSION=0x06010000 -D"CMAKE_INTDIR=\"RelWithDebInfo\"" -Donnxruntime_providers_cuda_EXPORTS -D_WINDLL -D_MBCS -DWIN32 -D_WINDOWS -DCPUINFO_SUPPORTED -DEIGEN_HAS_C99_MATH -DNDEBUG -DEIGEN_USE_THREADS -DPLATFORM_WINDOWS -DNOGDI -DNOMINMAX -D_USE_MATH_DEFINES -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -DUSE_CUDA=1 -DCPUINFO_SUPPORTED_PLATFORM=1 -DONNX_NAMESPACE=onnx -DONNX_ML=1 -DONNX_USE_LITE_PROTO=1 -D\_ONNX_NO_DOC_STRINGS -DWIN32_LEAN_AND_MEAN -DEIGEN_MPL2_ONLY -DEIGEN_HAS_CONSTEXPR -DEIGEN_HAS_VARIADIC_TEMPLATES -DEIGEN_HAS_CXX11_MATH -DEIGEN_HAS_CXX11_ATOMIC -DEIGEN_STRONG_INLINE=inline -DORT_RUN_EXTERNAL_ONNX_TESTS -DENABLE_CUDA_PROFILING -DWINAPI_FAMILY=100 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DNTDDI_VERSION=0x06010000 -D"CMAKE_INTDIR=\"RelWithDebInfo\"" -Donnxruntime_providers_cuda_EXPORTS -Xcompiler "/EHsc /W3 /nologo /O2 /Fdonnxruntime_providers_cuda.dir\RelWithDebInfo\vc142.pdb /FS /Zi /MD /GR" -o onnxruntime_providers_cuda.dir\RelWithDebInfo\/D\/a/_work/1/s/onnxruntime/core/providers/cuda/activation/activations_impl.cu.obj "D:\a\_work\1\s\onnxruntime\core\providers\cuda\activation\activations_impl.cu"

dmitrykobets-msft commented 1 year ago

Hi @snnn, looks good, thanks for the fix!