Skip to content

Commit

Permalink
Merge branch 'master' into 256-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Nov 25, 2017
2 parents 910c13c + d2dbdaf commit 3b5cb90
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 13 deletions.
14 changes: 9 additions & 5 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
2017-11-21 Kim Walisch <[email protected]>
2017-11-25 Kim Walisch <[email protected]>

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.
Expand Down
25 changes: 25 additions & 0 deletions lib/primesieve/.gitignore
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions lib/primesieve/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Test configuration for Travis CI. See <https://travis-ci.org/>.
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
34 changes: 26 additions & 8 deletions lib/primesieve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <atomic>
#include <stdint.h>
int main() {
std::atomic<int> x;
std::atomic<int64_t> 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 <atomic>
#include <stdint.h>
int main() {
std::atomic<int32_t> 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})
Expand Down
5 changes: 5 additions & 0 deletions lib/primesieve/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
==================================

Expand Down

0 comments on commit 3b5cb90

Please sign in to comment.