Skip to content

Commit

Permalink
Merge pull request #1 from eschnett/eschnett/travis
Browse files Browse the repository at this point in the history
Add Travis self-testing
  • Loading branch information
eschnett committed Apr 9, 2017
2 parents 477f9c8 + 34c05ce commit 109c9da
Show file tree
Hide file tree
Showing 10 changed files with 726 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -19,3 +19,5 @@ instantiations
.ninja_deps
interp
example_float
build
vectorclass
30 changes: 30 additions & 0 deletions .travis.yml
@@ -0,0 +1,30 @@
# General settings
notifications:
email: false
sudo: false
dist: trusty

# Build matrix
os:
- linux
- osx
language: cpp
compiler:
- clang
- gcc

# Install, build, and test
script:
- mkdir build && pushd build
- cmake -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_CXX_FLAGS="-march=native" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="$HOME/install" ..
- make -j2
- make -j2 test CTEST_OUTPUT_ON_FAILURE=1
- make -j2 install
- popd
after_success:
- mkdir -p "$HOME/bin" && ln -s "$(which $GCOV)" "$HOME/bin/gcov" && ls -l "$HOME/bin" && export PATH="$HOME/bin:$PATH" && hash -r
- mkdir build-coveralls && pushd build-coveralls
- cmake -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_CXX_FLAGS="-march=native" -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=ON ..
- make -j2
- make -j2 coveralls CTEST_OUTPUT_ON_FAILURE=1
- popd
File renamed without changes.
96 changes: 93 additions & 3 deletions CMakeLists.txt
@@ -1,14 +1,104 @@
# See file "BUILD" for instructions

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.1)
cmake_policy(SET CMP0048 NEW)

project (vecmathlib)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)

project(VecMathLib VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules")

option(COVERALLS "Generate coveralls data" OFF)

# External dependencies

if(COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()

# Main project

set(HEADERS
floatbuiltins.h
floatprops.h
floattypes.h
mathfuncs.h
mathfuncs_asin.h
mathfuncs_asinh.h
mathfuncs_base.h
mathfuncs_convert.h
mathfuncs_exp.h
mathfuncs_fabs.h
mathfuncs_int.h
mathfuncs_log.h
mathfuncs_pow.h
mathfuncs_rcp.h
mathfuncs_sin.h
mathfuncs_sinh.h
mathfuncs_sqrt.h
vec_altivec_float4.h
vec_avx_double4.h
vec_avx_float8.h
vec_avx_fp16_16.h
vec_avx_fp8_32.h
vec_base.h
vec_builtin.h
vec_mask.h
vec_mic_double8.h
vec_neon_float2.h
vec_neon_float4.h
vec_pseudo.h
vec_qpx_double4.h
vec_sse_double1.h
vec_sse_double2.h
vec_sse_float1.h
vec_sse_float4.h
vec_test.h
vec_vsx_double2.h
vecmathlib.h
)

add_executable (example example.cc)
add_executable (example_float example_float.cc)
add_executable (loop loop.cc)
add_executable (interp interp.cc)
add_executable (selftest selftest.cc)
add_executable (bench bench.cc)

add_library (instantiations instantiations.cc)

# Tests

add_executable (selftest selftest.cc)
enable_testing()
add_test(NAME selftest COMMAND ./selftest)

# Coverage

if(COVERALLS)
# Create the coveralls target
set(COVERALLS_SRCS "")
foreach(src ${HEADERS})
list(APPEND COVERALLS_SRCS "${PROJECT_SOURCE_DIR}/${src}")
endforeach()
coveralls_setup("${COVERALLS_SRCS}" ON "${PROJECT_SOURCE_DIR}/cmake/Modules")
endif()

# Install

install(FILES ${HEADERS} DESTINATION include/vecmathlib)

set(PKG_CONFIG_REQUIRES "")
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/vecmathlib")
set(PKG_CONFIG_LIBDIR "\${prefix}/lib")
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
set(PKG_CONFIG_LIBS "")

configure_file(
"${PROJECT_SOURCE_DIR}/pkg-config.pc.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc"
)

install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION lib/pkgconfig)
12 changes: 11 additions & 1 deletion README → README.rst
@@ -1,4 +1,7 @@
[From the wiki at <https://bitbucket.org/eschnett/vecmathlib/wiki/Home>:]
VecMathLib: SIMD vector operations and vectorizable math functions
==================================================================

|Build Status| |Code Coverage|

Vecmathlib provides efficient, accurate, tunable, and most importantly
vectorizable math functions such as sqrt, sin, or atan.
Expand All @@ -12,6 +15,7 @@ vecmathlib's algorithms are efficient on standard CPUs.


Implementation
==============

Vecmathlib consists of three parts:

Expand Down Expand Up @@ -42,6 +46,7 @@ architectures where they are otherwise not available.


Things To Do
============

Vecmathlib is not finished. Contributions are welcome! There are
several areas where it can be improved:
Expand All @@ -58,3 +63,8 @@ several areas where it can be improved:
them element-wise via libc's scalar functions
8. handle inf, nan, negative zero, rounding modes, and everything else
required for IEEE compliance (if -ffast-math is not used)

.. |Build Status| image:: https://travis-ci.org/eschnett/VecMathLib.svg?branch=master
:target: https://travis-ci.org/eschnett/VecMathLib
.. |Code Coverage| image:: https://coveralls.io/repos/github/eschnett/VecMathLib/badge.svg?branch=master
:target: https://coveralls.io/github/eschnett/VecMathLib?branch=master
124 changes: 124 additions & 0 deletions cmake/Modules/Coveralls.cmake
@@ -0,0 +1,124 @@
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#


#
# Param _COVERAGE_SRCS A list of source files that coverage should be collected for.
# Param _COVERALLS_UPLOAD Upload the result to coveralls?
#
function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)

if (ARGC GREATER 2)
set(_CMAKE_SCRIPT_PATH ${ARGN})
message("Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}")
else()
set(_CMAKE_SCRIPT_PATH ${PROJECT_SOURCE_DIR}/cmake)
endif()

if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
endif()

if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
endif()

# When passing a CMake list to an external process, the list
# will be converted from the format "1;2;3" to "1 2 3".
# This means the script we're calling won't see it as a list
# of sources, but rather just one long path. We remedy this
# by replacing ";" with "*" and then reversing that in the script
# that we're calling.
# http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html
set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS})
set(COVERAGE_SRCS "")
foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP})
set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}")
endforeach()

