Repository navigation
Build dpnp as C++20 - #3190
Build dpnp as C++20#3190antonwolfy wants to merge 2 commits into
Conversation
Bump CMAKE_CXX_STANDARD from 17 to 20 in the root CMakeLists.txt and in the pybind11 example, set the clang-format standard to c++20, and replace the dpnp_remove_cvref_t helper in the legacy backend with std::remove_cvref_t.
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3190/index.html |
|
Array API standard conformance tests for dpnp=0.22.0dev2=np2py314h8d9cdd5_7 ran successfully. |
| ) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD 20) |
There was a problem hiding this comment.
The installed dpnp4pybind11.hpp still compiles as C++17, but this example is its only build in CI. At C++20, nothing would catch a C++20-only change in that header, which would break C++17 extensions built against dpnp. Should the public headers stay C++17-compatible? If yes, could the example stay at C++17?
There was a problem hiding this comment.
Thanks, this is intentional: the C++20 switch applies to the shipped headers too, and is treated as a breaking change for C++ extensions built against dpnp. I updated the changelog entry and the quick start guide to say these extensions must now build as C++20, and the PR description to match. dpnp4pybind11.hpp now fails with a clear #error when compiled below C++20. The example stays at C++20 as the consumer build in CI.
Add an #error guard to dpnp4pybind11.hpp for standards below C++20, and state the requirement in the changelog entry and the quick start guide.
This PR moves the dpnp build from C++17 to C++20. DPC++ 2026.0, the minimum supported compiler, compiles SYCL kernels in C++20 mode.
CMakeLists.txtandexamples/pybind11/use_dpnp_array/CMakeLists.txt:CMAKE_CXX_STANDARDis now 20. With CMake's default extensions, icpx gets-std=gnu++20instead of-std=gnu++17..clang-format:Standard: c++20. pre-commit reformats nothing.dpnp/backend/src/dpnp_fptr.hpp: thedpnp_remove_cvref_thelper, which existed only becausestd::remove_cvref_tneeds C++20, is replaced bystd::remove_cvref_t.dpnp/libtensor/AGENTS.md: the C++ standard rule now says C++20.dpnp/include/dpnp4pybind11.hpp: an#errorguard fails the build below C++20 (checks_MSVC_LANGin MSVC mode, where__cplusplusstays199711L).doc/quick_start_guide.rst: states that extensions using the shipped headers must be compiled as C++20 or later.This is a breaking change for C++ extensions built against dpnp: the headers shipped with dpnp (
dpnp/includeanddpnp/libtensor/include) may now use C++20, so such extensions must build as C++20. The headers use no C++20 features yet, butdpnp4pybind11.hppnow stops a C++17 build with an#error, and CI no longer compiles the libtensor headers as C++17. The changelog entry and the quick start guide state the requirement.Measured with icpx 2026.2 on Linux (12 CPUs, Ubuntu 26.04), Release build, two clean builds of each with
scripts/build_locally.py:.sofilesBuild time grows by about 34 s (+3.8%). Each pybind11 extension in
dpnp/libtensorgrows by 12 to 20 KB,libdpnp_backend_c.soby 4 KB, and the Cython modules are unchanged or differ by at most 48 B.Tests with the C++20 build and with master (C++17) built the same way, run from the in-place builds:
dpnp/tests(SKIP_TENSOR_TESTS=1)dpnp/tests/tensorThe results are the same for C++17 and C++20 on both GPUs. The one failure is
test_init.py::TestImportError::test_import_error, which fails on every in-place build that isn't installed. The pybind11 example builds with-std=gnu++20and no warnings, and its 8 tests pass.On the Max 1100 (112 CPUs, Ubuntu 24.04), the clean build takes 655 s with C++17 and 658 s with C++20, and the
.sofiles grow by 211 KB (+0.11%). That host gives the same 18-Wgcc-install-dir-libstdcxxdriver warnings with both standards, about its GCC 13/14 install layout.Not checked locally: CUDA and HIP targets (no CUDA/HIP SYCL plugins on the hosts) and Windows. The open-source LLVM SYCL, conda-forge and Windows builds run in this PR's CI.