-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
219 lines (171 loc) · 8.04 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
cmake_minimum_required(VERSION 2.8.12)
project(parallel_project)
set(CMAKE_CXX_STANDARD 11)
# This file is used obtained from http://gitorious.org/findopencl
# - Try to find OpenCL
# This module tries to find an OpenCL implementation on your system. It supports
# AMD, Intel and NVIDIA implementations, but should work, too.
# Prerequisites
# Atleast one of the OpenCL SDKs should be installed.
# --If AMD APPSDK is installed then make sure the environment AMDAPPSDKROOT variable is set
# --If NVDIA GPU Compute SDK is installed then make sure the environment NVSDKCOMPUTE_ROOT variable is set
# --If Intel OpenCL Application SDK is installed then make sure the environment INTELOCLSDKROOT variable is set
#
# Once done this will define
# OPENCL_FOUND - system has OpenCL
# OPENCL_INCLUDE_DIRS - the OpenCL include directory
# OPENCL_LIBRARIES - link these to use OpenCL
#
#
FIND_PACKAGE(PackageHandleStandardArgs)
SET (OPENCL_VERSION_STRING "1.2.0")
SET (OPENCL_VERSION_MAJOR 1)
SET (OPENCL_VERSION_MINOR 2)
SET (OPENCL_VERSION_PATCH 0)
option( BUILD_64 "Linux only 64 bit build" ON)
option( BUILD_AMD_OPENCL "Create Build for AMD OpenCL implementation" ON )
option( BUILD_NV_OPENCL "Create Build for NV OpenCL implementation" OFF )
option( BUILD_INTEL_OPENCL "Create Build for INTEL OpenCL implementation" OFF )
option( BUILD_APPLE_OPENCL "Create Build for APPLE OpenCL implementation" OFF )
if( BUILD_64 )
set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE )
message( STATUS "64bit build - FIND_LIBRARY_USE_LIB64_PATHS TRUE" )
else()
set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE )
message( STATUS "32bit build - FIND_LIBRARY_USE_LIB64_PATHS FALSE" )
endif()
IF(${BUILD_AMD_OPENCL} STREQUAL ON)
IF ( DEFINED ENV{AMDAPPSDKROOT} )
message (STATUS "AMDAPPSDKROOT environment variable is set")
ELSE ( )
message ("AMDAPPSDKROOT is not set or APP SDK is not installed")
ENDIF( )
ENDIF (${BUILD_AMD_OPENCL} STREQUAL ON)
IF(${BUILD_NV_OPENCL} STREQUAL ON)
IF ( DEFINED ENV{NVSDKCOMPUTE_ROOT} )
message (STATUS "NVSDKCOMPUTE_ROOT is set")
ELSE ( )
message ("NVSDKCOMPUTE_ROOT is not set or NVIDIA GPU compute SDK is not installed")
ENDIF( )
ENDIF ( )
IF(${BUILD_INTEL_OPENCL} STREQUAL ON)
IF (DEFINED ENV{INTELOCLSDKROOT})
message (STATUS "INTELOCLSDKROOT is set")
ELSE ( )
message ("INTELOCLSDKROOT is not set. Install INTEL OpenCL Application or set the path manually")
ENDIF( )
ENDIF ( )
IF (APPLE)
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX")
FIND_PATH(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX")
FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX")
ELSEIF (WIN32)
# The AMD SDK currently installs both x86 and x86_64 libraries
IF(${BUILD_AMD_OPENCL} STREQUAL ON)
#http://developer.amd.com/download/AMD_APP_SDK_Installation_Notes.pdf
IF( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Win64 Generator
SET(OPENCL_LIB_DIR "$ENV{AMDAPPSDKROOT}/lib/x86_64")
ELSE ( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Generator - non Win64
SET(OPENCL_LIB_DIR "$ENV{AMDAPPSDKROOT}/lib/x86")
ENDIF( ${CMAKE_CL_64} EQUAL 1 )
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib PATHS ${OPENCL_LIB_DIR} )
GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
# On Win32 search relative to the library
FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" )
FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" ENV OpenCL_INCPATH)
ELSEIF ( ${BUILD_NV_OPENCL} STREQUAL ON )
#http://developer.download.nvidia.com/compute/cuda/3_1/sdk/docs/OpenCL_release_notes.txt
IF( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Win64 Generator
SET(OPENCL_LIB_DIR "$ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64")
ELSE ( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Generator - non Win64
SET(OPENCL_LIB_DIR "$ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/win32")
ENDIF( ${CMAKE_CL_64} EQUAL 1 )
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib PATHS ${OPENCL_LIB_DIR} )
GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
# On Win32 search relative to the library
FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" )
FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" ENV OpenCL_INCPATH)
ELSE ( ${BUILD_AMD_OPENCL} STREQUAL ON )
#http://software.intel.com/en-us/articles/intel-sdk-for-opencl-applications-2013-release-notes
IF( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Win64 Generator
SET(OPENCL_LIB_DIR "$ENV{INTELOCLSDKROOT}/lib/x64")
ELSE ( ${CMAKE_CL_64} EQUAL 1 ) # using Visual Studio Generator - non Win64
SET(OPENCL_LIB_DIR "$ENV{INTELOCLSDKROOT}/lib/x86")
ENDIF( ${CMAKE_CL_64} EQUAL 1 )
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib PATHS ${OPENCL_LIB_DIR} )
GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
# On Win32 search relative to the library
FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" )
FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" ENV OpenCL_INCPATH)
ELSE ( ${BUILD_AMD_OPENCL} STREQUAL ON )
message("NO OpenCL Build system is selected.")
ENDIF( ${BUILD_AMD_OPENCL} STREQUAL ON)
ELSE (APPLE)
# Unix style platforms
get_property( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
IF(${BUILD_AMD_OPENCL} STREQUAL ON)
SET(OPENCL_ROOT "$ENV{AMDAPPSDKROOT}/")
ELSEIF ( ${BUILD_NV_OPENCL} STREQUAL ON )
SET(OPENCL_ROOT "$ENV{NVSDKCOMPUTE_ROOT}/")
ELSE ( ${BUILD_AMD_OPENCL} STREQUAL ON )
SET(OPENCL_ROOT "$ENV{INTELOCLSDKROOT}/")
ENDIF( ${BUILD_AMD_OPENCL} STREQUAL ON)
IF( LIB64 )
message("building 64-bit lib")
FIND_LIBRARY( OPENCL_LIBRARIES
OpenCL
HINTS
${OPENCL_ROOT}/lib
$ENV{OPENCL_ROOT}/lib
DOC "OpenCL dynamic library path"
PATH_SUFFIXES x86_64 x64
)
ELSE( )
message("building 32-bit lib")
FIND_LIBRARY( OPENCL_LIBRARIES
OpenCL
HINTS
${OPENCL_ROOT}/lib
$ENV{OPENCL_ROOT}/lib
DOC "OpenCL dynamic library path"
PATH_SUFFIXES x86
)
ENDIF( )
#FIND_LIBRARY(OPENCL_LIBRARIES OpenCL
# PATHS ENV LD_LIBRARY_PATH ENV OpenCL_LIBPATH
#)
GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH)
GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
# The AMD SDK currently does not place its headers
# in /usr/include, therefore also search relative
# to the library
IF (${BUILD_AMD_OPENCL} STREQUAL ON)
SET(OCL_INSTALL_PATH "/opt/AMDAPP/include")
ELSEIF (${BUILD_AMD_OPENCL} STREQUAL ON)
SET(OCL_INSTALL_PATH "/usr/local/cuda/include")
ENDIF ()
FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} ${OCL_INSTALL_PATH} ENV OpenCL_INCPATH)
FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} ${OCL_INSTALL_PATH} ENV OpenCL_INCPATH)
ENDIF (APPLE)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS)
IF(_OPENCL_CPP_INCLUDE_DIRS)
SET( OPENCL_HAS_CPP_BINDINGS TRUE )
LIST( APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS} )
# This is often the same, so clean up
LIST( REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS )
ENDIF(_OPENCL_CPP_INCLUDE_DIRS)
MARK_AS_ADVANCED(
OPENCL_INCLUDE_DIRS
)
message (STATUS "OPENCL_FOUND :" ${OPENCL_FOUND} )
message (STATUS "OPENCL_INCLUDE_DIRS :" ${OPENCL_INCLUDE_DIRS} )
message (STATUS "OPENCL_LIBRARIES :" ${OPENCL_LIBRARIES} )
include_directories(.)
find_package( OpenCV REQUIRED )
find_package(OpenCL REQUIRED)
INCLUDE_DIRECTORIES(${OpenCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${OpenCL_LIBRARY})
add_executable(${PROJECT_NAME} main.cpp utils.cpp interpolation_cpu.cpp interpolation_gpu.cpp)
target_link_libraries(${PROJECT_NAME} ${OPENCL_LIBRARIES} ${OpenCV_LIBS} )
configure_file(image.dat ${CMAKE_CURRENT_BINARY_DIR}/image.dat COPYONLY)
configure_file(kernel.cl ${CMAKE_CURRENT_BINARY_DIR}/kernel.cl COPYONLY)