Newer
Older
# ==================================================================================================
# This file is part of the CodeVault project. The project is licensed under Apache Version 2.0.
# CodeVault is part of the EU-project PRACE-4IP (WP7.3.C).
#
# Author(s):
# Valeriu Codreanu <valeriu.codreanu@surfsara.nl>
#
# ==================================================================================================
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
# Packages are optional: if they are not present, certain code samples are not compiled
find_package(OpenMP) # Built-in in CMake
find_package(MPI) # Built-in in CMake
find_package(CUDA) # Built-in in CMake
find_package(OpenCL )
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/common.cmake)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# ==================================================================================================
if ("${DWARF_PREFIX}" STREQUAL "")
set(DWARF_PREFIX 1_dense)
endif()
set(NAME ${DWARF_PREFIX}_kmeans_rodinia_opencl)
# ==================================================================================================
# C++ compiler settings
find_package(Common)
select_compiler_flags(cxx_flags
GNU "-march=native" # I suggest remove "-O3" as this is controlled by the CMAKE_BUILD_TYPE
CLANG "-march=native" # same here
Intel "-axavx2,avx")
set(CXX_FLAGS ${cxx_flags})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CXX_FLAGS "${CXX_FLAGS} -Wall -Wno-comment")
if(APPLE)
set(CXX_FLAGS "${CXX_FLAGS} -Wa,-q")
endif()
endif()
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS}")
# C compiler settings
select_compiler_flags(c_flags
GNU "-march=native" # I suggest remove "-O3" as this is controlled by the CMAKE_BUILD_TYPE
CLANG "-march=native" # same here
Intel "-axavx2,avx")
set(C_FLAGS ${c_flags})
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(C_FLAGS "${C_FLAGS} -Wall -Wno-comment -DOPENCL_HEADER_CL_CL")
if(APPLE)
set(C_FLAGS "${C_FLAGS} -Wa,-q -DOPENCL_HEADER_LONG")
endif()
endif()
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
# NVCC compiler settings
if (CUDA_FOUND)
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O3")
set(CUDA_HOST_COMPILER "g++")
endif()
# ==================================================================================================
# GEMM with the CUDA cuBLAS library
find_package(Common)
if (CUDA_FOUND)
include_directories(${OPENCL_INCLUDE_DIRS})
add_executable(${NAME} src/cluster.c src/getopt.c src/kmeans_clustering.c src/kmeans.cpp src/read_input.c src/rmse.c)
target_link_libraries(${NAME} ${OPENCL_LIBRARIES})
configure_file(src/kmeans.cl kmeans.cl COPYONLY)
# target_link_libraries(${NAME} ${CUDA_curand_LIBRARY})
install(TARGETS ${NAME} DESTINATION bin)
if (OPENMP_FOUND)
message("** Enabling '${NAME}': with OpenMP and OpenMP")
message("** Enabling '${CMAKE_MODULE_PATH}': with OpenMP and OpenMP")
else()
message("** Enabling '${NAME}': with OpenCL and without OpenMP")
endif()
else()
message("** Skipping '${NAME}': no OpenCL")
dummy_install(${NAME} "OpenCL")
endif()
unset(NAME)
# ==================================================================================================