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

Last change on this file since 4964 was 4962, checked in by hongpum, 3 years ago

Add basic object cache implementation

File size: 8.8 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(USE_BOOST_MMAP "Using mmap from Boost.Iostreams")
12option(ENABLE_PREGENERATED_UCD_FUNCTIONS "Enable compiling the pregenerated UCD functions")
13option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
14
15# configure a header file to pass some of the CMake settings
16# to the source code
17#configure_file (
18#  "${PROJECT_SOURCE_DIR}/icgrepconfig.h.in"
19#  "${PROJECT_BINARY_DIR}/icgrepconfig.h"
20#  )
21
22# LLVM set up
23#
24# A convenience variable:
25set(LLVM_ROOT "../libllvm" CACHE PATH "Root of LLVM install.")
26
27# A bit of a sanity check:
28if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
29message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
30endif()
31
32# We incorporate the CMake features provided by LLVM:
33set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${LLVM_ROOT}/share/llvm/cmake;${CMAKE_CURRENT_SOURCE_DIR}/cmake")
34
35include(LLVMConfig)
36
37# Now set the header and library paths:
38include_directories( ${LLVM_INCLUDE_DIRS} )
39link_directories( ${LLVM_LIBRARY_DIRS} )
40add_definitions( ${LLVM_DEFINITIONS} )
41
42# Let's suppose we want to build a JIT compiler with support for
43# binary code (no interpreter):
44llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES mcjit native IRReader) # ipo
45
46message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
47
48# Check if boost has been installed on this system.
49set(Boost_USE_STATIC_LIBS ON)
50set(Boost_USE_MULTITHREADED OFF)
51set(Boost_USE_STATIC_RUNTIME ON)
52SET(REQ_BOOST_COMPONENTS ${REQ_BOOST_COMPONENTS} system)
53if(USE_BOOST_MMAP)
54  SET(REQ_BOOST_COMPONENTS ${REQ_BOOST_COMPONENTS} iostreams filesystem)
55endif()
56find_package(Boost COMPONENTS ${REQ_BOOST_COMPONENTS} REQUIRED)
57
58SET(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)
59SET(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 kernels/s2p_kernel.cpp kernels/scanmatchgen.cpp kernels/kernel.cpp kernels/pipeline.cpp)
60SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
61SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp)
62IF(ENABLE_MULTIPLEXING)
63SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/distributivepass.cpp pablo/passes/flattenassociativedfg.cpp pablo/passes/factorizedfg.cpp)
64SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp pablo/optimizers/pablo_bddminimization.cpp)
65ENDIF()
66
67add_library(PabloADT ${PABLO_SRC})
68add_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)
69add_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)
70add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp UCD/CaseFolding_txt.cpp)
71add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
72
73# add the executable
74target_link_libraries (PabloADT ${REQ_LLVM_LIBRARIES})
75target_link_libraries (CCADT PabloADT)
76target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
77target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
78target_link_libraries (RegExpCompiler RegExpADT)
79
80set(PRECOMPILED_FILES "")
81
82IF(NOT ENABLE_PREGENERATED_UCD_FUNCTIONS)
83set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_PREGENERATED_UCD_FUNCTIONS")
84ELSE()
85MESSAGE("Enabling predefined UCD functions...")
86# add the executable
87add_executable(generate_predefined_ucd_functions generate_predefined_ucd_functions.cpp)
88llvm_map_components_to_libnames(REQ_LLVM_TARGETS ${LLVM_TARGETS_TO_BUILD})
89target_link_libraries (generate_predefined_ucd_functions RegExpADT UCDlib PabloADT CCADT ${REQ_LLVM_TARGETS})
90
91set(PRECOMPILED_PROPERTIES_OBJ ${PROJECT_BINARY_DIR}/precompiled_properties.o)
92set(PRECOMPILED_FILES ${PRECOMPILED_PROPERTIES_OBJ} ${PROJECT_SOURCE_DIR}/UCD/precompiled_properties.cpp)
93
94if(ENABLE_MULTIPLEXING)
95set(MULTIPLEXING_FLAG -multiplexing -reassoc -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv) # -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv #-ldc=ldc.csv
96endif()
97
98add_custom_command(OUTPUT ${PRECOMPILED_FILES}
99  COMMAND generate_predefined_ucd_functions
100  ARGS -o ${PRECOMPILED_PROPERTIES_OBJ} -dir ${PROJECT_SOURCE_DIR}/UCD/ ${MULTIPLEXING_FLAG} -DefaultIfHierarchy
101  DEPENDS generate_predefined_ucd_functions
102  COMMENT "Building predefined UCD functions..."
103  VERBATIM)
104
105add_custom_target(run_generate_predefined_ucd_functions DEPENDS ${PRECOMPILED_FILES})
106
107add_dependencies(RegExpCompiler run_generate_predefined_ucd_functions)
108ENDIF()
109
110add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp object_cache.cpp ${PRECOMPILED_FILES})
111IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
112add_dependencies(icgrep run_generate_predefined_ucd_functions)
113ENDIF()
114IF(Boost_FOUND)
115    include_directories("${Boost_INCLUDE_DIRS}")
116    link_directories(${Boost_LIBRARY_DIR})
117    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
118    target_link_libraries(icgrep ${Boost_LIBRARIES})
119ENDIF()
120IF (PRINT_TIMING_INFORMATION)
121    find_package(PAPI REQUIRED)
122    include_directories(${PAPI_INCLUDE_DIRS})
123    target_link_libraries(icgrep ${PAPI_LIBRARIES})
124ENDIF()
125
126
127target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT ${REQ_LLVM_LIBRARIES})
128
129IF(USE_BOOST_MMAP)
130  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_MMAP")
131ENDIF()
132
133
134IF(ENABLE_MULTIPLEXING)
135message(STATUS "Enabling Multiplexing")
136SET(BUDDY_ROOT "${CMAKE_SOURCE_DIR}/../buddy-2.4/src")
137SET(BUDDY_SOURCES ${BUDDY_ROOT}/bddop.cpp ${BUDDY_ROOT}/cache.cpp ${BUDDY_ROOT}/imatrix.cpp ${BUDDY_ROOT}/kernel.cpp)
138SET(BUDDY_SOURCES ${BUDDY_SOURCES} ${BUDDY_ROOT}/prime.cpp ${BUDDY_ROOT}/pairs.cpp ${BUDDY_ROOT}/reorder.cpp ${BUDDY_ROOT}/tree.cpp)
139add_library(BUDDY ${BUDDY_SOURCES})
140include_directories(${BUDDY_ROOT})
141target_link_libraries (PabloADT BUDDY)
142SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
143ENDIF()
144
145include_directories("${PROJECT_SOURCE_DIR}")
146
147#Check compiler support for 0x / 11
148include(CheckCXXCompilerFlag)
149CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
150if(COMPILER_SUPPORTS_CXX11)
151  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
152else()
153  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
154  if(COMPILER_SUPPORTS_CXX0X)
155    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
156  else()
157    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
158    if(COMPILER_SUPPORTS_GNU11)
159      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
160    else() 
161      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)   
162      if(COMPILER_SUPPORTS_GNU0X)
163        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
164      endif()
165    endif()
166  endif()
167endif()
168
169#Disable RunTime Type Information
170IF (MSVC) # using Visual Studio C++
171  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
172ELSE() # using Clang, GCC, Intel C++, etc
173  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
174ENDIF()
175
176#Enable all warnings
177SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
178
179
180SET(CMAKE_REQUIRED_FLAGS)
181
182# detect LLVM version and add compiler flags.
183IF (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
184  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_5")
185ENDIF()
186
187IF (PRINT_TIMING_INFORMATION)   
188    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
189ENDIF()
190
191SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
192IF (${CMAKE_SYSTEM} MATCHES "Linux")
193    SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
194ENDIF()
195
196add_test(
197  NAME greptest
198  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
199  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
200
201add_test(
202  NAME proptest
203  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
204  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
205
206add_test(
207  NAME abc_test
208  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
209  COMMAND ./run_abc ../icgrep-build/icgrep)
210
211add_custom_target (abc_test
212  COMMAND python2 abc_testgen.py
213  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
214
215add_custom_target (check
216  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
217  DEPENDS icgrep abc_test)
218
219add_custom_target (perf_icgrep
220  COMMAND python2 perf.py icgrep
221  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
222  DEPENDS icgrep)
223
224add_custom_target (viewer
225  COMMAND python2 viewer.py
226  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
227
228add_custom_target (text_viewer
229  COMMAND python2 viewer.py -t
230  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.