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

Last change on this file since 5753 was 5753, checked in by cameron, 17 months ago

Parser for fixed strings (-F) mode

File size: 13.5 KB
RevLine 
[5179]1cmake_minimum_required (VERSION 2.8)
[3850]2
3project (icgrep)
4
[4096]5enable_testing()
[3850]6# The version number.
[4508]7set (icgrep_VERSION_MAJOR 1)
[5178]8set (icgrep_VERSION_MINOR 6)
[4096]9
[4583]10option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
[5240]11option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
[5510]12option(CARRYPACK_MANAGER "Use CarryPack Manager to reduce space required for carries. For testing only." OFF)
[5178]13find_package(LLVM REQUIRED CONFIG)
[3850]14
[5240]15message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
[5373]16
[5202]17set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
[3850]18
[5373]19set (Parabix_REVISION "svn")
20include(VersionFromVCS)
21add_version_info_from_vcs(Parabix_REVISION)
22message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
23
24
[3850]25# Now set the header and library paths:
26include_directories( ${LLVM_INCLUDE_DIRS} )
27link_directories( ${LLVM_LIBRARY_DIRS} )
28add_definitions( ${LLVM_DEFINITIONS} )
29
[5486]30# include(FindCUDA) # https://cmake.org/cmake/help/v3.0/module/FindCUDA.html
31
[5151]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
[3850]44# Let's suppose we want to build a JIT compiler with support for
45# binary code (no interpreter):
[5733]46set(LLVM_ALL_TARGETS X86)
[5151]47llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
[3850]48
[4196]49# Check if boost has been installed on this system.
[4210]50set(Boost_USE_STATIC_LIBS ON)
51set(Boost_USE_MULTITHREADED OFF)
[5234]52set(Boost_USE_STATIC_RUNTIME OFF)
[4991]53find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
[5252]54message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
[4212]55
[4991]56include_directories("${Boost_INCLUDE_DIRS}")
57link_directories(${Boost_LIBRARY_DIR})
[4974]58
[5429]59SET(OBJECT_CACHE_SRC toolchain/object_cache.cpp)
[5405]60
[5679]61SET(GREP_CORE_SRC toolchain/grep_pipeline.cpp kernels/linebreak_kernel.cpp kernels/grep_kernel.cpp kernels/scanmatchgen.cpp )
62
[5510]63SET(TOOLCHAIN_SRC toolchain/toolchain.cpp toolchain/pipeline.cpp)
[5429]64
[5734]65SET(DRIVER_SRC toolchain/driver.cpp toolchain/cpudriver.cpp)
66if(ENABLE_CUDA_COMPILE)
67SET(DRIVER_SRC ${DRIVER_SRC} toolchain/NVPTXDriver.cpp)
68endif()
[5464]69
[5706]70SET(KERNEL_SRC kernels/interface.cpp kernels/kernel.cpp kernels/streamset.cpp kernels/kernel_builder.cpp)
[5429]71SET(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)
[5267]72
[5734]73SET(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)
[5510]74SET(IDISA_SRC ${IDISA_SRC} IR_Gen/idisa_target.cpp)
[5734]75if(ENABLE_CUDA_COMPILE)
76SET(IDISA_SRC ${IDISA_SRC} IR_Gen/idisa_nvptx_builder.cpp)
77endif()
[5033]78
[5217]79SET(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)
[5510]80SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp)
81IF (CARRYPACK_MANAGER)
82SET(PABLO_SRC ${PABLO_SRC} pablo/carrypack_manager.cpp)
83ELSE()
84SET(PABLO_SRC ${PABLO_SRC} pablo/carry_manager.cpp)
85ENDIF()
[4766]86SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
[5371]87SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
[5510]88SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/optimizers/schedulingprepass.cpp)
89SET(PABLO_SRC ${PABLO_SRC} pablo/passes/flattenif.cpp)
[4922]90IF(ENABLE_MULTIPLEXING)
[5510]91SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_automultiplexing.cpp)
[4583]92ENDIF()
93
[5464]94add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
[4583]95add_library(PabloADT ${PABLO_SRC})
[5725]96add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_rep.cpp re/re_diff.cpp re/re_intersect.cpp re/re_assertion.cpp re/printer_re.cpp)
[5753]97add_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/parse_fixed_strings.cpp re/re_utility.cpp ${GREP_CORE_SRC})
[5673]98add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
[5679]99add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp)
[4198]100
[5405]101# force the compiler to compile the object cache to ensure that the versioning information is up to date
102add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
103add_dependencies(CodeGen RecompileObjectCache)
104
[4684]105# add the executable
[5464]106target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
107target_link_libraries (PabloADT CodeGen)
[4684]108target_link_libraries (CCADT PabloADT)
[5679]109target_link_libraries (UCDlib RegExpCompiler RegExpADT PabloADT CCADT)
[4684]110target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
[5679]111target_link_libraries (RegExpCompiler UCDlib RegExpADT)
[4684]112
[5679]113add_executable(icgrep icgrep.cpp grep_interface.cpp grep_engine.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)
[5402]114add_executable(u8u16 u8u16.cpp)
115add_executable(base64 base64.cpp kernels/radix64.cpp)
[5459]116add_executable(wc wc.cpp)
[5591]117add_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)
[5402]118add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
[5423]119add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
[5564]120add_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)
[5172]121
[5516]122
[5217]123target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
124target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5232]125target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5217]126target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
127target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5227]128target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5680]129target_link_libraries (lz4d PabloADT UCDlib RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5518]130target_link_libraries (core RegExpCompiler ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES})
[4919]131
[4922]132IF(ENABLE_MULTIPLEXING)
[5156]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")
[4583]138ENDIF()
139
[4096]140include_directories("${PROJECT_SOURCE_DIR}")
141
[4152]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")
[5156]155    else()
156      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
[4152]157      if(COMPILER_SUPPORTS_GNU0X)
158        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
159      endif()
160    endif()
161  endif()
162endif()
[4096]163
[4200]164#Disable RunTime Type Information
[5037]165IF (MSVC) # using Visual Studio C++
[4436]166  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
[4200]167ELSE() # using Clang, GCC, Intel C++, etc
[5646]168  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 
[4200]169ENDIF()
170
[5240]171#Disable Dual ABI support
172IF(DISABLE_DUAL_ABI)
173SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
174ENDIF()
175
[4227]176#Enable all warnings
[4356]177SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
[4200]178
[5493]179UNSET(HAS_EXECINFO CACHE)
180UNSET(HAS_MACH_VM_TYPES CACHE)
[5486]181include(CheckIncludeFileCXX)
[5493]182CHECK_INCLUDE_FILE_CXX(mach/vm_types.h HAS_MACH_VM_TYPES)
183IF (HAS_MACH_VM_TYPES)
184  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_MACH_VM_TYPES")
[5489]185ELSE()
[5493]186  UNSET(LIBUNWIND_FOUND CACHE)
187  find_package(Libunwind)
188  IF (LIBUNWIND_FOUND)
189    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_LIBUNWIND")
190    include_directories(${LIBUNWIND_INCLUDE_DIR})
191    target_link_libraries(CodeGen ${LIBUNWIND_LIBRARIES})
192  ELSE()
193    CHECK_INCLUDE_FILE_CXX(execinfo.h HAS_EXECINFO)
194    IF (HAS_EXECINFO)
195       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_EXECINFO")
196    ENDIF()
197  ENDIF()
[5486]198ENDIF()
199
[5510]200IF (CARRYPACK_MANAGER)
201SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_CARRYPACK_MANAGER")
202ENDIF()
203
[4480]204SET(CMAKE_REQUIRED_FLAGS)
[4152]205
[4118]206# detect LLVM version and add compiler flags.
[5731]207MATH(EXPR LLVM_VERSION_INTEGER "${LLVM_VERSION_MAJOR} * 10000 + ${LLVM_VERSION_MINOR} * 100 + ${LLVM_VERSION_PATCH}")
208SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_INTEGER=${LLVM_VERSION_INTEGER}")
[5196]209SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
[5734]210message(STATUS "LLVM Version Integer: ${LLVM_VERSION_INTEGER}")
[4118]211
[5599]212SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
213IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
214  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
215ENDIF()
[5373]216
[5486]217SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
218
219SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
[5489]220
[5493]221UNSET(HAS_ADDRESS_SANITIZER)
222CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
[5486]223IF (HAS_ADDRESS_SANITIZER)
224SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
[4919]225ENDIF()
226
[5495]227
[4096]228add_test(
229  NAME greptest
230  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5495]231  COMMAND python greptest.py ${CMAKE_BINARY_DIR}/icgrep)
[4096]232
[4137]233add_test(
[4456]234  NAME proptest
235  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5495]236  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
[4456]237
238add_test(
[4137]239  NAME abc_test
240  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5495]241  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
[4137]242
[5208]243add_test(
244  NAME u8u16_test
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
[5495]246  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
[5208]247
[5722]248#add_test(
249#  NAME lz4d_test
250#  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
251#  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
[5423]252
253add_test(
[5226]254  NAME editd_test
255  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
[5495]256  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
[5226]257
[5288]258add_test(
259  NAME base64_test
260  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
[5495]261  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
[5288]262
[5496]263SET_PROPERTY(TEST greptest PROPERTY TIMEOUT 400)
264SET_PROPERTY(TEST proptest PROPERTY TIMEOUT 1500)
[5702]265SET_PROPERTY(TEST abc_test PROPERTY TIMEOUT 100)
[5722]266SET_PROPERTY(TEST u8u16_test editd_test base64_test PROPERTY TIMEOUT 40)
[5495]267
268
[5493]269add_custom_target (greptest
270  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5722]271  COMMAND python greptest.py "${CMAKE_BINARY_DIR}/icgrep")
[5493]272
273add_custom_target (proptest
274  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5722]275  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml "${CMAKE_BINARY_DIR}/icgrep")
[5493]276
[5211]277add_custom_target (u8u16_test
278  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
[5722]279  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
[5211]280
[5423]281add_custom_target (lz4d_test
282  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
[5722]283  COMMAND ./run_all "${CMAKE_BINARY_DIR}/lz4d")
[5423]284
[5223]285add_custom_target (editd_test
286  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
[5495]287  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
[5223]288
[5289]289add_custom_target (base64_test
290  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
[5722]291  COMMAND python base64test.py "${CMAKE_BINARY_DIR}/base64")
[5289]292
[5494]293add_custom_target (abc_gen
294  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
295  COMMAND python abc_testgen.py)
296 
[4137]297add_custom_target (abc_test
[5493]298  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5722]299  COMMAND ./run_abc "${CMAKE_BINARY_DIR}/icgrep")
[4137]300
[4096]301add_custom_target (check
[4130]302  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
[5494]303  DEPENDS icgrep abc_gen)
[4128]304
305add_custom_target (perf_icgrep
[4785]306  COMMAND python2 perf.py icgrep
[4128]307  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
308  DEPENDS icgrep)
309
310add_custom_target (viewer
[4785]311  COMMAND python2 viewer.py
[4128]312  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
313
[4275]314add_custom_target (text_viewer
[4785]315  COMMAND python2 viewer.py -t
[4275]316  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
[5469]317
318
Note: See TracBrowser for help on using the repository browser.