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

Last change on this file since 5404 was 5404, checked in by cameron, 2 years ago

Grep kernels with signatures and object caching

File size: 11.2 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
10
11
12option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
13option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
14option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
15find_package(LLVM REQUIRED CONFIG)
16
17message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
18
19set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
20
21set (Parabix_REVISION "svn")
22include(VersionFromVCS)
23add_version_info_from_vcs(Parabix_REVISION)
24message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
25
26
27# Now set the header and library paths:
28include_directories( ${LLVM_INCLUDE_DIRS} )
29link_directories( ${LLVM_LIBRARY_DIRS} )
30add_definitions( ${LLVM_DEFINITIONS} )
31
32option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
33set(CUDA_LIB "")
34if(ENABLE_CUDA_COMPILE)
35  find_package(CUDA)
36  if(CUDA_FOUND)
37    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
38    include_directories(${CUDA_INCLUDE})
39    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
40    SET(CUDA_LIB "cuda")
41  endif(CUDA_FOUND)
42endif()
43
44# Let's suppose we want to build a JIT compiler with support for
45# binary code (no interpreter):
46set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
47llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
48
49# Check if boost has been installed on this system.
50set(Boost_USE_STATIC_LIBS ON)
51set(Boost_USE_MULTITHREADED OFF)
52set(Boost_USE_STATIC_RUNTIME OFF)
53find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
54message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
55
56include_directories("${Boost_INCLUDE_DIRS}")
57link_directories(${Boost_LIBRARY_DIR})
58
59SET(KERNEL_SRC kernels/kernel.cpp kernels/pipeline.cpp kernels/streamset.cpp kernels/interface.cpp)
60SET(KERNEL_SRC ${KERNEL_SRC} kernels/toolchain.cpp kernels/object_cache.cpp)
61SET(KERNEL_SRC ${KERNEL_SRC} kernels/s2p_kernel.cpp kernels/mmap_kernel.cpp kernels/deletion.cpp kernels/swizzle.cpp kernels/p2s_kernel.cpp kernels/stdin_kernel.cpp kernels/stdout_kernel.cpp)
62
63SET(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)
64
65SET(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)
66SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
67SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
68SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
69SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/passes/flattenif.cpp)
70IF(ENABLE_MULTIPLEXING)
71SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
72SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
73ENDIF()
74
75add_library(CodeGen ${KERNEL_SRC} ${IDISA_SRC})
76add_library(PabloADT ${PABLO_SRC})
77add_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)
78add_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)
79add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
80add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
81
82# add the executable
83target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
84target_link_libraries (CCADT PabloADT)
85target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
86target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
87target_link_libraries (RegExpCompiler RegExpADT)
88
89add_executable(icgrep icgrep.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)
90add_executable(u8u16 u8u16.cpp)
91add_executable(base64 base64.cpp kernels/radix64.cpp)
92add_executable(wc wc.cpp)
93add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
94add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
95
96## IWYU detects superfluous includes and when the include can be replaced with a forward declaration.
97## It can be obtained using "apt-get install iwyu" or from "github.com/include-what-you-use".
98
99#find_program(IWYU_PATH NAMES include-what-you-use iwyu)
100#if(IWYU_PATH)
101#cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
102#execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE)
103#get_filename_component(LIBGCC_PATH ${LIBGCC_FILE} DIRECTORY)
104#include_directories("${LIBGCC_PATH}/include")
105#set_property(TARGET CodeGen PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
106#set_property(TARGET PabloADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
107#set_property(TARGET RegExpADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
108#set_property(TARGET RegExpCompiler PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
109#set_property(TARGET CCADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
110#set_property(TARGET UCDlib PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
111#set_property(TARGET icgrep PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
112#set_property(TARGET u8u16 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
113#set_property(TARGET base64 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
114#set_property(TARGET wc PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
115#set_property(TARGET editd PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
116#set_property(TARGET array-test PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
117#endif()
118
119IF (PRINT_TIMING_INFORMATION)
120    find_package(PAPI REQUIRED)
121    include_directories(${PAPI_INCLUDE_DIRS})
122    target_link_libraries(icgrep ${PAPI_LIBRARIES})
123ENDIF()
124
125target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
126target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
127target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
128target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
129target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
130target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
131
132IF(ENABLE_MULTIPLEXING)
133    message(STATUS "Enabling Multiplexing")
134    find_package(Z3 REQUIRED)
135    include_directories(${Z3_INCLUDE_DIRS})
136    target_link_libraries(PabloADT ${Z3_LIBRARIES})
137    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
138ENDIF()
139
140include_directories("${PROJECT_SOURCE_DIR}")
141
142#Check compiler support for 0x / 11
143include(CheckCXXCompilerFlag)
144CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
145if(COMPILER_SUPPORTS_CXX11)
146  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
147else()
148  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
149  if(COMPILER_SUPPORTS_CXX0X)
150    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
151  else()
152    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
153    if(COMPILER_SUPPORTS_GNU11)
154      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
155    else()
156      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
157      if(COMPILER_SUPPORTS_GNU0X)
158        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
159      endif()
160    endif()
161  endif()
162endif()
163
164#Disable RunTime Type Information
165IF (MSVC) # using Visual Studio C++
166  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
167ELSE() # using Clang, GCC, Intel C++, etc
168  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
169ENDIF()
170
171#Disable Dual ABI support
172IF(DISABLE_DUAL_ABI)
173SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
174ENDIF()
175
176#Enable all warnings
177SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
178
179SET(CMAKE_REQUIRED_FLAGS)
180
181# detect LLVM version and add compiler flags.
182SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
183IF (${LLVM_VERSION_MAJOR} EQUAL 3)
184  IF (${LLVM_VERSION_MINOR} EQUAL 6)
185    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
186    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
187  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
188    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
189  ENDIF()
190ENDIF()
191
192SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
193
194IF (PRINT_TIMING_INFORMATION)
195    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
196ENDIF()
197
198SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
199SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
200
201add_test(
202  NAME greptest
203  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
204  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
205
206add_test(
207  NAME proptest
208  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
209  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
210
211add_test(
212  NAME abc_test
213  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
214  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
215
216add_test(
217  NAME u8u16_test
218  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
219  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
220
221add_test(
222  NAME editd_test
223  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
224  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
225
226add_test(
227  NAME base64_test
228  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
229  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
230
231add_custom_target (u8u16_test
232  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
233  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
234
235add_custom_target (editd_test
236  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
237  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
238
239add_custom_target (base64_test
240  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
241  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
242
243add_custom_target (abc_test
244  COMMAND python2 abc_testgen.py
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
246
247add_custom_target (check
248  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
249  DEPENDS icgrep abc_test)
250
251add_custom_target (perf_icgrep
252  COMMAND python2 perf.py icgrep
253  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
254  DEPENDS icgrep)
255
256add_custom_target (viewer
257  COMMAND python2 viewer.py
258  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
259
260add_custom_target (text_viewer
261  COMMAND python2 viewer.py -t
262  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.