.travis.yml: try to run tests in -mavx2 mode if the CPU supports it
authorEven Rouault <even.rouault@spatialys.com>
Fri, 30 Jun 2017 23:46:55 +0000 (01:46 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Sat, 1 Jul 2017 00:14:27 +0000 (02:14 +0200)
And modify settings so as to hae a AVX2 compatible CPU

.travis.yml
tools/travis-ci/run.sh

index 6747fe30b969201f0fef981b656f99e4a95863bd..282d0145285d4819faab5f8f9a99100a20b84866 100644 (file)
@@ -27,9 +27,11 @@ matrix:
 
 # Test compilation with AVX2
     - os: linux
+      # "sudo: yes" and "dist: trusty" give us a worker with the AVX2 instruction set
+      sudo: yes
+      dist: trusty
       compiler: clang-3.8
-      # skip tests since Travis doesn't have AVX2 compatible machines
-      env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_INSTRUCTION_SETS="-mavx2" OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_SKIP_TESTS=1
+      env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_INSTRUCTION_SETS="-mavx2" OPJ_CI_BUILD_CONFIGURATION=Release
       addons:
         apt:
           sources:
index 950a0ee9146876d1a812618dcf30ef3f0cab00bb..ac21dfe74e215485dd8cbd7ad11970901fdf47a6 100755 (executable)
@@ -111,6 +111,17 @@ elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
        else
                echo "Compiler not supported: ${CC}"; exit 1
        fi
+       if [ "${OPJ_CI_INSTRUCTION_SETS-:}" == "-mavx2" ]; then
+               AVX2_AVAIL=1
+               cat /proc/cpuinfo | grep avx2 >/dev/null || AVX2_AVAIL=0
+               if [[ "${AVX2_AVAIL}" == "1" ]]; then
+                       echo "AVX2 available on CPU"
+               else
+                       echo "AVX2 not available on CPU. Disabling tests"
+                       cat /proc/cpuinfo  | grep flags | head -n 1
+                       export OPJ_CI_SKIP_TESTS=1
+               fi
+        fi
 elif [ "${TRAVIS_OS_NAME}" == "windows" ]; then
        OPJ_OS_NAME=windows
        if which cl > /dev/null; then