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

Last change on this file since 5059 was 5059, checked in by cameron, 3 years ago

Pablo Kernel progress

File size: 9.8 KB
RevLine 
[3850]1cmake_minimum_required (VERSION 2.8)
2
3project (icgrep)
4
[4096]5enable_testing()
[3850]6# The version number.
[4508]7set (icgrep_VERSION_MAJOR 1)
[5033]8set (icgrep_VERSION_MINOR 5)
[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
[3850]14# configure a header file to pass some of the CMake settings
15# to the source code
16#configure_file (
17#  "${PROJECT_SOURCE_DIR}/icgrepconfig.h.in"
18#  "${PROJECT_BINARY_DIR}/icgrepconfig.h"
19#  )
20
21# LLVM set up
22#
23# A convenience variable:
24set(LLVM_ROOT "../libllvm" CACHE PATH "Root of LLVM install.")
25
26# A bit of a sanity check:
27if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
28message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
29endif()
30
31# We incorporate the CMake features provided by LLVM:
[4919]32set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${LLVM_ROOT}/share/llvm/cmake;${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33
[3850]34include(LLVMConfig)
35
36# Now set the header and library paths:
37include_directories( ${LLVM_INCLUDE_DIRS} )
38link_directories( ${LLVM_LIBRARY_DIRS} )
39add_definitions( ${LLVM_DEFINITIONS} )
40
41# Let's suppose we want to build a JIT compiler with support for
42# binary code (no interpreter):
[5047]43llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES mcjit native IRReader Linker) # ipo
[3850]44
[5037]45message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in ${LLVM_ROOT_DIR}")
[4096]46
[4196]47# Check if boost has been installed on this system.
[4210]48set(Boost_USE_STATIC_LIBS ON)
49set(Boost_USE_MULTITHREADED OFF)
[4583]50set(Boost_USE_STATIC_RUNTIME ON)
[4991]51find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
[4212]52
[4991]53include_directories("${Boost_INCLUDE_DIRS}")
54link_directories(${Boost_LIBRARY_DIR})
55SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
[4974]56
[5033]57SET(IDISA_SRC IDISA/idisa_builder.cpp IDISA/idisa_avx_builder.cpp IDISA/idisa_i64_builder.cpp IDISA/idisa_sse_builder.cpp IDISA/idisa_target.cpp)
58
[5032]59SET(PABLO_SRC pablo/pabloAST.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/function.cpp pablo/codegenstate.cpp pablo/builder.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_toolchain.cpp pablo/passes/flattenif.cpp)
[5059]60SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp pablo/pablo_kernel.cpp)
[5047]61SET(PABLO_SRC ${PABLO_SRC} kernels/s2p_kernel.cpp kernels/kernel.cpp kernels/instance.cpp kernels/streamset.cpp kernels/interface.cpp)
[4766]62SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
[4920]63SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp)
[4922]64IF(ENABLE_MULTIPLEXING)
[4920]65SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/distributivepass.cpp pablo/passes/flattenassociativedfg.cpp pablo/passes/factorizedfg.cpp)
66SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp pablo/optimizers/pablo_bddminimization.cpp)
[4583]67ENDIF()
68
69add_library(PabloADT ${PABLO_SRC})
[4684]70add_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)
[5022]71add_library(RegExpCompiler re/re_parser.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp)
[5045]72add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp)
[4949]73add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
[4198]74
[5033]75add_library(CodeGen object_cache.cpp util/ispc.cpp ${IDISA_SRC})
76
[4684]77# add the executable
[5033]78target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
[4684]79target_link_libraries (CCADT PabloADT)
80target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
81target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
82target_link_libraries (RegExpCompiler RegExpADT)
83
[4686]84set(PRECOMPILED_FILES "")
85
[4908]86IF(NOT ENABLE_PREGENERATED_UCD_FUNCTIONS)
[4686]87set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_PREGENERATED_UCD_FUNCTIONS")
88ELSE()
[4908]89MESSAGE("Enabling predefined UCD functions...")
[4684]90# add the executable
91add_executable(generate_predefined_ucd_functions generate_predefined_ucd_functions.cpp)
[4784]92llvm_map_components_to_libnames(REQ_LLVM_TARGETS ${LLVM_TARGETS_TO_BUILD})
93target_link_libraries (generate_predefined_ucd_functions RegExpADT UCDlib PabloADT CCADT ${REQ_LLVM_TARGETS})
[4684]94
95set(PRECOMPILED_PROPERTIES_OBJ ${PROJECT_BINARY_DIR}/precompiled_properties.o)
96set(PRECOMPILED_FILES ${PRECOMPILED_PROPERTIES_OBJ} ${PROJECT_SOURCE_DIR}/UCD/precompiled_properties.cpp)
97
[4777]98if(ENABLE_MULTIPLEXING)
[4799]99set(MULTIPLEXING_FLAG -multiplexing -reassoc -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv) # -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv #-ldc=ldc.csv
[4777]100endif()
[4684]101
102add_custom_command(OUTPUT ${PRECOMPILED_FILES}
103  COMMAND generate_predefined_ucd_functions
[4788]104  ARGS -o ${PRECOMPILED_PROPERTIES_OBJ} -dir ${PROJECT_SOURCE_DIR}/UCD/ ${MULTIPLEXING_FLAG} -DefaultIfHierarchy
[4684]105  DEPENDS generate_predefined_ucd_functions
106  COMMENT "Building predefined UCD functions..."
107  VERBATIM)
108
[4692]109add_custom_target(run_generate_predefined_ucd_functions DEPENDS ${PRECOMPILED_FILES})
[4684]110
[4686]111add_dependencies(RegExpCompiler run_generate_predefined_ucd_functions)
112ENDIF()
113
[5033]114add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp ${PRECOMPILED_FILES})
115add_executable(casefold casefold.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/stdout_kernel.cpp kernels/casefold_pipeline.cpp)
116add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/stdout_kernel.cpp kernels/u8u16_pipeline.cpp kernels/deletion.cpp)
117add_executable(symtbl symboltable.cpp toolchain.cpp kernels/symboltablepipeline.cpp kernels/stdout_kernel.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp ${PRECOMPILED_FILES})
118add_executable(wc wc.cpp toolchain.cpp)
[4988]119
[4908]120IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
[4686]121add_dependencies(icgrep run_generate_predefined_ucd_functions)
122ENDIF()
[4991]123
[4919]124IF (PRINT_TIMING_INFORMATION)
125    find_package(PAPI REQUIRED)
126    include_directories(${PAPI_INCLUDE_DIRS})
127    target_link_libraries(icgrep ${PAPI_LIBRARIES})
128ENDIF()
[4583]129
[4991]130target_link_libraries(icgrep ${Boost_LIBRARIES})
131target_link_libraries(symtbl ${Boost_LIBRARIES})
132target_link_libraries(casefold ${Boost_LIBRARIES})
[5005]133target_link_libraries(u8u16 ${Boost_LIBRARIES})
[5018]134target_link_libraries(wc ${Boost_LIBRARIES})
[4919]135
[5033]136target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES})
137target_link_libraries (symtbl UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES})
138target_link_libraries (casefold UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES})
139target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES})
140target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES})
[4734]141
[4922]142IF(ENABLE_MULTIPLEXING)
[4583]143message(STATUS "Enabling Multiplexing")
[4937]144SET(BUDDY_ROOT "${CMAKE_SOURCE_DIR}/../buddy-2.4/src")
145SET(BUDDY_SOURCES ${BUDDY_ROOT}/bddop.cpp ${BUDDY_ROOT}/cache.cpp ${BUDDY_ROOT}/imatrix.cpp ${BUDDY_ROOT}/kernel.cpp)
146SET(BUDDY_SOURCES ${BUDDY_SOURCES} ${BUDDY_ROOT}/prime.cpp ${BUDDY_ROOT}/pairs.cpp ${BUDDY_ROOT}/reorder.cpp ${BUDDY_ROOT}/tree.cpp)
[4868]147add_library(BUDDY ${BUDDY_SOURCES})
[4937]148include_directories(${BUDDY_ROOT})
[4868]149target_link_libraries (PabloADT BUDDY)
[4583]150SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
151ENDIF()
152
[4096]153include_directories("${PROJECT_SOURCE_DIR}")
154
[4152]155#Check compiler support for 0x / 11
156include(CheckCXXCompilerFlag)
157CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
158if(COMPILER_SUPPORTS_CXX11)
159  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
160else()
161  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
162  if(COMPILER_SUPPORTS_CXX0X)
163    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
164  else()
165    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
166    if(COMPILER_SUPPORTS_GNU11)
167      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
168    else() 
169      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)   
170      if(COMPILER_SUPPORTS_GNU0X)
171        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
172      endif()
173    endif()
174  endif()
175endif()
[4096]176
[4200]177#Disable RunTime Type Information
[5037]178IF (MSVC) # using Visual Studio C++
[4436]179  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
[4200]180ELSE() # using Clang, GCC, Intel C++, etc
[4436]181  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
[4200]182ENDIF()
183
[4227]184#Enable all warnings
[4356]185SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
[4200]186
[4480]187SET(CMAKE_REQUIRED_FLAGS)
[4152]188
[4118]189# detect LLVM version and add compiler flags.
[4508]190IF (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
[4152]191  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_5")
[4480]192ENDIF()
[4118]193
[4919]194IF (PRINT_TIMING_INFORMATION)   
195    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
196ENDIF()
197
[4200]198SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
[5037]199SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
[4152]200
[4096]201add_test(
202  NAME greptest
203  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]204  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
[4096]205
[4137]206add_test(
[4456]207  NAME proptest
208  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]209  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
[4456]210
211add_test(
[4137]212  NAME abc_test
213  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
214  COMMAND ./run_abc ../icgrep-build/icgrep)
215
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.