Skip to content

Performance Enhancements #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 76 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ jobs:
compiler: [msvc, clang]
config: [Release, Debug]
standard: ["11", "17"]
memory: ["default", "lowmem"]
include:
- config: Debug
sccache: "false"
cmake_extra: ""
- config: Release
sccache: "true"
cmake_extra: -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake_extra: -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- memory: "lowmem"
cmake_mem_flag: -DXAD_REDUCED_MEMORY=ON
- compiler: clang
cxx: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe
cc: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe
Expand Down Expand Up @@ -47,6 +50,12 @@ jobs:
toolset: "14.2"
- compiler: clang
toolset: "14.0"
- config: Release
memory: lowmem
- compiler: clang
memory: lowmem
- compiler: clang
config: Debug
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -57,7 +66,7 @@ jobs:
if: ${{ matrix.sccache == 'true' }}
uses: hendrikmuhs/[email protected]
with:
key: windows-${{ matrix.compiler }}-${{ matrix.toolset }}-${{ matrix.config }}
key: windows-${{ matrix.compiler }}-${{ matrix.toolset }}-${{ matrix.config }}-${{ matrix.memory }}
variant: sccache
- name: configure
shell: cmd
Expand All @@ -71,6 +80,7 @@ jobs:
-DCMAKE_C_COMPILER="${{ matrix.cc }}" ^
-DCMAKE_CXX_STANDARD="${{ matrix.standard }}" ^
${{ matrix.cmake_extra }} ^
${{ matrix.cmake_mem_flag }} ^
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
- name: build
shell: cmd
Expand All @@ -86,9 +96,9 @@ jobs:
ctest --no-compress-output --output-on-failure -j3 --output-junit test_results.xml
- name: upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test Results (windows ${{ matrix.compiler }}-${{ matrix.toolset }}-${{ matrix.config }})
name: Test Results (windows ${{ matrix.compiler }}-${{ matrix.toolset }}-${{ matrix.config }}-${{ matrix.memory }}-${{ matrix.standard }})
path: build/test_results.xml
- name: install
shell: cmd
Expand Down Expand Up @@ -125,6 +135,7 @@ jobs:
config: [Release, Debug]
reuse_slots: [OFF, ON]
standard: ["11", "17"]
memory: ["default", "lowmem"]
include:
- compiler: clang-11
cxx: clang++-11
Expand All @@ -146,9 +157,21 @@ jobs:
cxx: clang++-15
cc: clang-15
os: ubuntu-22.04
- memory: lowmem
cmake_mem_flag: -DXAD_REDUCED_MEMORY=ON
exclude:
- config: Debug
reuse_slots: ON
- config: Release
memory: lowmem
- standard: "17"
memory: lowmem
- compiler: clang-11
config: Debug
- compiler: clang-12
config: Debug
- compiler: clang-13
config: Debug
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -163,7 +186,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: linux-${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }}
key: linux-${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }}-${{ matrix.memory }}
- name: configure
run: |
mkdir build
Expand All @@ -175,6 +198,7 @@ jobs:
-DCMAKE_CXX_STANDARD=${{ matrix.standard }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DXAD_TAPE_REUSE_SLOTS=${{ matrix.reuse_slots }} \
${{ matrix.cmake_mem_flag }} \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install
- name: build
run: |
Expand All @@ -186,9 +210,9 @@ jobs:
ctest --no-compress-output --output-on-failure --parallel $(($(nproc) + 2)) --output-junit test_results.xml
- name: upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test Results (linux ${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }})
name: Test Results (linux ${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }}-${{ matrix.memory }}-${{ matrix.standard }})
path: build/test_results.xml
- name: install
run: |
Expand All @@ -212,34 +236,42 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler:
- gcc5
- gcc6
- gcc7
- gcc8
- gcc9
- gcc10
- gcc11
version: ["7", "8", "9", "10", "11", "12", "13", "14"]
config: [Release, Debug]
reuse_slots: [OFF, ON]
standard: [c++11, c++17]
memory: ["default", "lowmem"]
exclude:
- config: Debug
reuse_slots: ON
- compiler: gcc5
standard: c++17
- compiler: gcc6
standard: c++17
- compiler: gcc7
- version: "7"
standard: c++17
- config: Release
memory: lowmem
- standard: c++17
config: lowmem
- version: "7"
config: Debug
- version: "8"
config: Debug
- version: "9"
config: Debug
- version: "10"
config: Debug
- version: "12"
config: Debug
- version: "13"
config: Debug
include:
- memory: lowmem
cmake_mem_flag: -DXAD_REDUCED_MEMORY=ON
- config: Debug
compiler: gcc11
version: "11"
coverage: true
coverage_cxx_flags: "-fprofile-arcs -ftest-coverage"
coverage_ld_flags: "-lgcov"
standard: c++11
- compiler: gcc11
- version: "11"
config: Debug # also with reusing slots, for coverage
reuse_slots: ON
coverage: true
Expand All @@ -248,48 +280,33 @@ jobs:
standard: c++11
runs-on: ubuntu-latest
container:
image: conanio/${{ matrix.compiler }}
options: --user root
env:
ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION: node16
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
image: ghcr.io/foonathan/gcc:${{ matrix.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup tools
run: |
cat /etc/lsb-release
/lib/x86_64-linux-gnu/libc.so.6
sudo rm -f /etc/apt/sources.list.d/git-core-ubuntu-ppa-artful.list || true
sudo rm -f /etc/apt/sources.list.d/git-core-ubuntu-ppa-xenial.list || true
sudo apt-get update
sudo apt-get install -y ccache ninja-build lcov
apt-get update
apt-get install -y ccache ninja-build lcov
- name: GitHub WS Tmp
# there is an issue with workspace locations in github inside containers, which this works around
# see: https://github.com/actions/runner/issues/2058
run: |
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Setup cmake
run: |
wget https://github.com/Kitware/CMake/releases/download/v3.29.0/cmake-3.29.0-linux-x86_64.tar.gz
tar -xzf cmake-3.29.0-linux-x86_64.tar.gz
sudo rm /usr/bin/cmake /usr/share/cmake-* -rf
echo $(pwd)/cmake-3.29.0-linux-x86_64/bin >> $GITHUB_PATH
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: linux-${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }}
key: linux-gcc${{ matrix.version }}-${{ matrix.config }}-${{ matrix.reuse_slots }}-${{ matrix.memory }}-${{ matrix.standard }}
- name: configure
run: |
mkdir build
cd build
cmake .. -GNinja \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_FLAGS="-std=${{ matrix.standard }} ${{ matrix.coverage_cxx_flags }}" \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.coverage_ld_flags }}" \
-DXAD_TAPE_REUSE_SLOTS=${{ matrix.reuse_slots }} \
${{ matrix.cmake_mem_flag }} \
-DCMAKE_INSTALL_PREFIX=${{ env.GITHUB_WORKSPACE }}/install
- name: build
run: |
Expand All @@ -307,9 +324,9 @@ jobs:
ctest --no-compress-output --output-on-failure --parallel $(($(nproc) + 2)) --output-junit test_results.xml
- name: upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test Results (linux ${{ matrix.compiler }}-${{ matrix.config }}-${{ matrix.reuse_slots }})
name: Test Results (linux gcc${{ matrix.version }}-${{ matrix.config }}-${{ matrix.reuse_slots }}-${{ matrix.memory }}-${{ matrix.standard }})
path: ${{ env.GITHUB_WORKSPACE }}/build/test_results.xml
- name: coverage tests
if: ${{ matrix.coverage }}
Expand All @@ -323,7 +340,7 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: linux-${{ matrix.compiler }}-${{ matrix.reuse_slots }}
flag-name: linux-${{ matrix.compiler }}-${{ matrix.reuse_slots }}-${{ matrix.memory }}
path-to-lcov: ${{env.GITHUB_WORKSPACE }}/build/coverage/lcov.info
parallel: true
- name: install
Expand All @@ -340,8 +357,6 @@ jobs:
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_PREFIX_PATH="${{ env.GITHUB_WORKSPACE }}/install" \
-DCMAKE_CXX_FLAGS="-std=${{ matrix.standard}}" \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.coverage_ld_flags }}"
cmake --build .

