diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e1052e2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,125 @@ +# Ubuntu name decoder ring; https://en.wikipedia.org/wiki/List_of_Ubuntu_releases +# Ubuntu 12.04 LTS (Precise Pangolin) <== Travis CI VM image +# Ubuntu 12.10 (Quantal Quetzal) +# Ubuntu 13.04 (Raring Ringtail) +# Ubuntu 13.10 (Saucy Salamander) +# Ubuntu 14.04 LTS (Trusty Tahr) +# Ubuntu 14.10 (Utopic Unicorn) +# Ubuntu 15.04 (Vivid Vervet) +# Ubuntu 15.10 (Wily Werewolf) +# Ubuntu 16.04 LTS (Xenial Xantus) + +# language: instructs travis what compilers && environment to set up in build matrix +language: cpp + +# sudo: false instructs travis to build our project in a docker VM (faster) +# Can not yet install fglrx packages with 'false' +sudo: required # false + +# os: expands the build matrix to include multiple os's +# disable linux, as we get sporadic failures on building boost, needs investigation +os: +# - linux + - osx + +# compiler: expands the build matrix to include multiple compilers (per os) +compiler: + - gcc + - clang + +addons: + # apt: is disabled on osx builds + # apt: needed by docker framework to install project dependencies without + # sudo. Apt uses published Ubunto PPA's from https://launchpad.net/ + # https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json + apt: + sources: + # ubuntu-toolchain-r-test contains newer versions of gcc to install + - ubuntu-toolchain-r-test + # llvm-toolchain-precise-3.6 contains newer versions of clang to install + # - llvm-toolchain-precise-3.6 + # kubuntu-backports contains newer versions of cmake to install + - kubuntu-backports + # boost-latest contains boost v1.55 + # - boost-latest + packages: + # g++-4.8 is minimum version considered to be the first good c++11 gnu compiler + - g++-4.8 + # - clang-3.6 + # We require v2.8.12 minimum + - cmake + # I'm finding problems between pre-compiled versions of boost ublas, with gtest + # stl_algobase.h: error: no matching function for call to swap() + # - libboost-program-options1.55-dev + # - libboost-serialization1.55-dev + # - libboost-filesystem1.55-dev + # - libboost-system1.55-dev + # - libboost-regex1.55-dev + # The package opencl-headers on 'precise' only installs v1.1 cl headers; uncomment for 'trusty' or greater +# - opencl-headers + # Uncomment one of the following when fglrx modules are added to the apt whitelist +# - fglrx +# - fglrx=2:8.960-0ubuntu1 +# - fglrx=2:13.350.1-0ubuntu0.0.1 + +# env: specifies additional global variables to define per row in build matrix +env: + global: + - CLSPARSE_ROOT=${TRAVIS_BUILD_DIR}/bin/make/release + +# The following filters our build matrix; we are interested in linux-gcc & osx-clang +matrix: + exclude: + - os: linux + compiler: clang + - os: osx + compiler: gcc + +before_install: + # Remove the following linux clause when fglrx can be installed with sudo: false + - if [ ${TRAVIS_OS_NAME} == "linux" ]; then + sudo apt-get update -qq && + sudo apt-get install -qq fglrx=2:13.350.1-0ubuntu0.0.1; + fi + - if [ ${TRAVIS_OS_NAME} == "linux" ]; then + export OPENCL_ROOT="${TRAVIS_BUILD_DIR}/opencl-headers"; + export BUILD_BOOST="ON"; + fi + - if [ ${TRAVIS_OS_NAME} == "osx" ]; then + brew update; + brew outdated boost || brew upgrade boost; + brew outdated cmake || brew upgrade cmake; + export BUILD_BOOST="OFF"; + fi + - if [ ${CXX} = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi + - cmake --version; + - ${CC} --version; + - ${CXX} --version; + +install: + # 'Precise' only distributes v1.1 opencl headers; download 1.2 headers from khronos website + # Remove when the travis VM upgrades to 'trusty' or beyond + - if [ ${TRAVIS_OS_NAME} == "linux" ]; then + mkdir -p ${OPENCL_ROOT}/include/CL; + pushd ${OPENCL_ROOT}/include/CL; + wget -w 1 -r -np -nd -nv -A h,hpp https://www.khronos.org/registry/cl/api/1.2/; + popd; + fi + # osx image does not contain cl.hpp file; download from Khronos + - if [ ${TRAVIS_OS_NAME} == "osx" ]; then + pushd /System/Library/Frameworks/OpenCL.framework/Versions/A/Headers/; + sudo wget -w 1 -np -nd -nv -A h,hpp https://www.khronos.org/registry/cl/api/1.2/cl.hpp; + popd; + fi + +# Use before_script: to run configure steps +before_script: + - mkdir -p ${CLSPARSE_ROOT} + - pushd ${CLSPARSE_ROOT} + - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_Boost=${BUILD_BOOST} -DBUILD_gMock=ON -DBUILD_clSPARSE=ON -DBUILD_SAMPLES=ON ${TRAVIS_BUILD_DIR} + +# use script: to execute build steps +script: + - make + - cd clSPARSE-build + - make package diff --git a/CMakeLists.txt b/CMakeLists.txt index 59f4ea7..67aa57e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ cmake_minimum_required( VERSION 2.8.10 ) if( POLICY CMP0048 ) cmake_policy( SET CMP0048 NEW ) - project( SuperBuild.clSPARSE VERSION 0.6.1.0 ) + project( SuperBuild.clSPARSE VERSION 0.6.2.0 ) else( ) project( SuperBuild.clSPARSE ) @@ -42,7 +42,7 @@ else( ) endif( ) if( NOT DEFINED SuperBuild.clSPARSE_VERSION_PATCH ) - set( SuperBuild.clSPARSE_VERSION_PATCH 1 ) + set( SuperBuild.clSPARSE_VERSION_PATCH 2 ) endif( ) if( NOT DEFINED SuperBuild.clSPARSE_VERSION_TWEAK ) @@ -91,6 +91,7 @@ set_property( CACHE BUILD_CLVERSION PROPERTY STRINGS 2.0 1.2 1.1 ) # Comment this out because this does not work yet set( clSPARSE.Dependencies ) set( clSPARSE.Cmake.Args ) +set( clSPARSE.Samples.Cmake.Args ) # If the user selects, download, uncompress, and setup Boost if( BUILD_Boost ) @@ -100,13 +101,12 @@ if( BUILD_Boost ) list( APPEND clSPARSE.Dependencies Boost ) list( APPEND clSPARSE.Cmake.Args -DBOOST_ROOT=${BOOST_ROOT} ) else( ) - if( NOT DEFINED BOOST_ROOT AND NOT DEFINED ENV{BOOST_ROOT} ) - message( SEND_ERROR "BOOST_ROOT must be provided if BUILD_Boost is disabled" ) + if( WIN32 AND (NOT DEFINED BOOST_ROOT AND NOT DEFINED ENV{BOOST_ROOT}) ) + message( WARNING "BOOST_ROOT should be provided if Boost is not in a default location" ) else( ) - if( NOT DEFINED BOOST_ROOT ) - set( BOOST_ROOT "$ENV{BOOST_ROOT}" ) + if( DEFINED BOOST_ROOT ) + list( APPEND clSPARSE.Cmake.Args -DBOOST_ROOT=${BOOST_ROOT} ) endif( ) - list( APPEND clSPARSE.Cmake.Args -DBOOST_ROOT=${BOOST_ROOT} ) endif( ) endif( ) @@ -129,6 +129,12 @@ else( ) endif( ) endif( ) +# Pass OPENCL_ROOT along to subproject if users provides path +if( DEFINED OPENCL_ROOT ) + list( APPEND clSPARSE.Cmake.Args -DOPENCL_ROOT=${OPENCL_ROOT} ) + list( APPEND clSPARSE.Samples.Cmake.Args -DOPENCL_ROOT=${OPENCL_ROOT} ) +endif( ) + # If the user selects, download, uncompress, and setup clBLAS #if( BUILD_clBLAS ) # message( STATUS "Setting up clBLAS external..." ) @@ -198,7 +204,7 @@ if( BUILD_clSPARSE OR BUILD_SAMPLES ) DEPENDS clSPARSE SOURCE_DIR ${PROJECT_SOURCE_DIR}/samples BINARY_DIR clSPARSE-samples-build - CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_CLVERSION=${BUILD_CLVERSION} -DBUILD64=${BUILD64} -DCMAKE_PREFIX_PATH=${install_dir} + CMAKE_ARGS ${clSPARSE.Samples.Cmake.Args} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_CLVERSION=${BUILD_CLVERSION} -DBUILD64=${BUILD64} -DCMAKE_PREFIX_PATH=${install_dir} EXCLUDE_FROM_ALL 1 INSTALL_COMMAND "" ) diff --git a/README.md b/README.md index b5b45a5..8574cb3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ +## Build Status Pre-built binaries are available on our [releases page](https://github.com/clMathLibraries/clSPARSE/releases) +| Build branch | master | develop | +|-----|-----|-----| +| Linux/OSX x64 | [![Build Status](https://travis-ci.org/clMathLibraries/clSPARSE.svg?branch=master)](https://travis-ci.org/clMathLibraries/clSPARSE) |[![Build Status](https://travis-ci.org/clMathLibraries/clSPARSE.svg?branch=develop)](https://travis-ci.org/clMathLibraries/clSPARSE) | + # clSPARSE an OpenCL© library implementing Sparse linear algebra. This project is a result of a collaboration between [AMD Inc.](http://www.amd.com/) and diff --git a/cmake/ExternalBoost.cmake b/cmake/ExternalBoost.cmake index 659cad1..d207a9f 100644 --- a/cmake/ExternalBoost.cmake +++ b/cmake/ExternalBoost.cmake @@ -1,12 +1,12 @@ # ######################################################################## # Copyright 2015 Advanced Micro Devices, Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,8 +44,8 @@ endif( ) set( Boost.Command ./b2 --prefix=/package ) if( CMAKE_COMPILER_IS_GNUCXX ) - list( APPEND Boost.Command cxxflags=-fPIC ) -elseif( XCODE_VERSION ) + list( APPEND Boost.Command cxxflags=-fPIC -std=c++11 ) +elseif( XCODE_VERSION OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang") ) list( APPEND Boost.Command cxxflags=-std=c++11 -stdlib=libc++ linkflags=-stdlib=libc++ ) endif( ) @@ -77,6 +77,18 @@ elseif( MSVC14 ) list( APPEND Boost.Command toolset=msvc-14.0 ) elseif( XCODE_VERSION ) list( APPEND Boost.Command toolset=clang ) +elseif( DEFINED ENV{CC} ) + # CMake apprarently puts the full path of the compiler into CC + # The user might specify a non-default gcc compiler through ENV + message( STATUS "ENV{CC}=$ENV{CC}" ) + get_filename_component( gccToolset $ENV{CC} NAME ) + + # see: https://svn.boost.org/trac/boost/ticket/5917 + string( TOLOWER ${gccToolset} gccToolset ) + if( gccToolset STREQUAL "cc") + set( gccToolset "gcc" ) + endif( ) + list( APPEND Boost.Command toolset=${gccToolset} ) endif( ) if( WIN32 ) @@ -148,9 +160,11 @@ ExternalProject_Add( URL ${ext.Boost_URL} URL_MD5 ${ext.MD5_HASH} UPDATE_COMMAND ${Boost.Bootstrap} + LOG_UPDATE 1 CONFIGURE_COMMAND "" BUILD_COMMAND ${Boost.Command} BUILD_IN_SOURCE 1 + LOG_BUILD 1 INSTALL_COMMAND "" ) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 968d3a2..779d787 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,6 +1,6 @@ # ######################################################################## # Copyright 2015 Vratis, Ltd. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -32,6 +32,11 @@ list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) find_package( clSPARSE REQUIRED CONFIG ) message( STATUS "clSPARSE INCLUDES = ${clSPARSE_INCLUDE_DIR}") +# Query the user for which version of OpenCL they wish to build the library for +set( BUILD_CLVERSION "1.2" CACHE STRING "The version of OpenCL we wish to compile the samples against" ) +set_property( CACHE BUILD_CLVERSION PROPERTY STRINGS 2.0 1.2 1.1 ) +message( STATUS "clSPARSE samples are building using CL interface ='${BUILD_CLVERSION}'" ) + # Find OpenCL find_package( OpenCL ${BUILD_CLVERSION} REQUIRED ) message( STATUS "OPENCL_INCLUDE_DIRS = ${OPENCL_INCLUDE_DIRS}") diff --git a/samples/cmake/FindOpenCL.cmake b/samples/cmake/FindOpenCL.cmake index dfbff75..120f38a 100644 --- a/samples/cmake/FindOpenCL.cmake +++ b/samples/cmake/FindOpenCL.cmake @@ -1,12 +1,12 @@ # ######################################################################## # Copyright 2015 Advanced Micro Devices, Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,7 +14,6 @@ # limitations under the License. # ######################################################################## - # Locate an OpenCL implementation. # Currently supports AMD APP SDK (http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx/) # @@ -49,10 +48,15 @@ include( CheckSymbolExists ) include( CMakePushCheckState ) +if( DEFINED OPENCL_ROOT OR DEFINED ENV{OPENCL_ROOT}) + message( STATUS "Defined OPENCL_ROOT: ${OPENCL_ROOT}, ENV{OPENCL_ROOT}: $ENV{OPENCL_ROOT}" ) +endif( ) + find_path(OPENCL_INCLUDE_DIRS NAMES OpenCL/cl.h CL/cl.h HINTS ${OPENCL_ROOT}/include + $ENV{OPENCL_ROOT}/include $ENV{AMDAPPSDKROOT}/include $ENV{CUDA_PATH}/include PATHS @@ -107,6 +111,7 @@ if( LIB64 ) NAMES OpenCL HINTS ${OPENCL_ROOT}/lib + $ENV{OPENCL_ROOT}/lib $ENV{AMDAPPSDKROOT}/lib $ENV{CUDA_PATH}/lib DOC "OpenCL dynamic library path" @@ -119,6 +124,7 @@ else( ) NAMES OpenCL HINTS ${OPENCL_ROOT}/lib + $ENV{OPENCL_ROOT}/lib $ENV{AMDAPPSDKROOT}/lib $ENV{CUDA_PATH}/lib DOC "OpenCL dynamic library path" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1478b70..b723d7f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,7 @@ endif( ) # clSPARSE becomes the name of the project with a particular version if( POLICY CMP0048 ) cmake_policy( SET CMP0048 NEW ) - project( clSPARSE VERSION 0.6.1.0 LANGUAGES C CXX ) + project( clSPARSE VERSION 0.6.2.0 LANGUAGES C CXX ) else( ) project( clSPARSE C CXX ) # Define a version for the code @@ -44,7 +44,7 @@ else( ) endif( ) if( NOT DEFINED clSPARSE_VERSION_PATCH ) - set( clSPARSE_VERSION_PATCH 1 ) + set( clSPARSE_VERSION_PATCH 2 ) endif( ) if( NOT DEFINED clSPARSE_VERSION_TWEAK ) diff --git a/src/benchmarks/CMakeLists.txt b/src/benchmarks/CMakeLists.txt index 2654e1f..8f12914 100644 --- a/src/benchmarks/CMakeLists.txt +++ b/src/benchmarks/CMakeLists.txt @@ -1,12 +1,12 @@ # ######################################################################## # Copyright 2015 Advanced Micro Devices, Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,11 +15,35 @@ # ######################################################################## +message( STATUS "Configuring benchmarks sub-dir" ) + +# If user provides a specific boost path through command line, make sure to +# use that +if( DEFINED BOOST_ROOT OR DEFINED ENV{BOOST_ROOT} ) + set( Boost_NO_SYSTEM_PATHS ON ) + set( Boost_NO_BOOST_CMAKE ON ) + + # Workaround for a somewhat limiting find_package( Boost ) on MSVC platforms. + # Boost uses the prefix 'lib' for static libraries on windows, but it will + # not search with that prefix unless Boost_USE_STATIC_LIBS is set. However, other + # than a priori knowledge, a user does not know to set Boost_USE_STATIC_LIBS. + # Attempt to do a basic check on windows, which may/may not work in all cases + if( MSVC ) + file( GLOB Boost.static.env.libs RELATIVE "$ENV{BOOST_ROOT}/lib" "$ENV{BOOST_ROOT}/lib/lib*.lib" ) + file( GLOB Boost.static.define.libs RELATIVE "${BOOST_ROOT}/lib" "${BOOST_ROOT}/lib/lib*.lib" ) + list( LENGTH Boost.static.env.libs num.static.env.libs ) + list( LENGTH Boost.static.define.libs num.static.define.libs ) + math( EXPR Boost.num.static.libs "${num.static.env.libs} + ${num.static.define.libs} " ) + if( Boost.num.static.libs ) + message( STATUS "Detected MSVC boost static libs" ) + set( Boost_USE_STATIC_LIBS ON ) + endif( ) + endif( ) +endif( ) + set( Boost_USE_MULTITHREADED ON ) -set( Boost_USE_STATIC_LIBS ON ) set( Boost_DETAILED_FAILURE_MSG ON ) -set( Boost_NO_SYSTEM_PATHS ON ) -set( Boost_ADDITIONAL_VERSIONS 1.57.0 1.57 ) +set( Boost_ADDITIONAL_VERSIONS 1.58.0 1.58 1.57.0 1.57 ) # set( Boost_DEBUG ON ) find_package( Boost COMPONENTS program_options filesystem regex system ) diff --git a/src/cmake/FindOpenCL.cmake b/src/cmake/FindOpenCL.cmake index d98f506..120f38a 100644 --- a/src/cmake/FindOpenCL.cmake +++ b/src/cmake/FindOpenCL.cmake @@ -1,6 +1,6 @@ # ######################################################################## # Copyright 2015 Advanced Micro Devices, Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -48,10 +48,15 @@ include( CheckSymbolExists ) include( CMakePushCheckState ) +if( DEFINED OPENCL_ROOT OR DEFINED ENV{OPENCL_ROOT}) + message( STATUS "Defined OPENCL_ROOT: ${OPENCL_ROOT}, ENV{OPENCL_ROOT}: $ENV{OPENCL_ROOT}" ) +endif( ) + find_path(OPENCL_INCLUDE_DIRS NAMES OpenCL/cl.h CL/cl.h HINTS ${OPENCL_ROOT}/include + $ENV{OPENCL_ROOT}/include $ENV{AMDAPPSDKROOT}/include $ENV{CUDA_PATH}/include PATHS @@ -106,6 +111,7 @@ if( LIB64 ) NAMES OpenCL HINTS ${OPENCL_ROOT}/lib + $ENV{OPENCL_ROOT}/lib $ENV{AMDAPPSDKROOT}/lib $ENV{CUDA_PATH}/lib DOC "OpenCL dynamic library path" @@ -118,6 +124,7 @@ else( ) NAMES OpenCL HINTS ${OPENCL_ROOT}/lib + $ENV{OPENCL_ROOT}/lib $ENV{AMDAPPSDKROOT}/lib $ENV{CUDA_PATH}/lib DOC "OpenCL dynamic library path" diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 99b7ab5..5e7e32e 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -251,7 +251,7 @@ add_library( clSPARSE ${clSPARSE_LIBRARY_TYPE} ) # PRIVATE linking prevents transitive library linking of the clBLAS libraries -target_link_libraries( clSPARSE PRIVATE ${OPENCL_LIBRARIES} ) #${clBLAS_LIBRARIES} ) +target_link_libraries( clSPARSE PRIVATE ${OPENCL_LIBRARIES} ${CMAKE_DL_LIBS} ) #${clBLAS_LIBRARIES} ) # Package that helps me set visibility for function names exported from shared library GENERATE_EXPORT_HEADER( clSPARSE ) @@ -299,7 +299,7 @@ include( CMakePackageConfigHelpers ) set( LIB_INSTALL_DIR lib${SUFFIX_LIB} ) set( INCLUDE_INSTALL_DIR include ) -set( ConfigPackageLocation ${LIB_INSTALL_DIR}/clSPARSE/cmake ) +set( ConfigPackageLocation ${LIB_INSTALL_DIR}/cmake/clSPARSE ) configure_package_config_file( clSPARSEConfig.cmake.in diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 465ec3f..876910c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,7 +1,7 @@ # ######################################################################## # Copyright 2015 Advanced Micro Devices, Inc. # Copyright 2015 Vratis, Ltd. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -15,17 +15,41 @@ # limitations under the License. # ######################################################################## +message( STATUS "Configuring tests subdir" ) find_package( GTest REQUIRED ) +# If user provides a specific boost path through command line, make sure to +# use that +if( DEFINED BOOST_ROOT OR DEFINED ENV{BOOST_ROOT} ) + set( Boost_NO_SYSTEM_PATHS ON ) + set( Boost_NO_BOOST_CMAKE ON ) + + # Workaround for a somewhat limiting find_package( Boost ) on MSVC platforms. + # Boost uses the prefix 'lib' for static libraries on windows, but it will + # not search with that prefix unless Boost_USE_STATIC_LIBS is set. However, other + # than a priori knowledge, a user does not know to set Boost_USE_STATIC_LIBS. + # Attempt to do a basic check on windows, which may/may not work in all cases + if( MSVC ) + file( GLOB Boost.static.env.libs RELATIVE "$ENV{BOOST_ROOT}/lib" "$ENV{BOOST_ROOT}/lib/lib*.lib" ) + file( GLOB Boost.static.define.libs RELATIVE "${BOOST_ROOT}/lib" "${BOOST_ROOT}/lib/lib*.lib" ) + list( LENGTH Boost.static.env.libs num.static.env.libs ) + list( LENGTH Boost.static.define.libs num.static.define.libs ) + math( EXPR Boost.num.static.libs "${num.static.env.libs} + ${num.static.define.libs} " ) + if( Boost.num.static.libs ) + message( STATUS "Detected MSVC boost static libs" ) + set( Boost_USE_STATIC_LIBS ON ) + endif( ) + endif( ) +endif( ) + set( Boost_USE_MULTITHREADED ON ) -set( Boost_USE_STATIC_LIBS ON ) set( Boost_DETAILED_FAILURE_MSG ON ) -set( Boost_NO_SYSTEM_PATHS ON ) -set( Boost_ADDITIONAL_VERSIONS 1.57.0 1.57 ) +set( Boost_ADDITIONAL_VERSIONS 1.58.0 1.58 1.57.0 1.57 ) # set( Boost_DEBUG ON ) find_package( Boost COMPONENTS program_options serialization ) + # Unit tests requires OpenCL # A standard FindOpenCL.cmake module ships with cmake 3.1, buy we supply our own until 3.1 becomes more prevalent find_package( OpenCL REQUIRED ) @@ -35,6 +59,7 @@ find_package( OpenCL REQUIRED ) include_directories( ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/library + ${PROJECT_BINARY_DIR}/include resources #resources/uBLAS-linalg ${GTEST_INCLUDE_DIRS} diff --git a/src/tests/test-clsparse-utils.cpp b/src/tests/test-clsparse-utils.cpp index 588b474..13cafb7 100644 --- a/src/tests/test-clsparse-utils.cpp +++ b/src/tests/test-clsparse-utils.cpp @@ -19,48 +19,49 @@ #include "opencl_utils.h" #include "../library/internal/ocl-type-traits.hpp" +#include "clSPARSE-version.h" -TEST (clSparseTraits, cl_mem_type) +TEST( clSparseTraits, cl_mem_type ) { bool is_fundamental = is_pointer_fundamental::value; - ASSERT_EQ(false, is_fundamental); + ASSERT_EQ( false, is_fundamental ); } -TEST (clSparseTraits, non_cl_mem_type) +TEST( clSparseTraits, non_cl_mem_type ) { bool is_fundamental = is_pointer_fundamental::value; - ASSERT_EQ(true, is_fundamental); + ASSERT_EQ( true, is_fundamental ); } -TEST (clSparseInit, setup) +TEST( clSparseInit, setup ) { - clsparseStatus status = clsparseSetup(); + clsparseStatus status = clsparseSetup( ); - EXPECT_EQ(clsparseSuccess, status); + EXPECT_EQ( clsparseSuccess, status ); } -TEST (clSparseInit, teardown) +TEST( clSparseInit, teardown ) { - clsparseSetup(); - clsparseStatus status = clsparseTeardown(); + clsparseSetup( ); + clsparseStatus status = clsparseTeardown( ); - EXPECT_EQ (clsparseSuccess, status); + EXPECT_EQ( clsparseSuccess, status ); } -TEST (clSparseInit, version) +TEST( clSparseInit, version ) { cl_uint major = 3, minor = 3, patch = 3, tweak = 3; - clsparseGetVersion (&major, &minor, &patch, &tweak ); + clsparseGetVersion( &major, &minor, &patch, &tweak ); - EXPECT_EQ (0, major); - EXPECT_EQ (6, minor); - EXPECT_EQ (0, patch); - EXPECT_EQ( 0, tweak ); + EXPECT_EQ( clsparseVersionMajor, major ); + EXPECT_EQ( clsparseVersionMinor, minor ); + EXPECT_EQ( clsparseVersionPatch, patch ); + EXPECT_EQ( clsparseVersionTweak, tweak ); } -TEST (clsparseInit, control) +TEST( clsparseInit, control ) { // init cl environment @@ -68,23 +69,23 @@ TEST (clsparseInit, control) cl_platform_id* platforms = NULL; cl_uint num_platforms = 0; - status = getPlatforms(&platforms, &num_platforms); - ASSERT_EQ(CL_SUCCESS, status); + status = getPlatforms( &platforms, &num_platforms ); + ASSERT_EQ( CL_SUCCESS, status ); //printPlatforms(platforms, num_platforms); cl_device_id device = NULL; - status = getDevice(platforms[0], &device, CL_DEVICE_TYPE_GPU); - ASSERT_EQ(CL_SUCCESS, status); + status = getDevice( platforms[ 0 ], &device, CL_DEVICE_TYPE_GPU ); + ASSERT_EQ( CL_SUCCESS, status ); //printDeviceInfo(device); - auto context = clCreateContext(NULL, 1, &device, NULL, NULL, NULL); - auto queue = clCreateCommandQueue(context, device, 0, NULL); + auto context = clCreateContext( NULL, 1, &device, NULL, NULL, NULL ); + auto queue = clCreateCommandQueue( context, device, 0, NULL ); clsparseSetup( ); - auto control = clsparseCreateControl(queue, NULL); + auto control = clsparseCreateControl( queue, NULL ); clsparseReleaseControl( control ); clsparseTeardown( ); @@ -95,7 +96,7 @@ TEST (clsparseInit, control) } -TEST (clsparseInit, cpp_interface) +TEST( clsparseInit, cpp_interface ) { // Init OpenCL environment; cl_int cl_status; @@ -103,90 +104,90 @@ TEST (clsparseInit, cpp_interface) // Get OpenCL platforms std::vector platforms; - cl_status = cl::Platform::get(&platforms); + cl_status = cl::Platform::get( &platforms ); - if (cl_status != CL_SUCCESS) + if( cl_status != CL_SUCCESS ) { std::cout << "Problem with getting OpenCL platforms" - << " [" << cl_status << "]" << std::endl; - ASSERT_EQ(CL_SUCCESS, cl_status); + << " [" << cl_status << "]" << std::endl; + ASSERT_EQ( CL_SUCCESS, cl_status ); } int platform_id = 0; - for (const auto& p : platforms) + for( const auto& p : platforms ) { std::cout << "Platform ID " << platform_id++ << " : " - << p.getInfo() << std::endl; + << p.getInfo( ) << std::endl; } // Using first platform platform_id = 0; - cl::Platform platform = platforms[platform_id]; + cl::Platform platform = platforms[ platform_id ]; // Get device from platform std::vector devices; - cl_status = platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + cl_status = platform.getDevices( CL_DEVICE_TYPE_GPU, &devices ); - if (cl_status != CL_SUCCESS) + if( cl_status != CL_SUCCESS ) { std::cout << "Problem with getting devices from platform" - << " [" << platform_id << "] " << platform.getInfo() - << " error: [" << cl_status << "]" << std::endl; - ASSERT_EQ(CL_SUCCESS, cl_status); + << " [" << platform_id << "] " << platform.getInfo( ) + << " error: [" << cl_status << "]" << std::endl; + ASSERT_EQ( CL_SUCCESS, cl_status ); } std::cout << std::endl - << "Getting devices from platform " << platform_id << std::endl; + << "Getting devices from platform " << platform_id << std::endl; cl_int device_id = 0; - for (const auto& device : devices) + for( const auto& device : devices ) { std::cout << "Device ID " << device_id++ << " : " - << device.getInfo() << std::endl; + << device.getInfo( ) << std::endl; } // Using first device; device_id = 0; - cl::Device device = devices[device_id]; + cl::Device device = devices[ device_id ]; // Create OpenCL context; - cl::Context context (device); + cl::Context context( device ); // Create OpenCL queue; - cl::CommandQueue queue(context, device); + cl::CommandQueue queue( context, device ); - clsparseStatus status = clsparseSetup(); - if (status != clsparseSuccess) + clsparseStatus status = clsparseSetup( ); + if( status != clsparseSuccess ) { std::cout << "Problem with executing clsparseSetup()" << std::endl; - ASSERT_EQ(clsparseSuccess, status); + ASSERT_EQ( clsparseSuccess, status ); } // Create clsparseControl object - clsparseControl control = clsparseCreateControl(queue(), &status); - if (status != CL_SUCCESS) + clsparseControl control = clsparseCreateControl( queue( ), &status ); + if( status != CL_SUCCESS ) { std::cout << "Problem with creating clSPARSE control object" - <<" error [" << status << "]" << std::endl; - ASSERT_EQ(clsparseSuccess, status); + << " error [" << status << "]" << std::endl; + ASSERT_EQ( clsparseSuccess, status ); } //cleanup; - status = clsparseReleaseControl(control); - ASSERT_EQ(clsparseSuccess, status); + status = clsparseReleaseControl( control ); + ASSERT_EQ( clsparseSuccess, status ); - status = clsparseTeardown(); - ASSERT_EQ(clsparseSuccess, status); + status = clsparseTeardown( ); + ASSERT_EQ( clsparseSuccess, status ); } -int main(int argc, char* argv[]) +int main( int argc, char* argv[ ] ) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest( &argc, argv ); + return RUN_ALL_TESTS( ); } diff --git a/src/tests/test-conversion.cpp b/src/tests/test-conversion.cpp index 2e7623e..2ebcc7f 100644 --- a/src/tests/test-conversion.cpp +++ b/src/tests/test-conversion.cpp @@ -111,7 +111,7 @@ class MatrixConversion : public ::testing::Test for(int i = 0; i < ublas_dense.data().size(); i++) { // there should be exactly the same data - ASSERT_EQ(ublas_dense.data()[i], result[i]); + EXPECT_FLOAT_EQ(ublas_dense.data()[i], result[i]); } } @@ -136,7 +136,7 @@ class MatrixConversion : public ::testing::Test for(int i = 0; i < ublas_dense.data().size(); i++) { // there should be exactly the same data - ASSERT_EQ(ublas_dense.data()[i], result[i]); + EXPECT_DOUBLE_EQ(ublas_dense.data()[i], result[i]); } } } @@ -193,7 +193,7 @@ class MatrixConversion : public ::testing::Test ASSERT_EQ(CL_SUCCESS, cl_status); for (int i = 0; i < values.size(); i++) - ASSERT_EQ(CSRE::ublasSCsr.value_data()[i], values[i]); + EXPECT_FLOAT_EQ(CSRE::ublasSCsr.value_data()[i], values[i]); // Compare row_offsets @@ -272,7 +272,7 @@ class MatrixConversion : public ::testing::Test ASSERT_EQ(CL_SUCCESS, cl_status); for (int i = 0; i < values.size(); i++) - ASSERT_EQ(CSRE::ublasDCsr.value_data()[i], values[i]); + EXPECT_DOUBLE_EQ(CSRE::ublasDCsr.value_data()[i], values[i]); // Compare row_offsets @@ -369,7 +369,7 @@ class MatrixConversion : public ::testing::Test // Compare values; for (int i = 0; i < values.size(); i++) - ASSERT_EQ(values[i], CSRE::ublasSCsr.value_data()[i]); + EXPECT_FLOAT_EQ(values[i], CSRE::ublasSCsr.value_data()[i]); cl_status = ::clEnqueueReadBuffer(CLSE::queue, CSRE::csrSMatrix.colIndices, @@ -424,7 +424,7 @@ class MatrixConversion : public ::testing::Test // Compare values; for (int i = 0; i < values.size(); i++) - ASSERT_EQ(values[i], CSRE::ublasDCsr.value_data()[i]); + EXPECT_DOUBLE_EQ(values[i], CSRE::ublasDCsr.value_data()[i]); cl_status = ::clEnqueueReadBuffer(CLSE::queue, CSRE::csrDMatrix.colIndices, @@ -534,7 +534,7 @@ class MatrixConversion : public ::testing::Test ASSERT_EQ(CL_SUCCESS, cl_status); for (int i = 0; i < values.size(); i++) - ASSERT_EQ(ublas_coo.value_data()[i], values[i]); + EXPECT_FLOAT_EQ(ublas_coo.value_data()[i], values[i]); } @@ -590,7 +590,7 @@ class MatrixConversion : public ::testing::Test ASSERT_EQ(CL_SUCCESS, cl_status); for (int i = 0; i < values.size(); i++) - ASSERT_EQ(ublas_coo.value_data()[i], values[i]); + EXPECT_DOUBLE_EQ(ublas_coo.value_data()[i], values[i]); }