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

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

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

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