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

Last change on this file since 5564 was 5564, checked in by xuedongx, 21 months ago

add some of the kernels multiplex CCs need

File size: 13.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
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_nullable.cpp re/re_simplifier.cpp re/re_star_normal.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)
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)
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}\"'")
210
211SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
212
213SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
214
215UNSET(HAS_ADDRESS_SANITIZER)
216CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
217IF (HAS_ADDRESS_SANITIZER)
218SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
219ENDIF()
220
221
222add_test(
223  NAME greptest
224  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
225  COMMAND python greptest.py ${CMAKE_BINARY_DIR}/icgrep)
226
227add_test(
228  NAME proptest
229  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
230  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
231
232add_test(
233  NAME abc_test
234  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
235  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
236
237add_test(
238  NAME u8u16_test
239  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
240  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
241
242add_test(
243  NAME lz4d_test
244  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
245  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
246
247add_test(
248  NAME editd_test
249  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
250  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
251
252add_test(
253  NAME base64_test
254  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
255  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
256
257SET_PROPERTY(TEST greptest PROPERTY TIMEOUT 400)
258SET_PROPERTY(TEST proptest PROPERTY TIMEOUT 1500)
259SET_PROPERTY(TEST abc_test u8u16_test lz4d_test editd_test base64_test PROPERTY TIMEOUT 40)
260
261
262add_custom_target (greptest
263  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
264  COMMAND python greptest.py "${CMAKE_BINARY_DIR}/icgrep -ea")
265
266add_custom_target (proptest
267  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
268  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml "${CMAKE_BINARY_DIR}/icgrep -ea")
269
270add_custom_target (u8u16_test
271  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
272  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -ea -segment-size=16 -enable-segment-pipeline-parallel")
273
274add_custom_target (lz4d_test
275  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
276  COMMAND ./run_all "${CMAKE_BINARY_DIR}/lz4d -ea")
277
278add_custom_target (editd_test
279  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
280  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
281
282add_custom_target (base64_test
283  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
284  COMMAND python base64test.py "${CMAKE_BINARY_DIR}/base64 -ea")
285
286add_custom_target (abc_gen
287  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
288  COMMAND python abc_testgen.py)
289 
290add_custom_target (abc_test
291  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
292  COMMAND ./run_abc "${CMAKE_BINARY_DIR}/icgrep -ea")
293
294add_custom_target (check
295  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
296  DEPENDS icgrep abc_gen)
297
298add_custom_target (perf_icgrep
299  COMMAND python2 perf.py icgrep
300  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
301  DEPENDS icgrep)
302
303add_custom_target (viewer
304  COMMAND python2 viewer.py
305  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
306
307add_custom_target (text_viewer
308  COMMAND python2 viewer.py -t
309  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
310
311add_custom_target (clear_cache
312  COMMAND rm ~/.cache/parabix/*)
313
314
Note: See TracBrowser for help on using the repository browser.