Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation of oneDNN with C++20 on Windows #2028

Closed
ilya-lavrenov opened this issue Aug 7, 2024 · 4 comments
Closed

Fix compilation of oneDNN with C++20 on Windows #2028

ilya-lavrenov opened this issue Aug 7, 2024 · 4 comments
Assignees
Labels
bug A confirmed library bug
Milestone

Comments

@ilya-lavrenov
Copy link
Contributor

ilya-lavrenov commented Aug 7, 2024

Summary

oneDNN and some software which uses it (e.g. OpenVINO), are distributed as source code.
And some users may want to compile it with their own C++ standard and compile flags.

Problem statement

oneDNN with GPU backend enabled cannot be compiled with C++ 20 with MSVC compiler.
Build logs are https://github.com/openvinotoolkit/openvino/actions/runs/10289707118/job/28478073165

Problematic place https://github.com/oneapi-src/oneDNN/blob/main/src/gpu/intel/jit/gemm/include/internal/utils.hpp#L22 - __cplusplus is defined to 1997 value for MSVC compiler.

Preferred solution

Please, enable C++20 support om compilation level.

@ilya-lavrenov ilya-lavrenov added the enhancement A feature or an optimization request label Aug 7, 2024
@vpirogov
Copy link
Member

vpirogov commented Aug 8, 2024

oneDNN should be buildable with C++ 20, so this looks like a bug. Relevant error message:

ccache C:\BuildTools\VC\Tools\MSVC\14.40.33807\bin\Hostx64\x64\cl.exe  /nologo /TP -DCL_TARGET_OPENCL_VERSION=200 -DDNNL_DLL -DDNNL_DLL_EXPORTS -DDNNL_ENABLE_CPU_ISA_HINTS -DDNNL_ENABLE_MAX_CPU_ISA -DDNNL_X64=1 -DENABLE_ONEDNN_FOR_GPU -DIN_OV_COMPONENT -DNGEN_CPP11 -DNGEN_NEO_INTERFACE -DNGEN_NO_OP_NAMES -DNGEN_SAFE -DNGEN_WINDOWS_COMPAT -DOPENVINO_STATIC_LIBRARY -DOV_BUILD_POSTFIX=\"\" -DOV_GPU_OPENCL_HPP_HAS_UUID -DOV_GPU_USE_OPENCL_HPP -DOV_NATIVE_PARENT_PROJECT_ROOT_DIR=\"openvino\" -DOV_THREAD=OV_THREAD_TBB -DTBB_PREVIEW_WAITING_FOR_WORKERS=1 -DCMAKE_INTDIR=\"Release\" -IC:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\src\kernel_selector -IC:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\src\kernel_selector\kernels -IC:\actions-runner\_work\openvino\openvino\openvino_build\src\plugins\intel_gpu\src\kernel_selector\codegen\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty -IC:\actions-runner\_work\openvino\openvino\openvino_build\src\plugins\intel_gpu\thirdparty\onednn_gpu_install\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src -IC:\actions-runner\_work\openvino\openvino\openvino\thirdparty\ocl\cl_headers -IC:\actions-runner\_work\openvino\openvino\openvino\thirdparty\ocl\clhpp_headers\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\core\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\frontends\common\include -IC:\actions-runner\_work\openvino\openvino\openvino\src\inference\include /DWIN32 /D_WINDOWS /GR /EHsc /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /EHsc /Gy /W3 /bigobj /MP /wd4251 /wd4275 /wd4996 /wd4244 /wd4018 /O2 /Ob2 /DNDEBUG  /sdl /guard:cf /wd4996 -std:c++20 -MD /Os -WX /showIncludes /Fosrc\plugins\intel_gpu\src\kernel_selector\CMakeFiles\openvino_intel_gpu_kernels.dir\Release\kernel_selector_common.cpp.obj /FdC:\actions-runner\_work\openvino\openvino\openvino\bin\intel64\Release\ /FS -c C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\src\kernel_selector\kernel_selector_common.cpp
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2039: 'source_location': is not a member of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\common\primitive_hashing.hpp(138): note: see declaration of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(93): error C3829: attribute [[noreturn]] may only be applied to a function declaration
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(93): error C2182: 'stub': this use of 'void' is not valid
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2065: 'source_location': undeclared identifier
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2146: syntax error: missing ')' before identifier 'where'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C3083: 'source_location': the symbol to the left of a '::' must be a type
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2039: 'current': is not a member of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\common\primitive_hashing.hpp(138): note: see declaration of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2143: syntax error: missing ';' before '{'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(94): error C2447: '{': missing function header (old-style formal list?)
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(99): error C2039: 'source_location': is not a member of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\common\primitive_hashing.hpp(138): note: see declaration of 'std'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(99): error C2061: syntax error: identifier 'source_location'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(98): error C2365: 'dnnl::impl::gpu::intel::jit::stub': redefinition; previous definition was 'data variable'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(93): note: see declaration of 'dnnl::impl::gpu::intel::jit::stub'
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(100): error C2065: 'where': undeclared identifier
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu/intel/jit/gemm/utils.hpp(100): error C2065: 'where': undeclared identifier
C:\actions-runner\_work\openvino\openvino\openvino\src\plugins\intel_gpu\thirdparty\onednn_gpu\src\gpu\intel\jit\gemm\gen_gemm_kernel_generator.hpp(123): error C2064: term does not evaluate to a function taking 0 arguments

+@rjoursler, @petercad

@vpirogov vpirogov added bug A confirmed library bug and removed enhancement A feature or an optimization request labels Aug 8, 2024
@petercad
Copy link
Contributor

petercad commented Aug 8, 2024

@rjoursler Looks like this line needs to take into account __cplusplus.

@vpirogov vpirogov added this to the v3.6 milestone Aug 8, 2024
@rjoursler rjoursler self-assigned this Aug 8, 2024
@ilya-lavrenov
Copy link
Contributor Author

ilya-lavrenov commented Aug 8, 2024

@rjoursler Looks like this line needs to take into account __cplusplus.

No, as I stated in the description:

Problematic place https://github.com/oneapi-src/oneDNN/blob/main/src/gpu/intel/jit/gemm/include/internal/utils.hpp#L22 - __cplusplus is defined to 1997 value for MSVC compiler.

You need to rely on _MSVC_LANG for MSVC compiler instead of __cplusplus

WA on OpenVINO side is to use https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170, but we want to avoid it.

@rjoursler
Copy link
Contributor

This should be fixed by commit ece6802, @ilya-lavrenov could you please confirm this issue is fully resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A confirmed library bug
Projects
None yet
Development

No branches or pull requests

4 participants