source: icGREP/icgrep-devel/icgrep/CMakeLists.txt @ 5486

Last change on this file since 5486 was 5486, checked in by nmedfort, 22 months ago

Initial attempt to improve debugging capabilities with compilation stack traces on error.

File size: 11.6 KB
Line 
1cmake_minimum_required (VERSION 2.8)
2
3project (icgrep)
4
5enable_testing()
6# The version number.
7set (icgrep_VERSION_MAJOR 1)
8set (icgrep_VERSION_MINOR 6)
9
10option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
11option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
12find_package(LLVM REQUIRED CONFIG)
13
14message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
15
16set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
17
18set (Parabix_REVISION "svn")
19include(VersionFromVCS)
20add_version_info_from_vcs(Parabix_REVISION)
21message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
22
23
24# Now set the header and library paths:
25include_directories( ${LLVM_INCLUDE_DIRS} )
26link_directories( ${LLVM_LIBRARY_DIRS} )
27add_definitions( ${LLVM_DEFINITIONS} )
28
29# include(FindCUDA) # https://cmake.org/cmake/help/v3.0/module/FindCUDA.html
30
31option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
32set(CUDA_LIB "")
33if(ENABLE_CUDA_COMPILE)
34  find_package(CUDA)
35  if(CUDA_FOUND)
36    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
37    include_directories(${CUDA_INCLUDE})
38    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
39    SET(CUDA_LIB "cuda")
40  endif(CUDA_FOUND)
41endif()
42
43# Let's suppose we want to build a JIT compiler with support for
44# binary code (no interpreter):
45set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
46llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
47
48# Check if boost has been installed on this system.
49set(Boost_USE_STATIC_LIBS ON)
50set(Boost_USE_MULTITHREADED OFF)
51set(Boost_USE_STATIC_RUNTIME OFF)
52find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
53message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
54
55include_directories("${Boost_INCLUDE_DIRS}")
56link_directories(${Boost_LIBRARY_DIR})
57
58SET(OBJECT_CACHE_SRC toolchain/object_cache.cpp)
59
60SET(TOOLCHAIN_SRC toolchain/toolchain.cpp toolchain/pipeline.cpp toolchain/driver.cpp)
61
62SET(DRIVER_SRC toolchain/cpudriver.cpp toolchain/NVPTXDriver.cpp)
63
64SET(KERNEL_SRC kernels/kernel.cpp kernels/streamset.cpp kernels/interface.cpp kernels/kernel_builder.cpp)
65SET(KERNEL_SRC ${KERNEL_SRC} kernels/source_kernel.cpp kernels/s2p_kernel.cpp kernels/deletion.cpp kernels/swizzle.cpp kernels/p2s_kernel.cpp kernels/stdout_kernel.cpp)
66
67SET(IDISA_SRC IR_Gen/CBuilder.cpp IR_Gen/idisa_builder.cpp IR_Gen/idisa_avx_builder.cpp IR_Gen/idisa_i64_builder.cpp IR_Gen/idisa_sse_builder.cpp IR_Gen/idisa_nvptx_builder.cpp IR_Gen/idisa_target.cpp)
68
69SET(PABLO_SRC pablo/pabloAST.cpp pablo/branch.cpp pablo/codegenstate.cpp pablo/builder.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_toolchain.cpp)
70SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
71SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
72SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
73SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/passes/flattenif.cpp)
74IF(ENABLE_MULTIPLEXING)
75SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
76SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
77ENDIF()
78
79add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
80add_library(PabloADT ${PABLO_SRC})
81add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_rep.cpp re/re_diff.cpp re/re_intersect.cpp re/printer_re.cpp)
82add_library(RegExpCompiler re/re_parser.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp re/re_name_resolve.cpp re/re_parser_pcre.cpp re/re_parser_ere.cpp re/re_parser_bre.cpp re/re_parser_prosite.cpp re/re_utility.cpp)
83add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
84add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
85
86# force the compiler to compile the object cache to ensure that the versioning information is up to date
87add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
88add_dependencies(CodeGen RecompileObjectCache)
89
90# add the executable
91target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
92target_link_libraries (PabloADT CodeGen)
93target_link_libraries (CCADT PabloADT)
94target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
95target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
96target_link_libraries (RegExpCompiler RegExpADT)
97
98add_executable(icgrep icgrep.cpp grep_interface.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/match_count.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
99add_executable(u8u16 u8u16.cpp)
100add_executable(base64 base64.cpp kernels/radix64.cpp)
101add_executable(wc wc.cpp)
102add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
103add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
104add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
105
106target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
107target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
108target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
109target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
110target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
111target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
112target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
113
114IF(ENABLE_MULTIPLEXING)
115    message(STATUS "Enabling Multiplexing")
116    find_package(Z3 REQUIRED)
117    include_directories(${Z3_INCLUDE_DIRS})
118    target_link_libraries(PabloADT ${Z3_LIBRARIES})
119    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
120ENDIF()
121
122include_directories("${PROJECT_SOURCE_DIR}")
123
124#Check compiler support for 0x / 11
125include(CheckCXXCompilerFlag)
126CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
127if(COMPILER_SUPPORTS_CXX11)
128  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
129else()
130  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
131  if(COMPILER_SUPPORTS_CXX0X)
132    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
133  else()
134    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
135    if(COMPILER_SUPPORTS_GNU11)
136      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
137    else()
138      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
139      if(COMPILER_SUPPORTS_GNU0X)
140        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
141      endif()
142    endif()
143  endif()
144endif()
145
146#Disable RunTime Type Information
147IF (MSVC) # using Visual Studio C++
148  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
149ELSE() # using Clang, GCC, Intel C++, etc
150  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
151ENDIF()
152
153#Disable Dual ABI support
154IF(DISABLE_DUAL_ABI)
155SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
156ENDIF()
157
158#Enable all warnings
159SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
160
161include(CheckFunctionExists)
162CHECK_FUNCTION_EXISTS(aligned_alloc STDLIB_HAS_ALIGNED_ALLOC)
163IF (STDLIB_HAS_ALIGNED_ALLOC)
164SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTDLIB_HAS_ALIGNED_ALLOC")
165ELSE()
166CHECK_FUNCTION_EXISTS(posix_memalign STDLIB_HAS_POSIX_MEMALIGN)
167IF (!STDLIB_HAS_POSIX_MEMALIGN)
168MESSAGE(FATAL_ERROR "stdlib.h does not contain either aligned_alloc or posix_memalign" )
169ENDIF()
170ENDIF()
171
172include(CheckIncludeFileCXX)
173CHECK_INCLUDE_FILE_CXX(sanitizer/asan_interface.h HAS_ADDRESS_SANITIZER)
174
175find_package(Libunwind)
176IF (LIBUNWIND_FOUND)
177SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_LIBUNWIND")
178include_directories(${LIBUNWIND_INCLUDE_DIR})
179target_link_libraries(CodeGen ${LIBUNWIND_LIBRARIES})
180ENDIF()
181
182SET(CMAKE_REQUIRED_FLAGS)
183
184# detect LLVM version and add compiler flags.
185SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
186IF (${LLVM_VERSION_MAJOR} EQUAL 3)
187  IF (${LLVM_VERSION_MINOR} EQUAL 6)
188    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
189    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
190  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
191    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
192  ENDIF()
193ENDIF()
194
195SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
196
197SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
198
199SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
200IF (HAS_ADDRESS_SANITIZER)
201SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
202ENDIF()
203
204
205add_test(
206  NAME greptest
207  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
208  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
209
210add_test(
211  NAME proptest
212  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
213  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
214
215add_test(
216  NAME abc_test
217  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
218  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
219
220add_test(
221  NAME u8u16_test
222  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
223  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
224
225add_test(
226  NAME lz4d_test
227  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
228  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
229
230add_test(
231  NAME editd_test
232  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
233  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
234
235add_test(
236  NAME base64_test
237  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
238  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
239
240add_custom_target (u8u16_test
241  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
242  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
243
244add_custom_target (lz4d_test
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
246  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
247
248add_custom_target (editd_test
249  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
250  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
251
252add_custom_target (base64_test
253  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
254  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
255
256add_custom_target (abc_test
257  COMMAND python2 abc_testgen.py
258  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
259
260add_custom_target (check
261  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
262  DEPENDS icgrep abc_test)
263
264add_custom_target (perf_icgrep
265  COMMAND python2 perf.py icgrep
266  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
267  DEPENDS icgrep)
268
269add_custom_target (viewer
270  COMMAND python2 viewer.py
271  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
272
273add_custom_target (text_viewer
274  COMMAND python2 viewer.py -t
275  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
276
277add_custom_target (clear_cache
278  COMMAND rm ~/.cache/parabix/*)
279
280
Note: See TracBrowser for help on using the repository browser.