7 - DEPS_DIR=${TRAVIS_BUILD_DIR}/deps
12 - OPENCL_REGISTRY=https://www.khronos.org/registry/cl
13 - OPENCL_ROOT=${DEPS_DIR}/opencl
15 - POCL_BRANCH=release_0_13 # branch/tag
16 #- POCL_COMMIT= # commit id
17 - POCL_LLVM_VERSION=3.8.0
18 - POCL_LLVM_CONFIG=${DEPS_DIR}/llvm-${POCL_LLVM_VERSION}/bin/llvm-config
19 - POCL_CXX_COMPILER=${DEPS_DIR}/llvm-${POCL_LLVM_VERSION}/bin/clang++
20 - POCL_C_COMPILER=${DEPS_DIR}/llvm-${POCL_LLVM_VERSION}/bin/clang
22 - AMDAPPSDKROOT=${OPENCL_ROOT}/AMDAPPSDK
23 # Global build options and C++ flags
24 - CMAKE_OPTIONS="-DBOOST_COMPUTE_BUILD_TESTS=ON -DBOOST_COMPUTE_BUILD_EXAMPLES=ON -DBOOST_COMPUTE_BUILD_BENCHMARKS=ON -DBOOST_COMPUTE_USE_OFFLINE_CACHE=ON -DBOOST_COMPUTE_HAVE_OPENCV=ON -DBOOST_COMPUTE_THREAD_SAFE=ON"
25 - CXX_FLAGS="-Wall -pedantic -Werror -Wno-variadic-macros -Wno-long-long -Wno-shadow"
27 - BOOST_VERSION=default
34 ############################################################################
35 # POCL builds (OpenCL 1.0, 1.1)
36 ############################################################################
45 packages: &trusty_pocl_packages
47 # clang and llvm 3.7 for POCL (llvm-toolchain-trusty-3.7 is not whitelisted)
50 # - llvm-3.7-dev (...)
57 - libboost-chrono1.55-dev
58 - libboost-date-time1.55-dev
59 - libboost-test1.55-dev
60 - libboost-system1.55-dev
61 - libboost-filesystem1.55-dev
62 - libboost-timer1.55-dev
63 - libboost-program-options1.55-dev
64 - libboost-thread1.55-dev
69 sources: &trusty_pocl_sources
70 - ubuntu-toolchain-r-test
71 # - llvm-toolchain-trusty-3.7 (not whitelisted yet https://github.com/travis-ci/apt-source-whitelist/issues/199)
76 - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/pocl/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
83 packages: *trusty_pocl_packages
84 sources: *trusty_pocl_sources
89 - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/pocl/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
97 packages: *trusty_pocl_packages
98 sources: *trusty_pocl_sources
102 - OPENCL_VERSION="11"
103 - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/pocl/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
110 packages: *trusty_pocl_packages
111 sources: *trusty_pocl_sources
115 - OPENCL_VERSION="11"
116 - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/pocl/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
118 ############################################################################
119 # Khronos ICD builds (without running tests) (OpenCL 1.2, 2.0)
120 ############################################################################
122 # # Precise, OpenCL 1.2, Travis CI container-based infrastructure
128 # packages: &precise_icd_packages
131 # - libboost-chrono1.55-dev
132 # - libboost-date-time1.55-dev
133 # - libboost-test1.55-dev
134 # - libboost-system1.55-dev
135 # - libboost-filesystem1.55-dev
136 # - libboost-timer1.55-dev
137 # - libboost-program-options1.55-dev
138 # - libboost-thread1.55-dev
143 # sources: &precise_icd_sources
144 # - ubuntu-toolchain-r-test
145 # - llvm-toolchain-precise-3.7
149 # - OPENCL_LIB=khronos-icd
150 # - OPENCL_VERSION="12"
151 # - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
157 # packages: *precise_icd_packages
158 # sources: *precise_icd_sources
161 # - OPENCL_LIB=khronos-icd
162 # - OPENCL_VERSION="12"
163 # - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
164 # # Precise, OpenCL 2.0, Travis CI container-based infrastructure
170 # packages: *precise_icd_packages
171 # sources: *precise_icd_sources
174 # - OPENCL_LIB=khronos-icd
175 # - OPENCL_VERSION="20"
176 # - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
182 # packages: *precise_icd_packages
183 # sources: *precise_icd_sources
186 # - OPENCL_LIB=khronos-icd
187 # - OPENCL_VERSION="20"
188 # - ENV_CMAKE_OPTIONS="-DOpenCL_LIBRARY=${OPENCL_ROOT}/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
190 ############################################################################
191 # AMD APP SDK builds (v2.9.1 -> OpenCL 1.2, v3.0 -> OpenCL 2.0)
192 ############################################################################
194 # Precise, AMD APP SDK v2.9.1, Travis CI container-based infrastructure
200 packages: &precise_amdappsdk_packages
203 - libboost-chrono1.55-dev
204 - libboost-date-time1.55-dev
205 - libboost-test1.55-dev
206 - libboost-system1.55-dev
207 - libboost-filesystem1.55-dev
208 - libboost-timer1.55-dev
209 - libboost-program-options1.55-dev
210 - libboost-thread1.55-dev
215 sources: &precise_amdappsdk_sources
216 - ubuntu-toolchain-r-test
219 - OPENCL_LIB=amdappsdk
220 - OPENCL_VERSION="12"
221 - AMDAPPSDK_VERSION=291 # OpenCL 1.2
222 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
223 # Build is disabled as it's reduntant with the Coveralls build (see below)
229 # packages: *precise_amdappsdk_packages
230 # sources: *precise_amdappsdk_sources
232 # - OPENCL_LIB=amdappsdk
233 # - OPENCL_VERSION="12"
234 # - AMDAPPSDK_VERSION=291 # OpenCL 1.2
235 # - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
236 # Precise, AMD APP SDK v3.0, OpenCL 2.0, Travis CI container-based infrastructure
242 packages: *precise_amdappsdk_packages
243 sources: *precise_amdappsdk_sources
245 - OPENCL_LIB=amdappsdk
246 - OPENCL_VERSION="20"
247 - AMDAPPSDK_VERSION=300 # OpenCL 2.0
248 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
254 packages: *precise_amdappsdk_packages
255 sources: *precise_amdappsdk_sources
257 - OPENCL_LIB=amdappsdk
258 - OPENCL_VERSION="20"
259 - AMDAPPSDK_VERSION=300 # OpenCL 2.0
260 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
262 # Coveralls build (-DBOOST_COMPUTE_ENABLE_COVERAGE=ON)
263 # Trusty, AMD APP SDK v2.9.1, OpenCL 1.2
270 packages: &trusty_amdappsdk_packages
273 - libboost-chrono1.55-dev
274 - libboost-date-time1.55-dev
275 - libboost-test1.55-dev
276 - libboost-system1.55-dev
277 - libboost-filesystem1.55-dev
278 - libboost-timer1.55-dev
279 - libboost-program-options1.55-dev
280 - libboost-thread1.55-dev
285 sources: &trusty_amdappsdk_sources
286 - ubuntu-toolchain-r-test
289 - OPENCL_LIB=amdappsdk
290 - OPENCL_VERSION="12"
291 - AMDAPPSDK_VERSION=291 # OpenCL 1.2
292 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include -DBOOST_COMPUTE_ENABLE_COVERAGE=ON"
295 # Latest Boost library builds (currently 1.61)
296 # Precise, AMD APP SDK v2.9.1, Travis CI container-based infrastructure
306 packages: &precise_latest_boost_packages
312 sources: &precise_latest_boost_sources
313 - ubuntu-toolchain-r-test
315 - OPENCL_LIB=amdappsdk
316 - OPENCL_VERSION="12"
317 - AMDAPPSDK_VERSION=291 # OpenCL 1.2
318 - BOOST_VERSION="1_61_0" # Boost 1.61
319 - BOOST_URL="http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz"
320 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
330 packages: *precise_latest_boost_packages
331 sources: *precise_latest_boost_sources
333 - OPENCL_LIB=amdappsdk
334 - OPENCL_VERSION="12"
335 - AMDAPPSDK_VERSION=291 # OpenCL 1.2
336 - BOOST_VERSION="1_61_0" # Boost 1.61
337 - BOOST_URL="http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz"
338 - ENV_CMAKE_OPTIONS="-DOpenCL_INCLUDE_DIR=${OPENCL_ROOT}/include"
340 ############################################################################
342 ############################################################################
348 - ENV_CXX_FLAGS="-Wno-c99-extensions"
351 # Install dependencies
353 # POCL dependencies for Trusty
354 # llvm-toolchain-trusty-3.7 is not whitelisted yet https://github.com/travis-ci/apt-source-whitelist/issues/199
355 if [[ ${LINUX_DIST} == "trusty" && ${OPENCL_LIB} == "pocl" ]]; then
356 # see https://github.com/travis-ci/travis-ci/issues/6120
357 POCL_LLVM_URL=http://llvm.org/releases/${POCL_LLVM_VERSION}/clang+llvm-${POCL_LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz
358 mkdir -p ${DEPS_DIR}/llvm-${POCL_LLVM_VERSION}
359 travis_retry wget --no-check-certificate --quiet -O llvm-${POCL_LLVM_VERSION}.tar.xz ${POCL_LLVM_URL}
360 tar xf llvm-${POCL_LLVM_VERSION}.tar.xz -C ${DEPS_DIR}/llvm-${POCL_LLVM_VERSION} --strip-components 1
362 #sudo add-apt-repository -y "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main"
363 #travis_retry wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | travis_retry sudo apt-key add -
364 #sudo apt-get update -qq -
365 #sudo apt-get install -qq -y clang-3.7 libclang-common-3.7-dev libclang-3.7-dev libclang1-3.7 libllvm3.7 lldb-3.7 llvm-3.7 llvm-3.7-dev llvm-3.7-runtime clang-modernize-3.7 clang-format-3.7 lldb-3.7-dev
367 elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
369 brew outdated boost || brew upgrade boost
370 brew outdated cmake || brew upgrade cmake
371 brew install lcov homebrew/science/opencv
373 - gem install coveralls-lcov
374 - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
376 # Combine global build options with OS/compiler-dependent options
377 - export CMAKE_OPTIONS=${CMAKE_OPTIONS}" "${ENV_CMAKE_OPTIONS}
378 - export CXX_FLAGS=${CXX_FLAGS}" "${ENV_CXX_FLAGS}
381 # Download and install recent cmake
383 if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
384 CMAKE_URL="http://www.cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.tar.gz"
385 mkdir -p ${DEPS_DIR}/cmake
386 travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR}/cmake
387 export PATH=${DEPS_DIR}/cmake/bin:${PATH}
390 # Download and install Boost
392 if [[ ${TRAVIS_OS_NAME} == "linux" && ${BOOST_VERSION} != "default" ]]; then
393 if [ ! -f "${DEPS_DIR}/boost/${BOOST_VERSION}_cached" ]; then
394 # create dirs for source and install
395 mkdir -p ${DEPS_DIR}/boost${BOOST_VERSION}
396 mkdir -p ${DEPS_DIR}/boost
397 rm -rf ${DEPS_DIR}/boost/*
399 travis_retry wget --no-check-certificate --quiet -O - ${BOOST_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR}/boost${BOOST_VERSION}
400 pushd ${DEPS_DIR}/boost${BOOST_VERSION}
401 # configure and install
402 echo "using gcc : 4.8 : g++-4.8 ;" > $HOME/user-config.jam
403 ./bootstrap.sh --prefix=${DEPS_DIR}/boost/ --with-libraries=program_options,filesystem,system,thread,test,timer,chrono
406 touch ${DEPS_DIR}/boost/${BOOST_VERSION}_cached
408 echo 'Using cached Boost ${BOOST_VERSION} libraries.'
410 export CMAKE_OPTIONS=${CMAKE_OPTIONS}" -DBOOST_ROOT=${DEPS_DIR}/boost"
413 ############################################################################
414 # Download OpenCL headers (and cl.hpp)
415 ############################################################################
417 if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
418 mkdir -p ${OPENCL_ROOT}/include/CL
419 pushd ${OPENCL_ROOT}/include/CL
420 travis_retry git clone --depth 1 https://github.com/KhronosGroup/OpenCL-Headers.git -b opencl${OPENCL_VERSION}
421 mv ./OpenCL-Headers/* .
422 travis_retry wget -w 1 -np -nd -nv -A h,hpp --no-check-certificate ${OPENCL_REGISTRY}/api/2.1/cl.hpp;
426 ############################################################################
427 # Build and install POCL https://github.com/pocl/pocl
428 ############################################################################
430 if [[ ${TRAVIS_OS_NAME} == "linux" && ${OPENCL_LIB} == "pocl" ]]; then
431 travis_retry git clone --depth 1 https://github.com/pocl/pocl.git -b ${POCL_BRANCH}
433 if [[ -n "${POCL_COMMIT}" ]]; then
434 git checkout ${POCL_COMMIT}
438 cmake -DDIRECT_LINKAGE=ON -DENABLE_ICD=OFF -DCMAKE_C_COMPILER=${POCL_C_COMPILER} -DCMAKE_CXX_COMPILER=${POCL_CXX_COMPILER} -DWITH_LLVM_CONFIG=${POCL_LLVM_CONFIG} -DCMAKE_INSTALL_PREFIX=${OPENCL_ROOT}/pocl/ ..
443 ############################################################################
444 # fglrx does not work: https://github.com/travis-ci/travis-ci/issues/5221,
445 # so we build our own linkable .so file.
446 # Thanks to clSPARSE for providing opencl-icd build script.
447 ############################################################################
449 if [[ ${TRAVIS_OS_NAME} == "linux" && ${OPENCL_LIB} == "khronos-icd" ]]; then
450 mkdir -p ${OPENCL_ROOT}
452 travis_retry git clone --depth 1 https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
453 mv ./OpenCL-ICD-Loader/* .
456 travis_retry git clone --depth 1 https://github.com/KhronosGroup/OpenCL-Headers.git
457 mv ./OpenCL-Headers/* .
461 cmake -G "Unix Makefiles" ..
463 cp ./bin/libOpenCL.so .
468 ############################################################################
469 # Install AMD APP SDK
470 # Thanks to JuliaGPU https://github.com/JuliaGPU/OpenCL.jl
471 ############################################################################
473 if [[ ${TRAVIS_OS_NAME} == "linux" && ${OPENCL_LIB} == "amdappsdk" ]]; then
474 mkdir -p ${OPENCL_ROOT}
475 bash .travis/amd_sdk.sh ${AMDAPPSDK_VERSION}
476 tar -xjf AMD-SDK.tar.bz2
477 export OPENCL_VENDOR_PATH=${AMDAPPSDKROOT}/etc/OpenCL/vendors
478 mkdir -p ${OPENCL_VENDOR_PATH}
479 sh AMD-APP-SDK*.sh --tar -xf -C ${AMDAPPSDKROOT}
480 echo libamdocl64.so > ${OPENCL_VENDOR_PATH}/amdocl64.icd
481 if [[ ${AMDAPPSDK_VERSION} == "300" ]]; then
482 export LD_LIBRARY_PATH=${AMDAPPSDKROOT}/lib/x86_64/sdk:${LD_LIBRARY_PATH}
483 export CMAKE_LIBRARY_PATH=${AMDAPPSDKROOT}/lib/x86_64/sdk
484 cp ${AMDAPPSDKROOT}/lib/x86_64/libamdocl12cl64.so ${AMDAPPSDKROOT}/lib/x86_64/sdk/libamdocl12cl64.so
487 export LD_LIBRARY_PATH=${AMDAPPSDKROOT}/lib/x86_64:${LD_LIBRARY_PATH}
488 export CMAKE_LIBRARY_PATH=${AMDAPPSDKROOT}/lib/x86_64
490 chmod +x ${AMDAPPSDKROOT}/bin/x86_64/clinfo
491 ${AMDAPPSDKROOT}/bin/x86_64/clinfo
495 ############################################################################
496 # Build Boost.Compute tests, benchmarks and examples
497 ############################################################################
500 - echo ${CMAKE_OPTIONS}
502 - cmake ${CMAKE_OPTIONS} -DCMAKE_CXX_FLAGS=${CXX_FLAGS} ..
505 if [[ ${RUN_TESTS} == "true" ]]; then
506 # print OpenCL devices
507 ./example/list_devices
508 # run tests and examples
509 ctest --output-on-failure
510 ctest --output-on-failure
515 if [[ ${COVERAGE} == "true" ]]; then
516 lcov --directory test --base-directory ../include/boost/compute/ --capture --output-file coverage.info
517 lcov --remove coverage.info '/usr*' '*/test/*' -o coverage.info
518 cd .. && coveralls-lcov build/coverage.info