Skip to content

Commit 38370a8

Browse files
andriishAndrii VerbytskyihenryiiiAndrii Verbytskyi
authored
fix: support NVIDIA-PGI HPC SDK (#2475)
* Added guards to the includes Added new CI config Added new trigger Changed CI workflow name Debug CI Debug CI Debug CI Debug CI Added flags fro PGI Disable Eigen Removed tests that fail Uncomment lines * fix: missing include fix: minor style cleanup tests: support skipping ci: remove and tighten a bit fix: try msvc workaround for pgic * tests: split up prealoc tests * fix: PGI compiler fix * fix: PGI void_t only * fix: try to appease nvcc * ci: better ordering for slow tests * ci: minor improvements to testing * ci: Add NumPy to testing * ci: Eigen generates CUDA warnings / PGI errors * Added CentOS7 back for a moment * Fix YAML * ci: runs-on missing * centos7 is missing pytest * ci: use C++11 on CentOS 7 * ci: test something else * Try just adding flags on CentOS 7 * fix: CentOS 7 * refactor: move include to shared location * Added verbose flag * Try to use system cmake3 on CI * Try to use system cmake3 on CI, attempt2 * Try to use system cmake3 on CI, attempt3 * tests: not finding pytest should be a warning, not a fatal error * tests: cleanup * Weird issue? * fix: final polish Co-authored-by: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Andrii Verbytskyi <averbyts@cern.ch>
1 parent fe9ee86 commit 38370a8

File tree

11 files changed

+222
-48
lines changed

11 files changed

+222
-48
lines changed

.github/CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,29 @@ name, pre-commit):
164164
pre-commit install
165165
```
166166

167+
### Build recipes
168+
169+
This builds with the Intel compiler (assuming it is in your path, along with a
170+
recent CMake and Python 3):
171+
172+
```bash
173+
python3 -m venv venv
174+
. venv/bin/activate
175+
pip install pytest
176+
cmake -S . -B build-intel -DCMAKE_CXX_COMPILER=$(which icpc) -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DPYBIND11_WERROR=ON
177+
```
178+
179+
This will test the PGI compilers:
180+
181+
```bash
182+
docker run --rm -it -v $PWD:/pybind11 nvcr.io/hpc/pgi-compilers:ce
183+
apt-get update && apt-get install -y python3-dev python3-pip python3-pytest
184+
wget -qO- "https://cmake.org/files/v3.18/cmake-3.18.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
185+
cmake -S pybind11/ -B build
186+
cmake --build build
187+
```
188+
189+
167190
[pre-commit]: https://pre-commit.com
168191
[pybind11.readthedocs.org]: http://pybind11.readthedocs.org/en/latest
169192
[issue tracker]: https://github.com/pybind/pybind11/issues

.github/workflows/ci.yml

Lines changed: 109 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ jobs:
6969
python: 3.9-dev
7070
arch: x64
7171

72-
7372
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • ${{ matrix.arch }} ${{ matrix.args }}"
7473
runs-on: ${{ matrix.runs-on }}
7574
continue-on-error: ${{ endsWith(matrix.python, 'dev') }}
@@ -196,6 +195,114 @@ jobs:
196195
- name: Interface test
197196
run: cmake --build build --target test_cmake_build
198197

198+
199+
cuda:
200+
runs-on: ubuntu-latest
201+
name: "🐍 3.8 • CUDA 11 • Ubuntu 20.04"
202+
container: nvidia/cuda:11.0-devel-ubuntu20.04
203+
204+
steps:
205+
- uses: actions/checkout@v2
206+
207+
# tzdata will try to ask for the timezone, so set the DEBIAN_FRONTEND
208+
- name: Install 🐍 3
209+
run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake git python3-dev python3-pytest python3-numpy
210+
211+
- name: Configure
212+
run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
213+
214+
- name: Build
215+
run: cmake --build build -j2 --verbose
216+
217+
- name: Python tests
218+
run: cmake --build build --target pytest
219+
220+
221+
centos-nvhpc8:
222+
runs-on: ubuntu-latest
223+
name: "🐍 3 • CentOS8 / PGI 20.7 • x64"
224+
container: centos:8
225+
226+
steps:
227+
- uses: actions/checkout@v2
228+
229+
- name: Add Python 3 and a few requirements
230+
run: yum update -y && yum install -y git python3-devel python3-numpy python3-pytest make environment-modules
231+
232+
- name: Install CMake with pip
233+
run: |
234+
python3 -m pip install --upgrade pip
235+
python3 -m pip install cmake --prefer-binary
236+
237+
- name: Install NVidia HPC SDK
238+
run: yum -y install https://developer.download.nvidia.com/hpc-sdk/nvhpc-20-7-20.7-1.x86_64.rpm https://developer.download.nvidia.com/hpc-sdk/nvhpc-2020-20.7-1.x86_64.rpm
239+
240+
- name: Configure
241+
shell: bash
242+
run: |
243+
source /etc/profile.d/modules.sh
244+
module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.7
245+
cmake -S . -B build -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=14 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
246+
247+
- name: Build
248+
run: cmake --build build -j 2 --verbose
249+
250+
- name: Python tests
251+
run: cmake --build build --target pytest
252+
253+
- name: C++ tests
254+
run: cmake --build build --target cpptest
255+
256+
- name: Interface test
257+
run: cmake --build build --target test_cmake_build
258+
259+
centos-nvhpc7:
260+
runs-on: ubuntu-latest
261+
name: "🐍 3 • CentOS7 / PGI 20.7 • x64"
262+
container: centos:7
263+
264+
steps:
265+
- uses: actions/checkout@v2
266+
267+
- name: Add Python 3 and a few requirements
268+
run: yum update -y && yum install -y epel-release && yum install -y git python3-devel make environment-modules cmake3
269+
270+
- name: Install NVidia HPC SDK
271+
run: yum -y install https://developer.download.nvidia.com/hpc-sdk/nvhpc-20-7-20.7-1.x86_64.rpm https://developer.download.nvidia.com/hpc-sdk/nvhpc-2020-20.7-1.x86_64.rpm
272+
273+
# On CentOS 7, we have to filter a few tests (compiler internal error)
274+
# and allow deeper templete recursion (not needed on CentOS 8 with a newer
275+
# standard library). On some systems, you many need further workarounds:
276+
# https://github.com/pybind/pybind11/pull/2475
277+
- name: Configure
278+
shell: bash
279+
run: |
280+
source /etc/profile.d/modules.sh
281+
module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.7
282+
cmake3 -S . -B build -DDOWNLOAD_CATCH=ON \
283+
-DCMAKE_CXX_STANDARD=11 \
284+
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
285+
-DCMAKE_CXX_FLAGS="-Wc,--pending_instantiations=0" \
286+
-DPYBIND11_TEST_FILTER="test_smart_ptr.cpp;test_virtual_functions.cpp"
287+
288+
# Building before installing Pip should produce a warning but not an error
289+
- name: Build
290+
run: cmake3 --build build -j 2 --verbose
291+
292+
- name: Install CMake with pip
293+
run: |
294+
python3 -m pip install --upgrade pip
295+
python3 -m pip install pytest
296+
297+
- name: Python tests
298+
run: cmake3 --build build --target pytest
299+
300+
- name: C++ tests
301+
run: cmake3 --build build --target cpptest
302+
303+
- name: Interface test
304+
run: cmake3 --build build --target test_cmake_build
305+
199306
gcc:
200307
runs-on: ubuntu-latest
201308
strategy:
@@ -243,6 +350,7 @@ jobs:
243350
- name: Interface test
244351
run: cmake --build build --target test_cmake_build
245352

353+
246354
centos:
247355
runs-on: ubuntu-latest
248356
strategy:
@@ -289,27 +397,6 @@ jobs:
289397
- name: Interface test
290398
run: cmake --build build --target test_cmake_build
291399

292-
cuda:
293-
runs-on: ubuntu-latest
294-
name: "🐍 3.8 • CUDA 11 • Ubuntu 20.04"
295-
container: nvidia/cuda:11.0-devel-ubuntu20.04
296-
297-
steps:
298-
- uses: actions/checkout@v2
299-
300-
# tzdata will try to ask for the timezone, so set the DEBIAN_FRONTEND
301-
- name: Install 🐍 3
302-
run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake python3-dev python3-pytest
303-
304-
- name: Configure
305-
run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
306-
307-
- name: Build
308-
run: cmake --build build -j2 -v
309-
310-
- name: Python tests
311-
run: cmake --build build --target pytest
312-
313400

314401
install-classic:
315402
name: "🐍 3.5 • Debian • x86 • Install"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ In addition to the core functionality, pybind11 provides some extra goodies:
9999
v2.0 and a [workaround][intel-15-workaround])
100100
5. Cygwin/GCC (tested on 2.5.1)
101101
6. NVCC (CUDA 11 tested)
102+
7. NVIDIA PGI (20.7 tested)
102103

103104
## About
104105

docs/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Smaller or developer focused features:
8080
* Bugfixes related to more extensive testing
8181
`#2321 <https://github.com/pybind/pybind11/pull/2321>`_
8282

