Skip to content

Commit 9239021

Browse files
authored
Move to C++20 (#2088)
* update circleci * update appveyor android builds * update appveyor to vs2019 * build with c++20 * fix for vs2019 breakage * update circleci meson for macos
1 parent dfcd1c3 commit 9239021

File tree

8 files changed

+58
-43
lines changed

8 files changed

+58
-43
lines changed

.circleci/config.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,41 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: danieluranga/leela_chess_zero-lc0_ubuntu_builder:0.0.8
5+
- image: nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
66
steps:
77
- checkout
8+
- run:
9+
name: Install build tools
10+
command: |
11+
apt-get update
12+
apt-get -y install git python3-pip gcc-10 g++-10 clang-12 zlib1g zlib1g-dev
13+
pip3 install meson==0.63
14+
pip3 install ninja
815
- run:
916
name: "Pull Submodules"
1017
command: git submodule update --init
11-
- run:
12-
name: Update Meson
13-
command: pip3 install --upgrade meson==0.58.1
1418
- run:
1519
name: Meson GCC
1620
environment:
17-
CC: gcc-8
18-
CXX: g++-8
21+
CC: gcc-10
22+
CXX: g++-10
1923
command: meson build-gcc -Dgtest=false
24+
- run:
25+
name: Meson Clang
26+
environment:
27+
CC: clang-12
28+
CXX: clang++-12
29+
command: meson build-clang -Dgtest=false
2030
- run:
2131
name: Build GCC
2232
command: |
2333
cd build-gcc
2434
ninja -j 4
35+
- run:
36+
name: Build Clang
37+
command: |
38+
cd build-clang
39+
ninja -j 4
2540
"mac":
2641
macos:
2742
xcode: 14.1.0
@@ -34,7 +49,7 @@ jobs:
3449
- run:
3550
name: Install build tools
3651
command: |
37-
pip3 install meson==0.63
52+
pip3 install meson==1.3.0
3853
pip3 install ninja
3954
curl -LJOs https://github.com/ispc/ispc/releases/download/v1.21.0/ispc-v1.21.0-macOS.universal.tar.gz
4055
tar xf ispc-v1.21.0-macOS.universal.tar.gz

appveyor.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '{build}'
22
configuration: Release
33
platform: x64
44
image:
5-
- Visual Studio 2017
5+
- Visual Studio 2019
66
environment:
77
matrix:
88
- NAME: gpu-nvidia-cudnn
@@ -47,7 +47,7 @@ install:
4747
- cmd: set NET_HASH=3e3444370b9fe413244fdc79671a490e19b93d3cca1669710ffeac890493d198
4848
- cmd: IF NOT %OPENCL%==true IF NOT %DX%==true set NET=791556
4949
- cmd: IF NOT %OPENCL%==true IF NOT %DX%==true set NET_HASH=f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34
50-
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
50+
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
5151
- cmd: set DNNL_NAME=dnnl_win_1.5.0_cpu_vcomp
5252
- cmd: IF %NAME%==cpu-dnnl IF NOT EXIST C:\cache\%DNNL_NAME% appveyor DownloadFile https://github.com/oneapi-src/oneDNN/releases/download/v1.5/dnnl_win_1.5.0_cpu_vcomp.zip
5353
- cmd: IF %NAME%==cpu-dnnl IF NOT EXIST C:\cache\%DNNL_NAME% 7z x dnnl_win_1.5.0_cpu_vcomp.zip -oC:\cache
@@ -65,26 +65,26 @@ install:
6565
- cmd: IF %ISPC%==true IF NOT EXIST C:\cache\ispc-v1.13.0-windows appveyor DownloadFile https://github.com/ispc/ispc/releases/download/v1.13.0/ispc-v1.13.0-windows.zip
6666
- cmd: IF %ISPC%==true IF NOT EXIST C:\cache\ispc-v1.13.0-windows 7z x ispc-v1.13.0-windows.zip -oC:\cache\ispc-v1.13.0-windows
6767
- cmd: IF %ISPC%==true set PATH=C:\cache\ispc-v1.13.0-windows\bin;%PATH%
68-
- cmd: set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0"
68+
- cmd: set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1"
6969
- cmd: IF %CUDNN%==true IF NOT EXIST "%CUDA_PATH%\cuda" set CUDNN_INSTALL=1
70-
- cmd: IF DEFINED CUDNN_INSTALL appveyor DownloadFile https://developer.nvidia.com/compute/cuda/10.0/Prod/network_installers/cuda_10.0.130_win10_network
71-
- cmd: IF DEFINED CUDNN_INSTALL cuda_10.0.130_win10_network -s nvcc_10.0 cublas_dev_10.0 cublas_10.0 cudart_10.0
72-
- cmd: IF DEFINED CUDNN_INSTALL appveyor DownloadFile http://developer.download.nvidia.com/compute/redist/cudnn/v7.4.2/cudnn-10.0-windows10-x64-v7.4.2.24.zip
73-
- cmd: IF DEFINED CUDNN_INSTALL 7z x cudnn-10.0-windows10-x64-v7.4.2.24.zip -o"%CUDA_PATH%"
70+
- cmd: IF DEFINED CUDNN_INSTALL appveyor DownloadFile https://developer.download.nvidia.com/compute/cuda/10.1/Prod/network_installers/cuda_10.1.243_win10_network.exe
71+
- cmd: IF DEFINED CUDNN_INSTALL cuda_10.1.243_win10_network -s nvcc_10.1 cublas_dev_10.1 cublas_10.1 cudart_10.1
72+
- cmd: IF DEFINED CUDNN_INSTALL appveyor DownloadFile https://developer.download.nvidia.com/compute/redist/cudnn/v7.5.1/cudnn-10.1-windows10-x64-v7.5.1.10.zip
73+
- cmd: IF DEFINED CUDNN_INSTALL 7z x cudnn-10.1-windows10-x64-v7.5.1.10.zip -o"%CUDA_PATH%"
7474
- cmd: IF %CUDNN%==false set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1"
7575
- cmd: IF %CUDA%==true IF NOT EXIST "%CUDA_PATH%" set CUDA_INSTALL=1
7676
- cmd: IF DEFINED CUDA_INSTALL appveyor DownloadFile https://developer.download.nvidia.com/compute/cuda/11.1.0/network_installers/cuda_11.1.0_win10_network.exe
7777
- cmd: IF DEFINED CUDA_INSTALL cuda_11.1.0_win10_network.exe -s nvcc_11.1 cublas_dev_11.1 cublas_11.1 cudart_11.1 documentation_11.1
7878
- cmd: IF %CUDA%==true set PATH=%CUDA_PATH%\bin;%PATH%
79-
- cmd: set PATH=C:\Python36;C:\Python36\scripts;%PATH%
80-
- cmd: pip3 install --upgrade meson==0.55.3
81-
- cmd: set MIMALLOC_PATH=C:\cache\mimalloc-1.7.1
82-
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%" appveyor DownloadFile https://github.com/microsoft/mimalloc/archive/refs/tags/v1.7.1.zip
83-
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%" 7z x v1.7.1.zip -oC:\cache\
84-
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%"\out msbuild "%MIMALLOC_PATH%"\ide\vs2017\mimalloc-override.vcxproj /p:Configuration=Release /m
85-
- cmd: IF %NAME%==android IF NOT EXIST C:\ndk\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64 appveyor DownloadFile https://dl.google.com/android/repository/android-ndk-r19c-windows-x86_64.zip
86-
- cmd: IF %NAME%==android IF NOT EXIST C:\ndk\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64 7z x android-ndk-r19c-windows-x86_64.zip -oC:\ndk
87-
- cmd: IF %NAME%==android set PATH=C:\ndk\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin;%PATH%
79+
- cmd: set PATH=C:\Python310;C:\Python310\scripts;%PATH%
80+
#- cmd: pip3 install --upgrade meson==0.55.3
81+
- cmd: set MIMALLOC_PATH=C:\cache\mimalloc-1.8.7
82+
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%" appveyor DownloadFile https://github.com/microsoft/mimalloc/archive/refs/tags/v1.8.7.zip
83+
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%" 7z x v1.8.7.zip -oC:\cache\
84+
- cmd: IF %ANDROID%==false IF NOT EXIST "%MIMALLOC_PATH%"\out msbuild "%MIMALLOC_PATH%"\ide\vs2019\mimalloc-override.vcxproj /p:Configuration=Release /m
85+
- cmd: IF %NAME%==android IF NOT EXIST C:\ndk\android-ndk-r27c\toolchains\llvm\prebuilt\windows-x86_64 appveyor DownloadFile https://dl.google.com/android/repository/android-ndk-r27c-windows.zip
86+
- cmd: IF %NAME%==android IF NOT EXIST C:\ndk\android-ndk-r27c\toolchains\llvm\prebuilt\windows-x86_64 7z x android-ndk-r27c-windows.zip -oC:\ndk
87+
- cmd: IF %NAME%==android set PATH=C:\ndk\android-ndk-r27c\toolchains\llvm\prebuilt\windows-x86_64\bin;%PATH%
8888
- cmd: IF %NAME%==android sed "s/clang+*/&.cmd/" cross-files/aarch64-linux-android >crossfile-aarch64
8989
- cmd: IF %NAME%==android IF NOT EXIST C:\cache\OpenBLAS\android-aarch64 appveyor DownloadFile https://github.com/borg323/OpenBLAS/releases/download/android-0.3.27/openblas-android-aarch64.zip
9090
- cmd: IF %NAME%==android IF NOT EXIST C:\cache\OpenBLAS\android-aarch64 7z x openblas-android-aarch64.zip -oC:\cache\OpenBLAS
@@ -103,10 +103,10 @@ install:
103103
- cmd: cd C:\projects\lc0
104104
cache:
105105
- C:\cache
106-
- 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0'
106+
- 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1'
107107
- 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1'
108108
- C:\projects\lc0\subprojects\packagecache
109-
- C:\ndk\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64
109+
- C:\ndk\android-ndk-r27c\toolchains\llvm\prebuilt\windows-x86_64
110110
before_build:
111111
- cmd: git submodule update --init --recursive
112112
- cmd: IF %BLAS%==true (echo.#define DEFAULT_MAX_PREFETCH 0 & echo.#define DEFAULT_TASK_WORKERS 0) > params_override.h
@@ -124,7 +124,7 @@ before_build:
124124
- cmd: SET EXTRA=
125125
- cmd: IF %ANDROID%==false SET EXTRA=-Db_vscrt=md
126126
- cmd: IF %ONNX_DML%==true SET EXTRA=-Db_vscrt=md -Donnx_libdir=C:\cache\%ONNX_NAME%\lib -Donnx_include=C:\cache\%ONNX_NAME%\include
127-
- cmd: IF %ANDROID%==false meson build --backend vs2017 --buildtype release -Dgtest=%GTEST% -Dopencl=%OPENCL% -Dblas=%BUILD_BLAS% -Ddnnl=true -Ddx=%DX% -Dcudnn=%CUDNN% -Donednn=%ONEDNN% -Dispc_native_only=false -Dnative_cuda=false -Dpopcnt=%POPCNT% -Df16c=%F16C% -Dcudnn_include="%CUDA_PATH%\include","%CUDA_PATH%\cuda\include" -Dcudnn_libdirs="%CUDA_PATH%\lib\x64","%CUDA_PATH%\cuda\lib\x64" -Dopenblas_include="%PKG_FOLDER%\OpenBLAS\dist64\include" -Dopenblas_libdirs="%PKG_FOLDER%\OpenBLAS\dist64\lib" -Ddnnl_dir="%PKG_FOLDER%\%DNNL_NAME%" -Dopencl_include="%PKG_FOLDER%\opencl-nug.0.777.77\build\native\include" -Dopencl_libdirs="%PKG_FOLDER%\opencl-nug.0.777.77\build\native\lib\x64" -Ddefault_library=static -Dmalloc=mimalloc -Dmimalloc_libdir="%MIMALLOC_PATH%"\out\msvc-x64\Release %EXTRA%
127+
- cmd: IF %ANDROID%==false meson build --backend vs2019 --buildtype release -Dgtest=%GTEST% -Dopencl=%OPENCL% -Dblas=%BUILD_BLAS% -Ddnnl=true -Ddx=%DX% -Dcudnn=%CUDNN% -Donednn=%ONEDNN% -Dispc_native_only=false -Dnative_cuda=false -Dpopcnt=%POPCNT% -Df16c=%F16C% -Dcudnn_include="%CUDA_PATH%\include","%CUDA_PATH%\cuda\include" -Dcudnn_libdirs="%CUDA_PATH%\lib\x64","%CUDA_PATH%\cuda\lib\x64" -Dopenblas_include="%PKG_FOLDER%\OpenBLAS\dist64\include" -Dopenblas_libdirs="%PKG_FOLDER%\OpenBLAS\dist64\lib" -Ddnnl_dir="%PKG_FOLDER%\%DNNL_NAME%" -Dopencl_include="%PKG_FOLDER%\opencl-nug.0.777.77\build\native\include" -Dopencl_libdirs="%PKG_FOLDER%\opencl-nug.0.777.77\build\native\lib\x64" -Ddefault_library=static -Dmalloc=mimalloc -Dmimalloc_libdir="%MIMALLOC_PATH%"\out\msvc-x64\Release %EXTRA%
128128
- cmd: IF %ANDROID%==true meson arm64-v8a --buildtype release -Dgtest=false -Dopenblas_include="%PKG_FOLDER%\OpenBLAS\android-aarch64\include" -Dopenblas_libdirs="%PKG_FOLDER%\OpenBLAS\android-aarch64\lib" -Dembed=%EMBED% -Ddefault_library=static --cross-file crossfile-aarch64
129129
- cmd: IF %ANDROID%==true meson armeabi-v7a --buildtype release -Dgtest=false -Dopenblas_include="%PKG_FOLDER%\OpenBLAS\android-armv7a\include" -Dopenblas_libdirs="%PKG_FOLDER%\OpenBLAS\android-armv7a\lib" -Dembed=%EMBED% -Ddefault_library=static --cross-file crossfile-armv7a -Dispc=false -Dneon=false
130130
build_script:

cross-files/aarch64-linux-android

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Tested with Android NDK r19c, default toolchain
2+
# Tested with Android NDK r27c, default toolchain
33
# Targeting API level 21
44

55
# Set the toolchain path on your environment
@@ -17,8 +17,8 @@ cpp_link_args = ['-llog', '-static-libstdc++']
1717
[binaries]
1818
c = 'aarch64-linux-android21-clang'
1919
cpp = 'aarch64-linux-android21-clang++'
20-
ar = 'aarch64-linux-android-ar'
21-
strip = 'aarch64-linux-android-strip'
22-
ld = 'aarch64-linux-android-ld'
23-
ranlib = 'aarch64-linux-android-ranlib'
24-
as = 'aarch64-linux-android-as'
20+
ar = 'llvm-ar'
21+
strip = 'llvm-strip'
22+
ld = 'ld'
23+
ranlib = 'llvm-ranlib'
24+
as = 'aarch64-linux-android21-clang'

cross-files/armv7a-linux-android

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Tested with Android NDK r19c, default toolchain
2+
# Tested with Android NDK r27c, default toolchain
33
# Targeting API level 21
44

55
# When targeting API levels < 24 the build fails unless _FILE_OFFSET_BITS is unset.
@@ -24,8 +24,8 @@ cpp_link_args = ['-llog', '-static-libstdc++']
2424
[binaries]
2525
c = 'armv7a-linux-androideabi21-clang'
2626
cpp = 'armv7a-linux-androideabi21-clang++'
27-
ar = 'arm-linux-androideabi-ar'
28-
strip = 'arm-linux-androideabi-strip'
29-
ld = 'arm-linux-androideabi-ld'
30-
ranlib = 'arm-linux-androideabi-ranlib'
31-
as = 'arm-linux-androideabi-as'
27+
ar = 'llvm-ar'
28+
strip = 'llvm-strip'
29+
ld = 'ld'
30+
ranlib = 'llvm-ranlib'
31+
as = 'armv7a-linux-androideabi21-clang'

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# along with Leela Chess. If not, see <http://www.gnu.org/licenses/>.
1616

1717
project('lc0', 'cpp',
18-
default_options : ['cpp_std=c++17', 'b_ndebug=if-release', 'warning_level=3', 'b_lto=true', 'b_vscrt=mt'],
18+
default_options : ['cpp_std=c++20', 'b_ndebug=if-release', 'warning_level=3', 'b_lto=true', 'b_vscrt=mt'],
1919
meson_version: '>=0.55')
2020

2121
cc = meson.get_compiler('cpp')

scripts/appveyor_android_build.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cd arm64-v8a
22
ninja
3-
aarch64-linux-android-strip lc0
3+
llvm-strip lc0
44
cd C:\projects\lc0
55
cd armeabi-v7a
66
ninja
7-
arm-linux-androideabi-strip lc0
7+
llvm-strip lc0

scripts/appveyor_win_package.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IF %NAME%==cpu-openblas 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip C:\
1515
IF %NAME%==cpu-dnnl 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip C:\cache\%DNNL_NAME%\bin\dnnl.dll
1616
IF %NAME%==onednn 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip C:\cache\%DNNL_NAME%\bin\dnnl.dll
1717
IF %OPENCL%==true 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip C:\cache\opencl-nug.0.777.77\build\native\bin\OpenCL.dll
18-
IF %CUDNN%==true 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip "%CUDA_PATH%\bin\cudart64_100.dll" "%CUDA_PATH%\bin\cublas64_100.dll"
18+
IF %CUDNN%==true 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip "%CUDA_PATH%\bin\cudart64_101.dll" "%CUDA_PATH%\bin\cublas64_10.dll" "%CUDA_PATH%\bin\cublasLt64_10.dll"
1919
IF %CUDNN%==true 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip "%CUDA_PATH%\cuda\bin\cudnn64_7.dll"
2020
IF %CUDA%==true 7z a lc0-%APPVEYOR_REPO_TAG_NAME%-windows-%NAME%.zip "%CUDA_PATH%\bin\cudart64_110.dll" "%CUDA_PATH%\bin\cublas64_11.dll" "%CUDA_PATH%\bin\cublasLt64_11.dll"
2121
IF %NAME%==cpu-dnnl copy "%PKG_FOLDER%\%DNNL_NAME%\LICENSE" dist\DNNL-LICENSE

src/neural/xla/onnx2hlo.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pblczero::XlaLiteralProto ConstOpMax(const pblczero::XlaLiteralProto& lhs,
273273
typename std::remove_reference<decltype(lhs)>::type::value_type;
274274
std::transform(lhs.begin(), lhs.end(), rhs.begin(),
275275
std::back_inserter(*dst),
276-
[](T a, T b) { return std::max(a, b); });
276+
[](const T &a, const T &b) { return std::max(a, b); });
277277
});
278278
return result;
279279
}

0 commit comments

Comments
 (0)