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

Last change on this file since 5241 was 5241, checked in by nmedfort, 2 years ago

Potential fix for '\p{script=/.*hir.*/}'

File size: 9.1 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")
[4919]11option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
[5240]12option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
[5178]13find_package(LLVM REQUIRED CONFIG)
[3850]14
[5240]15message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
[5202]16set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
[3850]17
18# Now set the header and library paths:
19include_directories( ${LLVM_INCLUDE_DIRS} )
20link_directories( ${LLVM_LIBRARY_DIRS} )
21add_definitions( ${LLVM_DEFINITIONS} )
22
[5151]23option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
24set(CUDA_LIB "")
25if(ENABLE_CUDA_COMPILE)
26  find_package(CUDA)
27  if(CUDA_FOUND)
28    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
29    include_directories(${CUDA_INCLUDE})
30    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
31    SET(CUDA_LIB "cuda")
32  endif(CUDA_FOUND)
33endif()
34
[3850]35# Let's suppose we want to build a JIT compiler with support for
36# binary code (no interpreter):
[5151]37set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
38llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
[3850]39
[4196]40# Check if boost has been installed on this system.
[4210]41set(Boost_USE_STATIC_LIBS ON)
42set(Boost_USE_MULTITHREADED OFF)
[5234]43set(Boost_USE_STATIC_RUNTIME OFF)
[4991]44find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
[4212]45
[4991]46include_directories("${Boost_INCLUDE_DIRS}")
47link_directories(${Boost_LIBRARY_DIR})
[4974]48
[5227]49SET(KERNEL_SRC kernels/kernel.cpp kernels/s2p_kernel.cpp kernels/streamset.cpp kernels/interface.cpp)
[5239]50SET(IDISA_SRC IR_Gen/CBuilder.cpp IR_Gen/types/streamtype.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)
[5033]51
[5217]52SET(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)
[5227]53SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
[4766]54SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
[5202]55SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/passes/flattenif.cpp)
[4922]56IF(ENABLE_MULTIPLEXING)
[5160]57SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
[5156]58SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
[4583]59ENDIF()
60
[5227]61
62add_library(CodeGen ${KERNEL_SRC} ${IDISA_SRC} object_cache.cpp)
[4583]63add_library(PabloADT ${PABLO_SRC})
[4684]64add_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)
[5218]65add_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)
[5045]66add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp)
[4949]67add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
[4198]68
[5033]69
[4684]70# add the executable
[5033]71target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
[4684]72target_link_libraries (CCADT PabloADT)
73target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
74target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
75target_link_libraries (RegExpCompiler RegExpADT)
76
[5234]77add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp)
[5185]78add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
[5232]79add_executable(base64 base64.cpp kernels/radix64.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
[5088]80add_executable(wc wc.cpp toolchain.cpp kernels/pipeline.cpp)
[5212]81add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp toolchain.cpp kernels/pipeline.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
[5227]82add_executable(array-test array-test.cpp toolchain.cpp kernels/pipeline.cpp)
[5172]83
[4919]84IF (PRINT_TIMING_INFORMATION)
85    find_package(PAPI REQUIRED)
86    include_directories(${PAPI_INCLUDE_DIRS})
87    target_link_libraries(icgrep ${PAPI_LIBRARIES})
88ENDIF()
[4583]89
[5217]90target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
91target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5232]92target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5217]93target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
94target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5227]95target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[4919]96
[4922]97IF(ENABLE_MULTIPLEXING)
[5156]98    message(STATUS "Enabling Multiplexing")
99    find_package(Z3 REQUIRED)
100    include_directories(${Z3_INCLUDE_DIRS})
101    target_link_libraries(PabloADT ${Z3_LIBRARIES})
102    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
[4583]103ENDIF()
104
[4096]105include_directories("${PROJECT_SOURCE_DIR}")
106
[4152]107#Check compiler support for 0x / 11
108include(CheckCXXCompilerFlag)
109CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
110if(COMPILER_SUPPORTS_CXX11)
111  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
112else()
113  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
114  if(COMPILER_SUPPORTS_CXX0X)
115    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
116  else()
117    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
118    if(COMPILER_SUPPORTS_GNU11)
119      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
[5156]120    else()
121      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
[4152]122      if(COMPILER_SUPPORTS_GNU0X)
123        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
124      endif()
125    endif()
126  endif()
127endif()
[4096]128
[4200]129#Disable RunTime Type Information
[5037]130IF (MSVC) # using Visual Studio C++
[4436]131  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
[4200]132ELSE() # using Clang, GCC, Intel C++, etc
[4436]133  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
[4200]134ENDIF()
135
[5240]136#Disable Dual ABI support
137IF(DISABLE_DUAL_ABI)
138SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
139ENDIF()
140
[4227]141#Enable all warnings
[4356]142SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
[4200]143
[4480]144SET(CMAKE_REQUIRED_FLAGS)
[4152]145
[4118]146# detect LLVM version and add compiler flags.
[5196]147SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
148IF (${LLVM_VERSION_MAJOR} EQUAL 3)
149  IF (${LLVM_VERSION_MINOR} EQUAL 6)
150    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
151    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
152  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
153    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
154  ENDIF()
[4480]155ENDIF()
[4118]156
[5156]157IF (PRINT_TIMING_INFORMATION)
[4919]158    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
159ENDIF()
160
[4200]161SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
[5241]162SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g") #-fsanitize=address -fno-omit-frame-pointer
[4152]163
[4096]164add_test(
165  NAME greptest
166  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]167  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
[4096]168
[4137]169add_test(
[4456]170  NAME proptest
171  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]172  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
[4456]173
174add_test(
[4137]175  NAME abc_test
176  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5151]177  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
[4137]178
[5208]179add_test(
180  NAME u8u16_test
181  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
182  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
183
[5226]184add_test(
185  NAME editd_test
186  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
187  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
188
[5211]189add_custom_target (u8u16_test
190  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
191  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
192
[5223]193add_custom_target (editd_test
194  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
[5226]195  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
[5223]196
[4137]197add_custom_target (abc_test
[4785]198  COMMAND python2 abc_testgen.py
[4137]199  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
200
[4096]201add_custom_target (check
[4130]202  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
[4137]203  DEPENDS icgrep abc_test)
[4128]204
205add_custom_target (perf_icgrep
[4785]206  COMMAND python2 perf.py icgrep
[4128]207  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
208  DEPENDS icgrep)
209
210add_custom_target (viewer
[4785]211  COMMAND python2 viewer.py
[4128]212  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
213
[4275]214add_custom_target (text_viewer
[4785]215  COMMAND python2 viewer.py -t
[4275]216  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.