83+
* Bug in timezone issue in Eastern hemisphere midnight fixed.
84+
`#2438 <https://github.com/pybind/pybind11/pull/2438>`_
85+
8386
* Pointer to ``std::tuple`` & ``std::pair`` supported in cast.
8487
`#2334 <https://github.com/pybind/pybind11/pull/2334>`_
8588

@@ -96,6 +99,13 @@ Smaller or developer focused features:
9699
* Debug Python interpreter support.
97100
`#2025 <https://github.com/pybind/pybind11/pull/2025>`_
98101

102+
* NVCC (CUDA 11) now supported and tested in CI.
103+
`#2461 <https://github.com/pybind/pybind11/pull/2461>`_
104+
105+
* NVIDIA PGI compilers now supported and tested in CI.
106+
`#2475 <https://github.com/pybind/pybind11/pull/2475>`_
107+
108+
99109

100110

101111
v2.5.0 (Mar 31, 2020)

include/pybind11/detail/common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
#include <vector>
155155
#include <string>
156156
#include <stdexcept>
157+
#include <exception>
157158
#include <unordered_set>
158159
#include <unordered_map>
159160
#include <memory>
@@ -501,8 +502,16 @@ template <bool... Bs> using select_indices = typename select_indices_impl<index_
501502
template <bool B> using bool_constant = std::integral_constant<bool, B>;
502503
template <typename T> struct negation : bool_constant<!T::value> { };
503504

