diff --git a/ChangeLog b/ChangeLog index 73f2204..ecd0883 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,15 @@ -2017-11-21 Kim Walisch +2017-11-25 Kim Walisch - Version 1.2 work in progress. + Version 1.2 released. - * Reduce input limit from 10^20 to 2^64-1 to prevent - 128-bit integer overflows in S1(x). + This version fixes an integer overflow in primesum 128-bit + and speeds up primesum 256-bit by up to 30% due to replacing the + Boost multiprecision library with my own highly optimized + int256_t type. + + * int256_t.hpp: New 256-bit signed integer type. * Fix 128-bit integer overflow in phi_sum.cpp. - * primesum 256-bit runs 10% faster. + * Reduce input limit from 10^20 to 2^64-1 in primesum 128-bit. * CMakeLists.txt: Silence OpenMP warning. * README.md: Update build instructions. * .travis.yml: Update to Ubuntu 14. diff --git a/lib/primesieve/.gitignore b/lib/primesieve/.gitignore new file mode 100644 index 0000000..7a845a9 --- /dev/null +++ b/lib/primesieve/.gitignore @@ -0,0 +1,25 @@ +.* +*~ +!/.gitignore +!/.travis.yml +*.exe +*.tar.gz +*.zip +*.obj +*.lib +*.o +*.pc +*.dSYM +CMakeCache.txt +CMakeFiles +CMakeScripts +Makefile +cmake_install.cmake +install_manifest.txt +CTestTestfile.cmake +/primesieve* +/libprimesieve* +doc/Doxyfile +doc/html +doc/latex +build diff --git a/lib/primesieve/.travis.yml b/lib/primesieve/.travis.yml new file mode 100644 index 0000000..8d23a84 --- /dev/null +++ b/lib/primesieve/.travis.yml @@ -0,0 +1,63 @@ +# Test configuration for Travis CI. See . +language: cpp + +branches: + except: + - gh-pages + +compiler: + - gcc + - clang + +os: + - linux + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.9 + - g++-4.9 + +install: + - sudo apt-get install -y ninja-build cppcheck doxygen help2man texlive texlive-latex-extra graphviz libqt4-dev qt4-qmake valgrind + - wget --no-check-certificate http://cmake.org/files/v3.1/cmake-3.1.3-Linux-x86_64.tar.gz + - tar -xzf cmake-3.1.3-Linux-x86_64.tar.gz + - export CXXFLAGS="-Wall -Wextra -Werror -Wno-long-long -pedantic -O2" + - export PATH=$PWD/cmake-3.1.3-Linux-x86_64/bin:$PATH + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9"; fi + - if [ "$CC" = "gcc" ]; then export CC="gcc-4.9"; fi + +script: + # 1) Build using GNU make + - mkdir build + - cd build + - cmake -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBUILD_DOC=ON -DCMAKE_INSTALL_PREFIX=$(pwd) .. + - make -j4 + - make doc >/dev/null + - make install + - cd .. + - rm -rf build + # 2) Build primesieve GUI app + - cd src/gui + - qmake QMAKE_CXX=$CXX QMAKE_CC=$CC + - make -j4 + - cd ../.. + # 3) Build using ninja + - mkdir build + - cd build + - cmake -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBUILD_DOC=ON .. + - ninja + - ninja doc >/dev/null + # 4) Run integration tests + - ninja test + - test/cpu_info + - test/atomic + - cd .. + # 5) Test using valgrind + - $CXX -Iinclude -O2 -std=c++11 -g examples/cpp/nth_prime.cpp -o nth_prime build/libprimesieve.a -lpthread + - valgrind --error-exitcode=1 ./nth_prime 500000000 + # 6) Test using cppcheck + - rm -rf build + - cppcheck . -q --error-exitcode=1 -icmake-3.1.3-Linux-x86_64 -iexamples/cpp/prev_prime.cpp -iexamples/cpp/primesieve_iterator.cpp -itest/next_prime1.cpp -itest/prev_prime1.cpp diff --git a/lib/primesieve/CMakeLists.txt b/lib/primesieve/CMakeLists.txt index dba7763..606dc4d 100644 --- a/lib/primesieve/CMakeLists.txt +++ b/lib/primesieve/CMakeLists.txt @@ -59,31 +59,49 @@ endif() # Check if libatomic is needed ####################################### +include(CMakePushCheckState) include(CheckCXXSourceCompiles) -set(CMAKE_OLD_FLAGS ${CMAKE_REQUIRED_FLAGS}) +cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX11_STANDARD_COMPILE_OPTION}) check_cxx_source_compiles(" #include + #include int main() { - std::atomic x; + std::atomic x; x = 1; x--; - return x; + return (int) x; }" - have_atomic) + atomic64) -set(CMAKE_REQUIRED_FLAGS ${CMAKE_OLD_FLAGS}) +if(NOT atomic64) + find_library(ATOMIC NAMES atomic libatomic.so.1) -if(NOT have_atomic) - find_library(ATOMIC NAMES atomic libatomic.so libatomic.so.1) if(ATOMIC) set(LIBATOMIC ${ATOMIC}) - message(STATUS "Found libatomic: TRUE") + message(STATUS "Found libatomic: ${LIBATOMIC}") + else() + check_cxx_source_compiles(" + #include + #include + int main() { + std::atomic x; + x = 1; + x--; + return (int) x; + }" + atomic32) + + if(atomic32) + message(FATAL_ERROR "Failed to find libatomic!") + endif() endif() endif() +cmake_pop_check_state() + # libprimesieve ###################################################### add_library(libprimesieve ${LIB_SRC}) diff --git a/lib/primesieve/ChangeLog b/lib/primesieve/ChangeLog index a5f7943..4ccda37 100644 --- a/lib/primesieve/ChangeLog +++ b/lib/primesieve/ChangeLog @@ -1,3 +1,8 @@ +Changes in version 6.4, 25/11/2017 +================================== + + * CMakeLists.txt: Fix libatomic detection. + Changes in version 6.3, 12/11/2017 ==================================