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

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

Refactor IDISA, re, pablo toolchain components

File size: 8.6 KB
Line 
1cmake_minimum_required (VERSION 2.8)
2
3project (icgrep)
4
5enable_testing()
6# The version number.
7set (icgrep_VERSION_MAJOR 1)
8set (icgrep_VERSION_MINOR 0)
9
10option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
11option(ENABLE_PREGENERATED_UCD_FUNCTIONS "Enable compiling the pregenerated UCD functions")
12option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
13
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:
32set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${LLVM_ROOT}/share/llvm/cmake;${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33
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):
43llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES mcjit native IRReader) # ipo
44
45message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
46
47# Check if boost has been installed on this system.
48set(Boost_USE_STATIC_LIBS ON)
49set(Boost_USE_MULTITHREADED OFF)
50set(Boost_USE_STATIC_RUNTIME ON)
51
52find_package(Boost 1.46 COMPONENTS system iostreams filesystem REQUIRED)
53
54SET(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)
55SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp IDISA/idisa_builder.cpp IDISA/idisa_avx_builder.cpp IDISA/idisa_i64_builder.cpp IDISA/idisa_sse_builder.cpp IDISA/idisa_target.cpp kernels/s2p_kernel.cpp kernels/scanmatchgen.cpp kernels/kernel.cpp kernels/pipeline.cpp)
56SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
57SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp)
58IF(ENABLE_MULTIPLEXING)
59SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/distributivepass.cpp pablo/passes/flattenassociativedfg.cpp pablo/passes/factorizedfg.cpp)
60SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp pablo/optimizers/pablo_bddminimization.cpp)
61ENDIF()
62
63add_library(PabloADT ${PABLO_SRC})
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)
65add_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)
66add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp UCD/CaseFolding_txt.cpp)
67add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
68
69# add the executable
70target_link_libraries (PabloADT ${REQ_LLVM_LIBRARIES})
71target_link_libraries (CCADT PabloADT)
72target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
73target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
74target_link_libraries (RegExpCompiler RegExpADT)
75
76set(PRECOMPILED_FILES "")
77
78IF(NOT ENABLE_PREGENERATED_UCD_FUNCTIONS)
79set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_PREGENERATED_UCD_FUNCTIONS")
80ELSE()
81MESSAGE("Enabling predefined UCD functions...")
82# add the executable
83add_executable(generate_predefined_ucd_functions generate_predefined_ucd_functions.cpp)
84llvm_map_components_to_libnames(REQ_LLVM_TARGETS ${LLVM_TARGETS_TO_BUILD})
85target_link_libraries (generate_predefined_ucd_functions RegExpADT UCDlib PabloADT CCADT ${REQ_LLVM_TARGETS})
86
87set(PRECOMPILED_PROPERTIES_OBJ ${PROJECT_BINARY_DIR}/precompiled_properties.o)
88set(PRECOMPILED_FILES ${PRECOMPILED_PROPERTIES_OBJ} ${PROJECT_SOURCE_DIR}/UCD/precompiled_properties.cpp)
89
90if(ENABLE_MULTIPLEXING)
91set(MULTIPLEXING_FLAG -multiplexing -reassoc -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv) # -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv #-ldc=ldc.csv
92endif()
93
94add_custom_command(OUTPUT ${PRECOMPILED_FILES}
95  COMMAND generate_predefined_ucd_functions
96  ARGS -o ${PRECOMPILED_PROPERTIES_OBJ} -dir ${PROJECT_SOURCE_DIR}/UCD/ ${MULTIPLEXING_FLAG} -DefaultIfHierarchy
97  DEPENDS generate_predefined_ucd_functions
98  COMMENT "Building predefined UCD functions..."
99  VERBATIM)
100
101add_custom_target(run_generate_predefined_ucd_functions DEPENDS ${PRECOMPILED_FILES})
102
103add_dependencies(RegExpCompiler run_generate_predefined_ucd_functions)
104ENDIF()
105
106add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp object_cache.cpp ${PRECOMPILED_FILES})
107IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
108add_dependencies(icgrep run_generate_predefined_ucd_functions)
109ENDIF()
110IF(Boost_FOUND)
111    include_directories("${Boost_INCLUDE_DIRS}")
112    link_directories(${Boost_LIBRARY_DIR})
113    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
114    target_link_libraries(icgrep ${Boost_LIBRARIES})
115ENDIF()
116IF (PRINT_TIMING_INFORMATION)
117    find_package(PAPI REQUIRED)
118    include_directories(${PAPI_INCLUDE_DIRS})
119    target_link_libraries(icgrep ${PAPI_LIBRARIES})
120ENDIF()
121
122
123target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT ${REQ_LLVM_LIBRARIES})
124
125IF(ENABLE_MULTIPLEXING)
126message(STATUS "Enabling Multiplexing")
127SET(BUDDY_ROOT "${CMAKE_SOURCE_DIR}/../buddy-2.4/src")
128SET(BUDDY_SOURCES ${BUDDY_ROOT}/bddop.cpp ${BUDDY_ROOT}/cache.cpp ${BUDDY_ROOT}/imatrix.cpp ${BUDDY_ROOT}/kernel.cpp)
129SET(BUDDY_SOURCES ${BUDDY_SOURCES} ${BUDDY_ROOT}/prime.cpp ${BUDDY_ROOT}/pairs.cpp ${BUDDY_ROOT}/reorder.cpp ${BUDDY_ROOT}/tree.cpp)
130add_library(BUDDY ${BUDDY_SOURCES})
131include_directories(${BUDDY_ROOT})
132target_link_libraries (PabloADT BUDDY)
133SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
134ENDIF()
135
136include_directories("${PROJECT_SOURCE_DIR}")
137
138#Check compiler support for 0x / 11
139include(CheckCXXCompilerFlag)
140CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
141if(COMPILER_SUPPORTS_CXX11)
142  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
143else()
144  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
145  if(COMPILER_SUPPORTS_CXX0X)
146    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
147  else()
148    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
149    if(COMPILER_SUPPORTS_GNU11)
150      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
151    else() 
152      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)   
153      if(COMPILER_SUPPORTS_GNU0X)
154        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
155      endif()
156    endif()
157  endif()
158endif()
159
160#Disable RunTime Type Information
161IF (MSVC) # using Visual Studio C++
162  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
163ELSE() # using Clang, GCC, Intel C++, etc
164  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
165ENDIF()
166
167#Enable all warnings
168SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
169
170
171SET(CMAKE_REQUIRED_FLAGS)
172
173# detect LLVM version and add compiler flags.
174IF (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
175  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_5")
176ENDIF()
177
178IF (PRINT_TIMING_INFORMATION)   
179    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
180ENDIF()
181
182SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
183IF (${CMAKE_SYSTEM} MATCHES "Linux")
184    SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
185ENDIF()
186
187add_test(
188  NAME greptest
189  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
190  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
191
192add_test(
193  NAME proptest
194  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
195  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
196
197add_test(
198  NAME abc_test
199  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
200  COMMAND ./run_abc ../icgrep-build/icgrep)
201
202add_custom_target (abc_test
203  COMMAND python2 abc_testgen.py
204  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
205
206add_custom_target (check
207  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
208  DEPENDS icgrep abc_test)
209
210add_custom_target (perf_icgrep
211  COMMAND python2 perf.py icgrep
212  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
213  DEPENDS icgrep)
214
215add_custom_target (viewer
216  COMMAND python2 viewer.py
217  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
218
219add_custom_target (text_viewer
220  COMMAND python2 viewer.py -t
221  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.