505+
// PGI cannot detect operator delete with the "compatible" void_t impl, so
506+
// using the new one (C++14 defect, so generally works on newer compilers, even
507+
// if not in C++17 mode)
508+
#if defined(__PGIC__)
509+
template<typename... > using void_t = void;
510+
#else
504511
template <typename...> struct void_t_impl { using type = void; };
505512
template <typename... Ts> using void_t = typename void_t_impl<Ts...>::type;
513+
#endif
514+
506515

507516
/// Compile-time all/any/none of that check the boolean value of all template types
508517
#if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))

tests/CMakeLists.txt

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ else()
1616
cmake_policy(VERSION 3.18)
1717
endif()
1818

19+
# Only needed for CMake < 3.5 support
20+
include(CMakeParseArguments)
21+
22+
# Filter out items; print an optional message if any items filtered
23+
#
24+
# Usage:
25+
# pybind11_filter_tests(LISTNAME file1.cpp file2.cpp ... MESSAGE "")
26+
#
27+
macro(PYBIND11_FILTER_TESTS LISTNAME)
28+
cmake_parse_arguments(ARG "" "MESSAGE" "" ${ARGN})
29+
set(PYBIND11_FILTER_TESTS_FOUND OFF)
30+
foreach(filename IN LISTS ARG_UNPARSED_ARGUMENTS)
31+
list(FIND ${LISTNAME} ${filename} _FILE_FOUND)
32+
if(_FILE_FOUND GREATER -1)
33+
list(REMOVE_AT ${LISTNAME} ${_FILE_FOUND})
34+
set(PYBIND11_FILTER_TESTS_FOUND ON)
35+
endif()
36+
endforeach()
37+
if(PYBIND11_FILTER_TESTS_FOUND AND ARG_MESSAGE)
38+
message(STATUS "${ARG_MESSAGE}")
39+
endif()
40+
endmacro()
41+
1942
# New Python support
2043
if(DEFINED Python_EXECUTABLE)
2144
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
@@ -34,6 +57,9 @@ option(PYBIND11_CUDA_TESTS "Enable building CUDA tests (requires CMake 3.12+)" O
3457
set(PYBIND11_TEST_OVERRIDE
3558
""
3659
CACHE STRING "Tests from ;-separated list of *.cpp files will be built instead of all tests")
60+
set(PYBIND11_TEST_FILTER
61+
""
62+
CACHE STRING "Tests from ;-separated list of *.cpp files will be removed from all tests")
3763

3864
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
3965
# We're being loaded directly, i.e. not via add_subdirectory, so make this
@@ -106,21 +132,23 @@ if(PYBIND11_TEST_OVERRIDE)
106132
set(PYBIND11_TEST_FILES ${PYBIND11_TEST_OVERRIDE})
107133
endif()
108134

109-
# Skip test_async for Python < 3.5
110-
list(FIND PYBIND11_TEST_FILES test_async.cpp PYBIND11_TEST_FILES_ASYNC_I)
111-
if((PYBIND11_TEST_FILES_ASYNC_I GREATER -1) AND (PYTHON_VERSION VERSION_LESS 3.5))
112-
message(STATUS "Skipping test_async because Python version ${PYTHON_VERSION} < 3.5")
113-
list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_ASYNC_I})
135+
# You can also filter tests:
136+
if(PYBIND11_TEST_FILTER)
137+
pybind11_filter_tests(PYBIND11_TEST_FILES ${PYBIND11_TEST_FILTER})
138+
endif()
139+
140+
if(PYTHON_VERSION VERSION_LESS 3.5)
141+
pybind11_filter_tests(PYBIND11_TEST_FILES test_async.cpp MESSAGE
142+
"Skipping test_async on Python 2")
114143
endif()
115144

