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

Last change on this file since 5238 was 5238, checked in by cameron, 2 years ago

IR_Gen subdirectory for all IR generation utility functions

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