Skip to content

Commit

Permalink
C++14 (#825)
Browse files Browse the repository at this point in the history
* C++14

Require C++14 or newer.

* Remove Pre-C++14 #ifdefs

* More -Wno-deprecated-declarations

* pybind11: refactor variant caster

* GCC 5.0: Add visit_helper for Variant

Try to address:
```
In file included from /home/runner/work/openPMD-api/openPMD-api/include/openPMD/binding/python/Variant.hpp:26:0,
                 from /home/runner/work/openPMD-api/openPMD-api/include/openPMD/binding/python/Numpy.hpp:24,
                 from /home/runner/work/openPMD-api/openPMD-api/src/binding/python/Attributable.cpp:24:
/home/runner/work/openPMD-api/openPMD-api/share/openPMD/thirdParty/pybind11/include/pybind11/stl.h: In instantiation of ‘static pybind11::handle pybind11::detail::variant_caster<V<Ts ...> >::cast(Variant&&, pybind11::return_value_policy, pybind11::handle) [with Variant = mpark::variant ...
 /home/runner/work/openPMD-api/openPMD-api/src/binding/python/Attributable.cpp:337:10:   required from here
/home/runner/work/openPMD-api/openPMD-api/share/openPMD/thirdParty/pybind11/include/pybind11/stl.h:362:37: error: no matching function for call to ‘pybind11::detail::visit_helper<mpark::variant>::call(pybind11::detail::variant_caster_visitor, mpark::variant<
```

* Visual Studio: 2017+

Too old for multi-return statements in constexpr functions:
  MSVC++ 14.0, _MSC_VER == 1900 (Visual Studio 2015 version 14.0)

New enough:
  MSVC++ 14.1, _MSC_VER == 1910 (Visual Studio 2017 version 15.0)

* AppVeyor: Diversify VS & Py Versions

* GH Action: Cache
  • Loading branch information
ax3l authored Nov 24, 2020
1 parent a6287fc commit ea3e5d7
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 133 deletions.
29 changes: 14 additions & 15 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
environment:
matrix:
- TARGET_ARCH: x86
CONDA_PY: 35
CONDA_INSTALL_LOCN: C:\\Miniconda35
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CONDA_PY: 36
CONDA_INSTALL_LOCN: C:\\Miniconda36
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform: x86
SHARED: ON

- TARGET_ARCH: x64
CONDA_PY: 35
CONDA_INSTALL_LOCN: C:\\Miniconda35-x64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CONDA_PY: 37
CONDA_INSTALL_LOCN: C:\\Miniconda37-x64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform: x64
SHARED: ON

- TARGET_ARCH: x86
CONDA_PY: 37
CONDA_INSTALL_LOCN: C:\\Miniconda37
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform: x86
SHARED: ON

- TARGET_ARCH: x64
CONDA_PY: 37
CONDA_INSTALL_LOCN: C:\\Miniconda37-x64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CONDA_PY: 36
CONDA_INSTALL_LOCN: C:\\Miniconda36-x64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform: x64
SHARED: OFF

Expand Down Expand Up @@ -114,19 +114,18 @@ before_build:
- ps: ..\share\openPMD\download_samples.ps1

# Compiler & Generator Selection
- cmd: if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set OPENPMD_CMAKE_GENERATOR=Visual Studio 14 2015
- cmd: if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set OPENPMD_CMAKE_GENERATOR=Visual Studio 15 2017
- cmd: if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set OPENPMD_CMAKE_GENERATOR=Visual Studio 16 2019
- cmd: if "%TARGET_ARCH%"=="x64" set OPENPMD_CMAKE_GENERATOR=%OPENPMD_CMAKE_GENERATOR% Win64
# - cmd: if "%TARGET_ARCH%"=="x86" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86
- cmd: if "%TARGET_ARCH%"=="x86" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
- cmd: if "%TARGET_ARCH%"=="x64" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
# - cmd: if "%TARGET_ARCH%"=="x86" "C:\Program Files (x86)\Microsoft Visual Studio 15.9\VC\vcvarsall.bat" x86
# - cmd: if "%TARGET_ARCH%"=="x64" "C:\Program Files (x86)\Microsoft Visual Studio 15.9\VC\vcvarsall.bat" amd64

# CMake configure
- cmd: cmake -G "%OPENPMD_CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_SHARED_LIBS=%SHARED% -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX="%CONDA_INSTALL_LOCN%" -DCMAKE_INSTALL_BINDIR="Library\bin" ".."

build_script:
- cmd: cmake --build . --config %CONFIGURATION%
- cmd: cmake --build . --config %CONFIGURATION% --target install
# - cmd: tree "%CONDA_INSTALL_LOCN%"

test_script:
- cmd: ctest -V -C %CONFIGURATION%
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/dependencies/install_spack
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set -eu -o pipefail

spack_ver="0.16.0"

# download
cd /opt
if [ -d spack ]; then exit 0; fi

# download
curl -sOL https://github.com/spack/spack/archive/v${spack_ver}.tar.gz
tar -xf v${spack_ver}.tar.gz && rm v${spack_ver}.tar.gz
mv spack-${spack_ver} spack
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Spack Cache
uses: actions/cache@v2
with: {path: /opt/spack, key: clangtidy10_nopy_ompi_h5_ad1_ad2 }
- name: Install
run: |
sudo apt-get install clang clang-tidy gfortran libopenmpi-dev python
Expand All @@ -28,12 +31,15 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Spack Cache
uses: actions/cache@v2
with: {path: /opt/spack, key: clang5_nopy_nompi_h5 }
- name: Install
run: |
sudo apt-get install clang-5.0
sudo .github/workflows/dependencies/install_spack
- name: Build
env: {CC: clang-5.0, CXX: clang++-5.0, CXXFLAGS: -Werror}
env: {CC: clang-5.0, CXX: clang++-5.0, CXXFLAGS: -Werror -Wno-deprecated-declarations}
run: |
eval $(spack env activate --sh .github/ci/spack-envs/clang5_nopy_nompi_h5/)
spack install
Expand All @@ -48,12 +54,15 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Spack Cache
uses: actions/cache@v2
with: {path: /opt/spack, key: clang5_nopy_ompi_h5_ad1_ad2_bp3 }
- name: Install
run: |
sudo apt-get install clang-5.0 gfortran libopenmpi-dev python3
sudo .github/workflows/dependencies/install_spack
- name: Build
env: {CC: clang-5.0, CXX: clang++-5.0, CXXFLAGS: -Werror}
env: {CC: clang-5.0, CXX: clang++-5.0, CXXFLAGS: -Werror -Wno-deprecated-declarations}
run: |
eval $(spack env activate --sh .github/ci/spack-envs/clang5_nopy_ompi_h5_ad1_ad2_bp3/)
spack install
Expand Down Expand Up @@ -113,7 +122,7 @@ jobs:
brew install hdf5-mpi
brew install python
- name: Build
env: {CXXFLAGS: -Werror}
env: {CXXFLAGS: -Werror -Wno-deprecated-declarations}
run: |
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
Expand All @@ -136,6 +145,9 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Spack Cache
uses: actions/cache@v2
with: {path: /opt/spack, key: gcc5_py36_ompi_h5_ad1_ad2 }
- name: Install
run: |
sudo apt-get install g++-5 gfortran libopenmpi-dev python3 python3-setuptools
Expand All @@ -144,7 +156,7 @@ jobs:
python3 -m pip install -U numpy
python3 -m pip install -U mpi4py
- name: Build
env: {CC: gcc-5, CXX: g++-5, CXXFLAGS: -Werror}
env: {CC: gcc-5, CXX: g++-5, CXXFLAGS: -Werror -Wno-deprecated-declarations}
run: |
eval $(spack env activate --sh .github/ci/spack-envs/gcc5_py36_ompi_h5_ad1_ad2/)
spack install
Expand All @@ -164,7 +176,7 @@ jobs:
sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev libadios-dev python3 python3-numpy python3-mpi4py
# TODO ADIOS1 (.pc file broken?) ADIOS2
- name: Build
env: {CXXFLAGS: -Werror, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig}
env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig}
run: |
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Changelog
=========