116145
# Skip tests for CUDA check:
117146
# /pybind11/tests/test_constants_and_functions.cpp(125):
118147
# error: incompatible exception specifications
119-
list(FIND PYBIND11_TEST_FILES test_constants_and_functions.cpp PYBIND11_TEST_FILES_CAF_I)
120-
if((PYBIND11_TEST_FILES_CAF_I GREATER -1) AND PYBIND11_CUDA_TESTS)
121-
message(
122-
STATUS "Skipping test_constants_and_functions due to incompatible exception specifications")
123-
list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_CAF_I})
148+
if(PYBIND11_CUDA_TESTS)
149+
pybind11_filter_tests(
150+
PYBIND11_TEST_FILES test_constants_and_functions.cpp MESSAGE
151+
"Skipping test_constants_and_functions due to incompatible exception specifications")
124152
endif()
125153

126154
string(REPLACE ".cpp" ".py" PYBIND11_PYTEST_FILES "${PYBIND11_TEST_FILES}")
@@ -318,23 +346,24 @@ foreach(target ${test_targets})
318346
endif()
319347
endforeach()
320348

321-
# Make sure pytest is found or produce a fatal error
349+
# Make sure pytest is found or produce a warning
322350
if(NOT PYBIND11_PYTEST_FOUND)
323351
execute_process(
324352
COMMAND ${PYTHON_EXECUTABLE} -c "import pytest; print(pytest.__version__)"
325353
RESULT_VARIABLE pytest_not_found
326354
OUTPUT_VARIABLE pytest_version
327355
ERROR_QUIET)
328356
if(pytest_not_found)
329-
message(FATAL_ERROR "Running the tests requires pytest. Please install it manually"
330-
" (try: ${PYTHON_EXECUTABLE} -m pip install pytest)")
357+
message(WARNING "Running the tests requires pytest. Please install it manually"
358+
" (try: ${PYTHON_EXECUTABLE} -m pip install pytest)")
331359
elseif(pytest_version VERSION_LESS 3.1)
332-
message(FATAL_ERROR "Running the tests requires pytest >= 3.1. Found: ${pytest_version}"
333-
"Please update it (try: ${PYTHON_EXECUTABLE} -m pip install -U pytest)")
360+
message(WARNING "Running the tests requires pytest >= 3.1. Found: ${pytest_version}"
361+
"Please update it (try: ${PYTHON_EXECUTABLE} -m pip install -U pytest)")
362+
else()
363+
set(PYBIND11_PYTEST_FOUND
364+
TRUE
365+
CACHE INTERNAL "")
334366
endif()
335-
set(PYBIND11_PYTEST_FOUND
336-
TRUE
337-
CACHE INTERNAL "")
338367
endif()
339368

340369
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)

tests/test_factory_constructors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "pybind11_tests.h"
1212
#include "constructor_stats.h"
1313
#include <cmath>
14+
#include <new>
1415

1516
// Classes for testing python construction via C++ factory function:
1617
// Not publicly constructible, copyable, or movable:

0 commit comments

Comments
 (0)