Skip to content

Build dpnp as C++20 - #3190

Open
antonwolfy wants to merge 1 commit into
masterfrom
build-as-cxx20
Open

antonwolfy wants to merge 1 commit into
masterfrom
build-as-cxx20

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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.txt and examples/pybind11/use_dpnp_array/CMakeLists.txt: CMAKE_CXX_STANDARD is now 20. With CMake's default extensions, icpx gets -std=gnu++20 instead of -std=gnu++17.
  • .clang-format: Standard: c++20. pre-commit reformats nothing.
  • dpnp/backend/src/dpnp_fptr.hpp: the dpnp_remove_cvref_t helper, which existed only because std::remove_cvref_t needs C++20, is replaced by std::remove_cvref_t.
  • dpnp/libtensor/AGENTS.md: the C++ standard rule now says C++20.

The libtensor headers shipped with dpnp are unchanged and use no C++20 features yet, so extensions that include them and build as C++17 keep working.

Measured with icpx 2026.2 on Linux (12 CPUs, Ubuntu 26.04), Release build, two clean builds of each with scripts/build_locally.py:

C++17 (master) C++20
Build time, run 1 888 s 926 s
Build time, run 2 891 s 921 s
Peak RSS of a single process 3.56 GB 3.56 GB
Compiler warnings 0 0
Total size of the 24 .so files 194,067,928 B 194,289,104 B (+221 KB, +0.11%)

Build time grows by about 34 s (+3.8%). Each pybind11 extension in dpnp/libtensor grows by 12 to 20 KB, libdpnp_backend_c.so by 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:

Host, device dpnp/tests (SKIP_TENSOR_TESTS=1) dpnp/tests/tensor
Panther Lake H, OpenCL CPU (C++20 only) 80583 passed, 7017 skipped, 1 failed 15533 passed
Panther Lake H, Arc B370 (fp64), Level Zero 80564 passed, 7036 skipped, 1 failed 15532 passed (serial run; 4 xdist workers run out of the shared 14 GB on this iGPU with either standard)
Data Center GPU Max 1100, Level Zero 82567 passed, 5033 skipped, 1 failed 15532 passed

The 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++20 and 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 .so files grow by 211 KB (+0.11%). That host gives the same 18 -Wgcc-install-dir-libstdcxx driver 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.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

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.
@github-actions

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/3190/index.html

@github-actions

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.22.0dev2=np2py314h8d9cdd5_7 ran successfully.
Passed: 1491
Failed: 0
Skipped: 6

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 84.269%. remained the same — build-as-cxx20 into master

)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants