Skip to content

Commit

Permalink
Merge pull request #23 from CNugteren/cmake_update
Browse files Browse the repository at this point in the history
Reduced compiler requirements
  • Loading branch information
CNugteren committed May 26, 2015
2 parents f5afa53 + 5fecbf5 commit 9edbebc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 49 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

Version 1.6.3
- Reduced the requirements from GCC 4.9.0 to 4.8.0
- Minor updates to the CMake file

Version 1.6.2
- Fixed another exception-related bug
- Further improved reporting of failed runs
Expand Down
82 changes: 40 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
# ==================================================================================================

# CMake project
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.10)
project("cltune" CXX)
set(cltune_VERSION_MAJOR 1)
set(cltune_VERSION_MINOR 6)
set(cltune_VERSION_PATCH 2)
set(cltune_VERSION_PATCH 3)

# Options
option(SAMPLES "Enable compilation of sample programs" ON)
Expand All @@ -43,35 +43,38 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH false) # Don't add the automatically deter

# ==================================================================================================

# Compiler-version check
# Compiler-version check (requires at least CMake 2.8.10)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "GCC version must be at least 4.9")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "GCC version must be at least 4.8")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "Clang version must be at least 3.3")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "Clang version must be at least 3.3")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "Clang version must be at least 5.0")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "Clang version must be at least 5.0")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
message(FATAL_ERROR "ICC version must be at least 14.0")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
message(FATAL_ERROR "ICC version must be at least 14.0")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Visual Studio version must be at least 18.0")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "MS Visual Studio version must be at least 18.0")
endif()
endif()

# C++ compiler settings
set(FLAGS "-O3 -std=c++11")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(FLAGS "${FLAGS} -Wall -Wno-comment")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.4)
set(FLAGS "${FLAGS} -Wno-attributes")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
#set(FLAGS "${FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded")
set(FLAGS "${FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")

Expand All @@ -86,9 +89,7 @@ find_package(OpenCL REQUIRED)
# ==================================================================================================

# The includes
include_directories(
${cltune_SOURCE_DIR}/include
${OPENCL_INCLUDE_DIRS})
include_directories(${cltune_SOURCE_DIR}/include ${OPENCL_INCLUDE_DIRS})

# Gathers all source-files
set(TUNER
Expand All @@ -113,35 +114,32 @@ install(FILES include/cltune.h DESTINATION include)
# Optional: Enables compilation of sample programs
if (SAMPLES)

# Adds sample programs
add_executable(sample_simple samples/simple/simple.cc)
add_executable(sample_gemm samples/gemm/gemm.cc)
add_executable(sample_conv samples/conv/conv.cc)
target_link_libraries(sample_simple cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})
target_link_libraries(sample_gemm cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})
target_link_libraries(sample_conv cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})
# Adds sample programs
add_executable(sample_simple samples/simple/simple.cc)
add_executable(sample_gemm samples/gemm/gemm.cc)
add_executable(sample_conv samples/conv/conv.cc)
target_link_libraries(sample_simple cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})
target_link_libraries(sample_gemm cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})
target_link_libraries(sample_conv cltune ${OPENCL_LIBRARIES} ${OpenMP_LIBRARY})

# Note: these are not installed because they depend on their separate OpenCL kernel files
# Note: these are not installed because they depend on their separate OpenCL kernel files

endif()
# ==================================================================================================
# Optional: Enables compilation of the Google tests
if (TESTS)

# Enables Google Test tests (source-code is shipped with the project)
add_subdirectory(external/gtest-1.7.0)
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
# Enables Google Test tests (source-code is shipped with the project)
add_subdirectory(external/gtest-1.7.0)
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

# Compiles the tests
add_executable(unit_tests test/tuner.cc test/kernel_info.cc)
target_link_libraries(unit_tests gtest gtest_main cltune ${OPENCL_LIBRARIES})
# Compiles the tests
add_executable(unit_tests test/tuner.cc test/kernel_info.cc)
target_link_libraries(unit_tests gtest gtest_main cltune ${OPENCL_LIBRARIES})

# Adds the tests
add_test(
name unit_tests
command unit_tests
)
# Adds the tests
add_test(name unit_tests command unit_tests)

endif()
# ==================================================================================================
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Compilation

CLTune can be compiled as a shared library using CMake. The pre-requisites are:

* CMake version 2.8 or higher
* CMake version 2.8.10 or higher
* A C++11 compiler, for example:
- GCC 4.9.0 or newer
- GCC 4.8.0 or newer
- Clang 3.3 or newer
- AppleClang 5.0 or newer
- ICC 14.0 or newer
* An OpenCL library. CLTune has been tested with:
- Apple OpenCL
Expand Down Expand Up @@ -88,13 +89,14 @@ Examples are included as part of the CLTune distribution. They illustrate some m

The latter two take optionally command-line arguments. The first argument is an integer for the device to run on, the second argument is an integer to select a search strategy (0=random, 1=annealing, 2=PSO, 3=fullsearch), and the third an optional search-strategy parameter.


Development and tests
-------------

The CLTune project follows the Google C++ styleguide (with some exceptions) and uses a tab-size of
two spaces and a max-width of 100 characters per line. It is furthermore based on practises from the
third edition of Effective C++ and the first edition of Effective Modern C++. The project is
licensed under the MIT license by SURFsara, (c) 2014. The contributing authors so far are:
licensed under the APACHE 2.0 license by SURFsara, (c) 2014. The contributing authors so far are:

* Cedric Nugteren

Expand All @@ -103,7 +105,7 @@ providing the `-TESTS=ON` option to CMake. Running the tests goes as follows:

./unit_tests

Other useful tests are the provided examples, since they include a verification kernel:
However, the more useful tests are the provided examples, since they include a verification kernel. Running the examples on device Y on platform X goes as follows:

./sample_conv 0 0
./sample_gemm 0 0
./sample_conv X Y
./sample_gemm X Y
5 changes: 4 additions & 1 deletion src/tuner_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <fstream> // std::ifstream, std::stringstream
#include <iostream> // FILE
#include <limits> // std::numeric_limits
#include <regex> // std::regex, std::regex_replace
#include <algorithm> // std::min

namespace cltune {
Expand Down Expand Up @@ -219,11 +218,15 @@ TunerImpl::TunerResult TunerImpl::RunKernel(const std::string &source, const Ker
const size_t configuration_id,
const size_t num_configurations) {

// Note: the following code is disabled because of GCC 4.8.0 compatibility
auto processed_source = source;
/*
// Removes the use of C++11 string literals (if any) from the kernel source code
auto string_literal_start = std::regex{"R\"\\("};
auto string_literal_end = std::regex{"\\)\";"};
auto processed_source = std::regex_replace(source, string_literal_start, "");
processed_source = std::regex_replace(processed_source, string_literal_end, "");
*/

// In case of an exception, skip this run
try {
Expand Down

0 comments on commit 9edbebc

Please sign in to comment.