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

Last change on this file since 5646 was 5646, checked in by nmedfort, 18 months ago

Minor clean up. Bug fix for object cache when the same cached kernel is used twice in a single run. Improvement to RE Minimizer.

File size: 13.5 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)
12option(CARRYPACK_MANAGER "Use CarryPack Manager to reduce space required for carries. For testing only." OFF)
13find_package(LLVM REQUIRED CONFIG)
14
15message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
16
17set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
18
19set (Parabix_REVISION "svn")
20include(VersionFromVCS)
21add_version_info_from_vcs(Parabix_REVISION)
22message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
23
24
25# Now set the header and library paths:
26include_directories( ${LLVM_INCLUDE_DIRS} )
27link_directories( ${LLVM_LIBRARY_DIRS} )
28add_definitions( ${LLVM_DEFINITIONS} )
29
30# include(FindCUDA) # https://cmake.org/cmake/help/v3.0/module/FindCUDA.html
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(OBJECT_CACHE_SRC toolchain/object_cache.cpp)
60
61SET(TOOLCHAIN_SRC toolchain/toolchain.cpp toolchain/pipeline.cpp)
62
63SET(DRIVER_SRC toolchain/driver.cpp toolchain/cpudriver.cpp toolchain/NVPTXDriver.cpp)
64
65SET(KERNEL_SRC kernels/kernel.cpp kernels/streamset.cpp kernels/interface.cpp kernels/kernel_builder.cpp)
66SET(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)
67
68SET(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)
69SET(IDISA_SRC ${IDISA_SRC} IR_Gen/idisa_target.cpp)
70
71SET(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)
72SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp)
73IF (CARRYPACK_MANAGER)
74SET(PABLO_SRC ${PABLO_SRC} pablo/carrypack_manager.cpp)
75ELSE()
76SET(PABLO_SRC ${PABLO_SRC} pablo/carry_manager.cpp)
77ENDIF()
78SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
79SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
80SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/optimizers/schedulingprepass.cpp)
81SET(PABLO_SRC ${PABLO_SRC} pablo/passes/flattenif.cpp)
82IF(ENABLE_MULTIPLEXING)
83SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_automultiplexing.cpp)
84ENDIF()
85
86add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
87add_library(PabloADT ${PABLO_SRC})
88add_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)
89add_library(RegExpCompiler re/re_parser.cpp re/re_memoizer.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_star_normal.cpp re/re_minimizer.cpp re/re_local.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp re/re_name_resolve.cpp re/re_name_gather.cpp re/re_collect_unicodesets.cpp re/re_multiplex.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)
90add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
91add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
92
93# force the compiler to compile the object cache to ensure that the versioning information is up to date
94add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
95add_dependencies(CodeGen RecompileObjectCache)
96
97# add the executable
98target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
99target_link_libraries (PabloADT CodeGen)
100target_link_libraries (CCADT PabloADT)
101target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
102target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
103target_link_libraries (RegExpCompiler RegExpADT)
104
105add_executable(icgrep icgrep.cpp grep_interface.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/u8u32_kernel.cpp kernels/delmask_kernel.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/charclasses.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
106add_executable(u8u16 u8u16.cpp)
107add_executable(base64 base64.cpp kernels/radix64.cpp)
108add_executable(wc wc.cpp)
109add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp kernels/streams_merge.cpp kernels/cc_kernel.cpp)
110add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
111add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
112add_executable(core combine/core.cpp combine/regexGen.cpp combine/stringGen.cpp combine/icgrep-test/icgrep-test.cpp combine/pugixml/src/pugixml.cpp grep_interface.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/u8u32_kernel.cpp kernels/delmask_kernel.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/charclasses.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
113
114
115target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
116target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
117target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
118target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
119target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
120target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
121target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
122target_link_libraries (core RegExpCompiler ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES})
123
124IF(ENABLE_MULTIPLEXING)
125    message(STATUS "Enabling Multiplexing")
126    find_package(Z3 REQUIRED)
127    include_directories(${Z3_INCLUDE_DIRS})
128    target_link_libraries(PabloADT ${Z3_LIBRARIES})
129    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
130ENDIF()
131
132include_directories("${PROJECT_SOURCE_DIR}")
133
134#Check compiler support for 0x / 11
135include(CheckCXXCompilerFlag)
136CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
137if(COMPILER_SUPPORTS_CXX11)
138  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
139else()
140  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
141  if(COMPILER_SUPPORTS_CXX0X)
142    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
143  else()
144    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
145    if(COMPILER_SUPPORTS_GNU11)
146      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
147    else()
148      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
149      if(COMPILER_SUPPORTS_GNU0X)
150        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
151      endif()
152    endif()
153  endif()
154endif()
155
156#Disable RunTime Type Information
157IF (MSVC) # using Visual Studio C++
158  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
159ELSE() # using Clang, GCC, Intel C++, etc
160  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 
161ENDIF()
162
163#Disable Dual ABI support
164IF(DISABLE_DUAL_ABI)
165SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
166ENDIF()
167
168#Enable all warnings
169SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
170
171UNSET(HAS_EXECINFO CACHE)
172UNSET(HAS_MACH_VM_TYPES CACHE)
173include(CheckIncludeFileCXX)
174CHECK_INCLUDE_FILE_CXX(mach/vm_types.h HAS_MACH_VM_TYPES)
175IF (HAS_MACH_VM_TYPES)
176  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_MACH_VM_TYPES")
177ELSE()
178  UNSET(LIBUNWIND_FOUND CACHE)
179  find_package(Libunwind)
180  IF (LIBUNWIND_FOUND)
181    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_LIBUNWIND")
182    include_directories(${LIBUNWIND_INCLUDE_DIR})
183    target_link_libraries(CodeGen ${LIBUNWIND_LIBRARIES})
184  ELSE()
185    CHECK_INCLUDE_FILE_CXX(execinfo.h HAS_EXECINFO)
186    IF (HAS_EXECINFO)
187       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_EXECINFO")
188    ENDIF()
189  ENDIF()
190ENDIF()
191
192IF (CARRYPACK_MANAGER)
193SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_CARRYPACK_MANAGER")
194ENDIF()
195
196SET(CMAKE_REQUIRED_FLAGS)
197
198# detect LLVM version and add compiler flags.
199SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
200IF (${LLVM_VERSION_MAJOR} EQUAL 3)
201  IF (${LLVM_VERSION_MINOR} EQUAL 6)
202    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
203    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
204  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
205    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
206  ENDIF()
207ENDIF()
208
209SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
210IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
211  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
212ENDIF()
213
214SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
215
216SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
217
218UNSET(HAS_ADDRESS_SANITIZER)
219CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
220IF (HAS_ADDRESS_SANITIZER)
221SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
222ENDIF()
223
224
225add_test(
226  NAME greptest
227  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
228  COMMAND python greptest.py ${CMAKE_BINARY_DIR}/icgrep)
229
230add_test(
231  NAME proptest
232  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
233  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
234
235add_test(
236  NAME abc_test
237  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
238  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
239
240add_test(
241  NAME u8u16_test
242  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
243  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
244
245add_test(
246  NAME lz4d_test
247  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
248  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
249
250add_test(
251  NAME editd_test
252  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
253  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
254
255add_test(
256  NAME base64_test
257  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
258  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
259
260SET_PROPERTY(TEST greptest PROPERTY TIMEOUT 400)
261SET_PROPERTY(TEST proptest PROPERTY TIMEOUT 1500)
262SET_PROPERTY(TEST abc_test u8u16_test lz4d_test editd_test base64_test PROPERTY TIMEOUT 40)
263
264
265add_custom_target (greptest
266  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
267  COMMAND python greptest.py "${CMAKE_BINARY_DIR}/icgrep -ea")
268
269add_custom_target (proptest
270  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
271  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml "${CMAKE_BINARY_DIR}/icgrep -ea")
272
273add_custom_target (u8u16_test
274  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
275  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -ea -segment-size=16 -enable-segment-pipeline-parallel")
276
277add_custom_target (lz4d_test
278  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
279  COMMAND ./run_all "${CMAKE_BINARY_DIR}/lz4d -ea")
280
281add_custom_target (editd_test
282  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
283  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
284
285add_custom_target (base64_test
286  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
287  COMMAND python base64test.py "${CMAKE_BINARY_DIR}/base64 -ea")
288
289add_custom_target (abc_gen
290  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
291  COMMAND python abc_testgen.py)
292 
293add_custom_target (abc_test
294  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
295  COMMAND ./run_abc "${CMAKE_BINARY_DIR}/icgrep -ea")
296
297add_custom_target (check
298  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
299  DEPENDS icgrep abc_gen)
300
301add_custom_target (perf_icgrep
302  COMMAND python2 perf.py icgrep
303  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
304  DEPENDS icgrep)
305
306add_custom_target (viewer
307  COMMAND python2 viewer.py
308  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
309
310add_custom_target (text_viewer
311  COMMAND python2 viewer.py -t
312  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
313
314add_custom_target (clear_cache
315  COMMAND rm ~/.cache/parabix/*)
316
317
Note: See TracBrowser for help on using the repository browser.