Skip to content

Commit

Permalink
add CMake option TESTS (#30)
Browse files Browse the repository at this point in the history
* add CMake option TESTS

* Added option for release build with corresponding flags and fixed CMAKE_CONFIGURATION_TYPES to release.

* try fixing build on Appveyor

* disable temperature logging on Appveyor/Linux
  • Loading branch information
ranocha authored and philipheinisch committed Mar 14, 2019
1 parent 1d4fef3 commit 80c1c1d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 26 deletions.
37 changes: 31 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Select compiler, supports gcc, clang

cmake_minimum_required (VERSION 3.5)

PROJECT(toolkitICL)

option(BUILDREL "Official release build" OFF)

if(DEFINED ENV{AMDPROFILERPATH})
message(STATUS "Found AMD profiling driver")
option(USEAMDP "Use AMD Profiling" ON)
Expand Down Expand Up @@ -30,7 +32,7 @@ if(DEFINED ENV{IPG_Dir})
option(USEIPG "Use Intel Power Gadget" ON)
option(USEIRAPL "Use RAPL" OFF)
ELSE()
option(USEIPG "Use Intel Power Gadget" OF)
option(USEIPG "Use Intel Power Gadget" OFF)
endif()

IF(USEIPG)
Expand All @@ -49,29 +51,51 @@ IF(USENVML)
add_definitions(-DUSENVML)
ENDIF()

# Because Makefiles are shit to read
set(CMAKE_CONFIGURATION_TYPES "Release" CACHE STRING "" FORCE)

SET(CMAKE_VERBOSE_MAKEFILE "false")
# Includes modules to find OCL
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/")

# compiler flags
IF(BUILDREL)
MESSAGE(STATUS "Building release version")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
MESSAGE(STATUS "Microsoft Visual Studio detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " /std=c++11 /O2 /DH5_BUILT_AS_DYNAMIC_LIB")
SET(CMAKE_C_FLAGS " /std=c++11 /O2 /DH5_BUILT_AS_DYNAMIC_LIB")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
MESSAGE(STATUS "GNU Compiler Collection detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -fPIC -Wall -mfpmath=sse -Wcast-align -Wl,-E")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -msse2 -fPIC -Wall -mfpmath=sse -Wcast-align -Wl,-E")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
MESSAGE(STATUS "LLVM Clang detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -fPIC -Wall")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -msse2 -fPIC -Wall")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
MESSAGE(STATUS "Apple Clang detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -march=native -fPIC -Wall")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -msse2 -fPIC -Wall")
ELSE()
MESSAGE(STATUS "Compiler ${CMAKE_CXX_COMPILER_ID} unknown. Simple compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -fstrict-aliasing -fPIC -Wall")
ENDIF()
ELSE(BUILDREL)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
MESSAGE(STATUS "Microsoft Visual Studio detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " /std=c++11 /O2 /DH5_BUILT_AS_DYNAMIC_LIB")
SET(CMAKE_C_FLAGS " /std=c++11 /O2 /DH5_BUILT_AS_DYNAMIC_LIB")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
MESSAGE(STATUS "GNU Compiler Collection detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -march=native -fPIC -Wall -mfpmath=sse -Wcast-align -Wl,-E")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
MESSAGE(STATUS "LLVM Clang detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -march=native -fPIC -Wall")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
MESSAGE(STATUS "Apple Clang detected. Corresponding compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -funroll-loops -fstrict-aliasing -march=native -fPIC -Wall")
ELSE()
MESSAGE(STATUS "Compiler ${CMAKE_CXX_COMPILER_ID} unknown. Simple compiler flags have been set.")
SET(CMAKE_CXX_FLAGS " -std=c++11 -O2 -fstrict-aliasing -march=native -fPIC -Wall")
ENDIF()
ENDIF(BUILDREL)

# Get cl2.hpp header file
OPTION(GET_CL2HPP "Download cl2.hpp from Khronos" OFF)
Expand Down Expand Up @@ -116,6 +140,7 @@ ENDIF(OpenCL_FOUND)
ADD_SUBDIRECTORY(src)

# tests
OPTION(TESTS "Build unit tests" OFF)
IF(TESTS)
enable_testing()
ADD_SUBDIRECTORY(test)
Expand Down
40 changes: 20 additions & 20 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ build_script:
# Windows only
- cmd: set VCPKG_DEFAULT_TRIPLET=x64-windows
- cmd: cmake .. -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DHDF5_ROOT="C:/Tools/vcpkg/installed/x64-windows" -DHDF5_INCLUDE_DIRS="C:/Tools/vcpkg/installed/x64-windows/include" -DHDF5_LIBRARIES="hdf5::hdf5-shared" -DHDF5_HL_LIBRARIES="hdf5::hdf5_hl-shared"
- cmd: cmake --build . --target ALL_BUILD
- cmd: cmake --build . --target ALL_BUILD --config Release
- cmd: set PATH=%PATH%;%cd%\bin;%cd%\bin\Release;%cd%\bin\Debug
- cmd: echo %PATH%
# - cmd: cd ..
Expand All @@ -83,8 +83,8 @@ build_script:
- cmd: mkdir build
- cmd: cd build
- cmd: cmake -DTESTS=ON .. -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DHDF5_ROOT="C:/Tools/vcpkg/installed/x64-windows" -DHDF5_INCLUDE_DIRS="C:/Tools/vcpkg/installed/x64-windows/include" -DHDF5_LIBRARIES="hdf5::hdf5-shared" -DHDF5_HL_LIBRARIES="hdf5::hdf5_hl-shared"
- cmd: cmake --build . --target ALL_BUILD
- cmd: cmake --build . --target RUN_TESTS
- cmd: cmake --build . --target ALL_BUILD --config Release
- cmd: cmake --build . --target RUN_TESTS --config Release
# Linux only
# build without tests
- sh: cmake ..
Expand All @@ -107,22 +107,22 @@ build_script:
- sh: cmake --build . --target test
# test power logging
# instead of `sudo toolkitICL ...`, `sudo chmod o+rw /dev/cpu/0/msr` could be run once
- sh: sudo modprobe msr
- sh: cd test
- sh: sudo ../bin/toolkitICL -b -intel_power 1000 -c repetition_test.h5
- sh: h5ls out_repetition_test.h5/housekeeping
- sh: h5ls out_repetition_test.h5/housekeeping/intel
- sh: h5dump -d housekeeping/intel/cores0 out_repetition_test.h5
- sh: h5dump -d housekeeping/intel/DRAM0 out_repetition_test.h5
# - sh: h5dump -d housekeeping/intel/GT0 out_repetition_test.h5 # not required on all machines
- sh: h5dump -d housekeeping/intel/package0 out_repetition_test.h5
- sh: h5dump -d housekeeping/intel/power_time out_repetition_test.h5
- sh: h5dump -d housekeeping/intel/TDP out_repetition_test.h5
- sh: sudo ../bin/toolkitICL -b -intel_temp 1000 -c repetition_test.h5
- sh: h5ls out_repetition_test.h5/housekeeping
- sh: h5ls out_repetition_test.h5/housekeeping/intel
- sh: h5dump -d housekeeping/intel/package0_temperature out_repetition_test.h5
- sh: h5dump -d housekeeping/intel/temperature_time out_repetition_test.h5
- sh: cd ..
# - sh: sudo modprobe msr
# - sh: cd test
# - sh: sudo ../bin/toolkitICL -b -intel_power 1000 -c repetition_test.h5
# - sh: h5ls out_repetition_test.h5/housekeeping
# - sh: h5ls out_repetition_test.h5/housekeeping/intel
# - sh: h5dump -d housekeeping/intel/cores0 out_repetition_test.h5
# - sh: h5dump -d housekeeping/intel/DRAM0 out_repetition_test.h5
# # - sh: h5dump -d housekeeping/intel/GT0 out_repetition_test.h5 # not required on all machines
# - sh: h5dump -d housekeeping/intel/package0 out_repetition_test.h5
# - sh: h5dump -d housekeeping/intel/power_time out_repetition_test.h5
# - sh: h5dump -d housekeeping/intel/TDP out_repetition_test.h5
# - sh: sudo ../bin/toolkitICL -b -intel_temp 1000 -c repetition_test.h5
# - sh: h5ls out_repetition_test.h5/housekeeping
# - sh: h5ls out_repetition_test.h5/housekeeping/intel
# - sh: h5dump -d housekeeping/intel/package0_temperature out_repetition_test.h5
# - sh: h5dump -d housekeeping/intel/temperature_time out_repetition_test.h5
# - sh: cd ..
# display test log
- sh: cat Testing/Temporary/LastTest.log

0 comments on commit 80c1c1d

Please sign in to comment.