#message("Coverage sources: ${COVERAGE_SRCS}")
set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)

add_custom_target(coveralls_generate

# Zero the coverage counters.
COMMAND ${CMAKE_COMMAND}
-P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake"

# Run regress tests.
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure

# Generate Gcov and translate it into coveralls JSON.
# We do this by executing an external CMake script.
# (We don't want this to run at CMake generation time, but after compilation and everything has run).
COMMAND ${CMAKE_COMMAND}
-DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c"
-DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
-DCOV_PATH="${PROJECT_BINARY_DIR}"
-DPROJECT_ROOT="${PROJECT_SOURCE_DIR}"
-P "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake"

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating coveralls output..."
)

if (_COVERALLS_UPLOAD)
message("COVERALLS UPLOAD: ON")

find_program(CURL_EXECUTABLE curl)

if (NOT CURL_EXECUTABLE)
message(FATAL_ERROR "Coveralls: curl not found! Aborting")
endif()

add_custom_target(coveralls_upload
# Upload the JSON to coveralls.
COMMAND ${CURL_EXECUTABLE}
-S -F json_file=@${COVERALLS_FILE}
https://coveralls.io/api/v1/jobs

DEPENDS coveralls_generate

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Uploading coveralls output...")

add_custom_target(coveralls DEPENDS coveralls_upload)
else()
message("COVERALLS UPLOAD: OFF")
add_custom_target(coveralls DEPENDS coveralls_generate)
endif()

endfunction()

macro(coveralls_turn_on_coverage)
if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
endif()

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endmacro()
23 changes: 23 additions & 0 deletions cmake/Modules/CoverallsClear.cmake
@@ -0,0 +1,23 @@
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#

file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda)

0 comments on commit 109c9da

Please sign in to comment.