0.12.1-alpha
------------
0.13.0-beta
-----------
**Date:** TBA

[Title]
Expand All @@ -23,6 +23,7 @@ Bug Fixes
Other
"""""

- switch to C++14 #825
- Docs:

- Release cibuildwheel example #775
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ add_library(openPMD::openPMD ALIAS openPMD)

# properties
target_compile_features(openPMD
PUBLIC cxx_std_11
PUBLIC cxx_std_14
)
set_target_properties(openPMD PROPERTIES
CXX_EXTENSIONS OFF
Expand Down Expand Up @@ -424,10 +424,10 @@ if(openPMD_HAVE_ADIOS1)
add_library(openPMD.ADIOS1.Serial SHARED ${IO_ADIOS1_SEQUENTIAL_SOURCE})
add_library(openPMD.ADIOS1.Parallel SHARED ${IO_ADIOS1_SOURCE})
target_compile_features(openPMD.ADIOS1.Serial
PUBLIC cxx_std_11
PUBLIC cxx_std_14
)
target_compile_features(openPMD.ADIOS1.Parallel
PUBLIC cxx_std_11
PUBLIC cxx_std_14
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(openPMD.ADIOS1.Serial PUBLIC "/bigobj")
Expand Down Expand Up @@ -652,8 +652,8 @@ if(BUILD_TESTING)
# compile Catch2 implementation part separately
add_library(CatchRunner test/CatchRunner.cpp) # Always MPI_Init with Serial Fallback
add_library(CatchMain test/CatchMain.cpp) # Serial only
target_compile_features(CatchRunner PUBLIC cxx_std_11)
target_compile_features(CatchMain PUBLIC cxx_std_11)
target_compile_features(CatchRunner PUBLIC cxx_std_14)
target_compile_features(CatchMain PUBLIC cxx_std_14)
set_target_properties(CatchRunner CatchMain PROPERTIES
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
Expand Down
6 changes: 6 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Upgrade Guide
=============

0.13.0-beta
-----------

Building openPMD-api now requires a compiler that supports C++14 or newer.


0.12.0-alpha
------------

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ C++ & Python API for Scientific I/O with openPMD
================================================

[![Supported openPMD Standard](https://img.shields.io/badge/openPMD-1.0.0--1.1.0-blue)](https://github.com/openPMD/openPMD-standard/releases)
[![Documentation Status](https://readthedocs.org/projects/openpmd-api/badge/?version=latest)](https://openpmd-api.readthedocs.io/en/latest/?badge=latest)
[![Doxygen](https://img.shields.io/badge/API-Doxygen-blue)](https://www.openpmd.org/openPMD-api)
[![Gitter chat](https://img.shields.io/gitter/room/openPMD/API)](https://gitter.im/openPMD/API)
![Supported Platforms][api-platforms]
Expand All @@ -14,6 +13,7 @@ C++ & Python API for Scientific I/O with openPMD
[![LGTM: Python](https://img.shields.io/lgtm/grade/python/g/openPMD/openPMD-api?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/openPMD/openPMD-api/context:python)
[![LGTM: Total alerts](https://img.shields.io/lgtm/alerts/g/openPMD/openPMD-api?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/openPMD/openPMD-api/alerts/)
[![Coverage Status](https://coveralls.io/repos/github/openPMD/openPMD-api/badge)](https://coveralls.io/github/openPMD/openPMD-api)
[![Documentation Status](https://readthedocs.org/projects/openpmd-api/badge/?version=latest)](https://openpmd-api.readthedocs.io/en/latest/?badge=latest)
[![Linux/OSX Build Status dev](https://travis-ci.com/openPMD/openPMD-api.svg?branch=dev)](https://travis-ci.com/openPMD/openPMD-api)
[![Windows Build Status dev](https://ci.appveyor.com/api/projects/status/x95q4n620pqk0e0t/branch/dev?svg=true)](https://ci.appveyor.com/project/ax3l/openpmd-api/branch/dev)
[![PyPI Wheel Release](https://github.com/openPMD/openPMD-api/workflows/wheels/badge.svg?branch=wheels&event=push)](https://github.com/openPMD/openPMD-api/actions?query=workflow%3Awheels)
Expand All @@ -33,10 +33,10 @@ Writing & reading through those backends and their associated files is supported

### C++

[![C++11][api-cpp]](https://isocpp.org/) ![C++11 API: Alpha][dev-alpha]
[![C++14][api-cpp]](https://isocpp.org/) ![C++14 API: Beta][dev-beta]

[api-cpp]: https://img.shields.io/badge/language-C%2B%2B11-yellowgreen "C++11 API"
[dev-alpha]: https://img.shields.io/badge/phase-alpha-yellowgreen "Status: Alpha"
[api-cpp]: https://img.shields.io/badge/language-C%2B%2B14-yellowgreen "C++14 API"
[dev-beta]: https://img.shields.io/badge/phase-beta-yellowgreen "Status: Beta"

```cpp
#include <openPMD/openPMD.hpp>
Expand Down Expand Up @@ -65,7 +65,7 @@ for( auto const& i : s.iterations ) {

### Python

[![Python3][api-py3]](https://www.python.org/) ![Python3 API: Alpha][dev-alpha]
[![Python3][api-py3]](https://www.python.org/) ![Python3 API: Beta][dev-beta]

[api-py3]: https://img.shields.io/badge/language-Python3-yellowgreen "Python3 API"

Expand Down Expand Up @@ -100,7 +100,7 @@ Our manual shows full [read & write examples](https://openpmd-api.readthedocs.io

Required:
* CMake 3.12.0+
* C++11 capable compiler, e.g. g++ 4.8+, clang 3.9+, VS 2015+
* C++14 capable compiler, e.g. g++ 5.0+, clang 5.0+, VS 2017+

Shipped internally in `share/openPMD/thirdParty/`:
* [MPark.Variant](https://github.com/mpark/variant) 1.4.0+ ([BSL-1.0](https://github.com/mpark/variant/blob/master/LICENSE.md))
Expand Down
2 changes: 1 addition & 1 deletion docs/source/citation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Dependent Software
The good way to control complex software environments is to install software through a :ref:`package manager (see installation) <install>`.
Furthermore, openPMD-api provides functionality to simplify the documentation of its version and enabled backends:

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dev/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Required
--------

* CMake 3.12.0+
* C++11 capable compiler, e.g. g++ 4.8+, clang 3.9+, VS 2015+
* C++14 capable compiler, e.g. g++ 5.0+, clang 5.0+, VS 2017+

Shipped internally
------------------
Expand Down
24 changes: 12 additions & 12 deletions docs/source/usage/firstwrite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Step-by-step: how to write scientific data with openPMD-api?

<style>
@media screen and (min-width: 60em) {
/* C++11 and Python code samples side-by-side */
/* C++14 and Python code samples side-by-side */
#first-write > .section > .section:nth-of-type(2n+1) {
float: left;
width: 48%;
Expand All @@ -20,7 +20,7 @@ Step-by-step: how to write scientific data with openPMD-api?
display: table;
clear: both;
}
/* only show first C++11 and Python Headline */
/* only show first C++14 and Python Headline */
#first-write > .section > .section:not(#c-11):not(#python) > h3 {
display: none;
}
Expand All @@ -47,7 +47,7 @@ Include / Import

After successful :ref:`installation <install>`, you can start using openPMD-api as follows:

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -78,7 +78,7 @@ Write into a new openPMD series in ``myOutput/data_<00...N>.h5``.
Further file formats than ``.h5`` (`HDF5 <https://hdfgroup.org>`_) are supported:
``.bp`` (`ADIOS1 <https://www.olcf.ornl.gov/center-projects/adios/>`_/`ADIOS2 <https://csmd.ornl.gov/software/adios2>`_) or ``.json`` (`JSON <https://en.wikipedia.org/wiki/JSON#Example>`_).

C++11
C++14
^^^^^

.. code-block:: cpp
Expand All @@ -102,7 +102,7 @@ Iteration

Grouping by an arbitrary, positive integer number ``<N>`` in a series:

C++11
C++14
^^^^^

.. code-block:: cpp
Expand All @@ -122,7 +122,7 @@ Attributes
Everything in openPMD can be extended and user-annotated.
Let us try this by writing some meta data:

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -155,7 +155,7 @@ Data
Let's prepare some data that we want to write.
For example, a magnetic field slice :math:`\vec B(i, j)` in two spatial dimensions with three components :math:`(B_x, B_y, B_z)^\intercal` of which the :math:`B_y` component shall be constant for all :math:`(i, j)` indices.

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -195,7 +195,7 @@ Record
An openPMD record can be either structured (mesh) or unstructured (particles).
We prepared a vector field in 2D above, which is a mesh:

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -244,7 +244,7 @@ Independent of the absolute unit system, a magnetic field has the `physical dime
Ouch, our magnetic field was measured in `cgs units <https://en.wikipedia.org/wiki/Gaussian_units>`_!
Quick, let's also store the conversion factor 10\ :sup:`-4` from `Gauss <https://en.wikipedia.org/wiki/Gauss_(unit)>`_ (cgs) to `Tesla <https://en.wikipedia.org/wiki/Tesla_(unit)>`_ (SI).

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -291,7 +291,7 @@ We can write record components partially and in parallel or at once.
Writing very small data one by one is is a performance killer for I/O.
Therefore, we register all data to be written first and then flush it out collectively.

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down Expand Up @@ -330,7 +330,7 @@ We now flush the registered data chunks to the I/O backend.
Flushing several chunks at once allows to increase I/O performance significantly.
After that, the variables ``x_data`` and ``y_data`` can be used again.

C++11
C++14
^^^^^

.. code-block:: cpp
Expand All @@ -349,7 +349,7 @@ Close

Finally, the Series is fully closed (and newly registered data or attributes since the last ``.flush()`` is written) when its destructor is called.

C++11
C++14
^^^^^

.. code-block:: cpp
Expand Down
Loading

0 comments on commit ea3e5d7

Please sign in to comment.