Expand All @@ -354,7 +369,10 @@ jobs:
os: [macos-13, macos-latest]
compiler: [default, clang15]
standard: [c++11, c++17]
memory: ["default", "lowmem"]
include:
- memory: lowmem
cmake_mem_flag: -DXAD_REDUCED_MEMORY=ON
- config: Release
os: macos-13
compiler: default
Expand Down Expand Up @@ -382,6 +400,10 @@ jobs:
compiler: clang15
- os: macos-latest
compiler: default
- config: Release
memory: lowmem
- standard: "c++17"
config: lowmem
runs-on: ${{ matrix.os }}
steps:
- name: setup
Expand All @@ -399,7 +421,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: macos-${{ matrix.config }}
key: macos-${{ matrix.config }}-${{ matrix.compiler }}-${{ matrix.standard }}-${{ matrix.memory }}
- name: configure
run: |
mkdir build
Expand All @@ -408,6 +430,7 @@ jobs:
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-DCMAKE_CXX_FLAGS="-std=${{matrix.standard }} ${{ matrix.coverage_cxx_flags }}" \
${{ matrix.cmake_mem_flag }} \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.coverage_ld_flags }}" \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install \
${{ matrix.compiler == 'clang15' && ' -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ -DCMAKE_C_COMPILER=clang' || '' }}
Expand All @@ -427,9 +450,9 @@ jobs:
ctest --no-compress-output --output-on-failure -j$(sysctl -n hw.ncpu) --output-junit test_results.xml
- name: upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test Results (macos ${{ matrix.config }})
name: Test Results (macos ${{ matrix.config }}-${{ matrix.compiler }}-${{ matrix.standard }}-${{ matrix.memory }}-${{ matrix.standard }})
path: build/test_results.xml
- name: coverage tests
if: ${{ matrix.coverage }}
Expand All @@ -443,7 +466,7 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: macos
flag-name: macos-${{ matrix.compiler }}-${{ matrix.standard }}-${{ matrix.memory }}
path-to-lcov: build/coverage/lcov.info
parallel: true
- name: install
Expand Down Expand Up @@ -483,7 +506,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
Expand Down
5 changes: 5 additions & 0 deletions cmake/XADSetupCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ function(xad_add_library name type)
set_target_properties(${name} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
if(MSVC)
# in MSVC/Debug, we used checked iterators, and MSVC displays a deprecation warning
# without this flag
target_compile_definitions(${name} PUBLIC "$<$<CONFIG:DEBUG>:_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING>")
endif()
endfunction()


Expand Down
11 changes: 8 additions & 3 deletions cmake/XADSetupOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ endif()
# Tape options: these end up in Config.hpp, a cmake-generated file
option(XAD_TAPE_REUSE_SLOTS "Reuse slots in tape that have become free (slower, less memory)" OFF)
option(XAD_NO_THREADLOCAL "Disable thread-local tape - only for single-threaded tape use" OFF)
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1920)
option(XAD_USE_STRONG_INLINE "Use forced inlining for higher preformance, at a higher compile time cost" OFF)
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910)
option(XAD_USE_STRONG_INLINE "Use forced inlining for higher performance, at a higher compile time cost" OFF)
else()
# in VS 2015 and 2017, without strong inlining, some long expressions in release mode get miscompiled
# in VS 2015, without strong inlining, some long expressions in release mode get miscompiled
set(XAD_USE_STRONG_INLINE ON CACHE BOOL "Use forced inlining for higher preformance, at a higher compile time cost" FORCE)
endif()
option(XAD_ALLOW_INT_CONVERSION "Add real->int conversion operator, potentially missing to track dependencies" ON)
option(XAD_REDUCED_MEMORY "Reduce memory required for tape, at a slight performance cost" OFF)

if(XAD_REDUCED_MEMORY)
message(STATUS "Using reduced memory for tape storage at a slight performance cost")
endif()
8 changes: 2 additions & 6 deletions cmake/XADSetupTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,14 @@ if (NOT TARGET GTest::gmock_main)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set(_gtest_tag release-1.10.0)
else()
set(_gtest_tag release-1.11.0)
set(_gtest_tag v1.15.2)
endif()
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG ${_gtest_tag}
)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_MakeAvailable(googletest)

set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES
FOLDER "test/gtest")
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set(public_headers
XAD/Literals.hpp
XAD/Macros.hpp
XAD/MathFunctions.hpp
XAD/OperationsContainer.hpp
XAD/OperationsContainerPaired.hpp
XAD/ReusableRange.hpp
XAD/StdCompatibility.hpp
XAD/Tape.hpp
Expand Down
Loading