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

Last change on this file since 5172 was 5172, checked in by lindanl, 3 years ago

Add Edit Distance App

File size: 10.0 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 5)
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
41option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
42set(CUDA_LIB "")
43if(ENABLE_CUDA_COMPILE)
44  find_package(CUDA)
45  if(CUDA_FOUND)
46    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
47    include_directories(${CUDA_INCLUDE})
48    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
49    SET(CUDA_LIB "cuda")
50  endif(CUDA_FOUND)
51endif()
52
53# Let's suppose we want to build a JIT compiler with support for
54# binary code (no interpreter):
55set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
56llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
57
58message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in ${LLVM_ROOT_DIR}")
59
60# Check if boost has been installed on this system.
61set(Boost_USE_STATIC_LIBS ON)
62set(Boost_USE_MULTITHREADED OFF)
63set(Boost_USE_STATIC_RUNTIME ON)
64find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
65
66include_directories("${Boost_INCLUDE_DIRS}")
67link_directories(${Boost_LIBRARY_DIR})
68SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
69
70SET(IDISA_SRC 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)
71
72SET(PABLO_SRC pablo/pablo_type.cpp 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)
73SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp pablo/pablo_kernel.cpp)
74SET(PABLO_SRC ${PABLO_SRC} kernels/s2p_kernel.cpp kernels/kernel.cpp kernels/streamset.cpp kernels/interface.cpp)
75SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
76SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp)
77IF(ENABLE_MULTIPLEXING)
78SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
79SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
80ENDIF()
81
82add_library(PabloADT ${PABLO_SRC})
83add_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)
84add_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)
85add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp)
86add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
87
88add_library(CodeGen object_cache.cpp ${IDISA_SRC})
89
90# add the executable
91target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
92target_link_libraries (CCADT PabloADT)
93target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
94target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
95target_link_libraries (RegExpCompiler RegExpADT)
96
97set(PRECOMPILED_FILES "")
98
99IF(NOT ENABLE_PREGENERATED_UCD_FUNCTIONS)
100set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_PREGENERATED_UCD_FUNCTIONS")
101ELSE()
102MESSAGE("Enabling predefined UCD functions...")
103# add the executable
104add_executable(generate_predefined_ucd_functions generate_predefined_ucd_functions.cpp)
105llvm_map_components_to_libnames(REQ_LLVM_TARGETS ${LLVM_TARGETS_TO_BUILD})
106target_link_libraries (generate_predefined_ucd_functions RegExpADT UCDlib PabloADT CCADT ${REQ_LLVM_TARGETS})
107
108set(PRECOMPILED_PROPERTIES_OBJ ${PROJECT_BINARY_DIR}/precompiled_properties.o)
109set(PRECOMPILED_FILES ${PRECOMPILED_PROPERTIES_OBJ} ${PROJECT_SOURCE_DIR}/UCD/precompiled_properties.cpp)
110
111if(ENABLE_MULTIPLEXING)
112set(MULTIPLEXING_FLAG -multiplexing -reassoc -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv) # -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv #-ldc=ldc.csv
113endif()
114
115add_custom_command(OUTPUT ${PRECOMPILED_FILES}
116  COMMAND generate_predefined_ucd_functions
117  ARGS -o ${PRECOMPILED_PROPERTIES_OBJ} -dir ${PROJECT_SOURCE_DIR}/UCD/ ${MULTIPLEXING_FLAG} -DefaultIfHierarchy
118  DEPENDS generate_predefined_ucd_functions
119  COMMENT "Building predefined UCD functions..."
120  VERBATIM)
121
122add_custom_target(run_generate_predefined_ucd_functions DEPENDS ${PRECOMPILED_FILES})
123
124add_dependencies(RegExpCompiler run_generate_predefined_ucd_functions)
125ENDIF()
126
127add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp ${PRECOMPILED_FILES})
128add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp)
129#add_executable(symtbl symboltable.cpp toolchain.cpp kernels/symboltablepipeline.cpp kernels/stdout_kernel.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp ${PRECOMPILED_FILES})
130add_executable(wc wc.cpp toolchain.cpp kernels/pipeline.cpp)
131
132add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp toolchain.cpp kernels/pipeline.cpp editd/editdscan_kernel.cpp)
133
134IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
135add_dependencies(icgrep run_generate_predefined_ucd_functions)
136ENDIF()
137
138IF (PRINT_TIMING_INFORMATION)
139    find_package(PAPI REQUIRED)
140    include_directories(${PAPI_INCLUDE_DIRS})
141    target_link_libraries(icgrep ${PAPI_LIBRARIES})
142ENDIF()
143
144target_link_libraries(icgrep ${Boost_LIBRARIES})
145#target_link_libraries(symtbl ${Boost_LIBRARIES})
146target_link_libraries(u8u16 ${Boost_LIBRARIES})
147target_link_libraries(wc ${Boost_LIBRARIES})
148target_link_libraries(editd ${Boost_LIBRARIES})
149
150target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${CUDA_LIB})
151#target_link_libraries (symtbl UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${CUDA_LIB})
152target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${CUDA_LIB})
153target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${CUDA_LIB})
154target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${CUDA_LIB})
155
156IF(ENABLE_MULTIPLEXING)
157    message(STATUS "Enabling Multiplexing")
158    find_package(Z3 REQUIRED)
159    include_directories(${Z3_INCLUDE_DIRS})
160    target_link_libraries(PabloADT ${Z3_LIBRARIES})
161    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
162ENDIF()
163
164
165include_directories("${PROJECT_SOURCE_DIR}")
166
167#Check compiler support for 0x / 11
168include(CheckCXXCompilerFlag)
169CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
170if(COMPILER_SUPPORTS_CXX11)
171  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
172else()
173  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
174  if(COMPILER_SUPPORTS_CXX0X)
175    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
176  else()
177    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
178    if(COMPILER_SUPPORTS_GNU11)
179      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
180    else()
181      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
182      if(COMPILER_SUPPORTS_GNU0X)
183        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
184      endif()
185    endif()
186  endif()
187endif()
188
189#Disable RunTime Type Information
190IF (MSVC) # using Visual Studio C++
191  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
192ELSE() # using Clang, GCC, Intel C++, etc
193  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
194ENDIF()
195
196#Enable all warnings
197SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
198
199SET(CMAKE_REQUIRED_FLAGS)
200
201# detect LLVM version and add compiler flags.
202IF (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
203  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_5")
204ENDIF()
205
206IF (PRINT_TIMING_INFORMATION)
207    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
208ENDIF()
209
210SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
211SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g") # -fsanitize=address -fno-omit-frame-pointer
212
213add_test(
214  NAME greptest
215  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
216  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
217
218add_test(
219  NAME proptest
220  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
221  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
222
223add_test(
224  NAME abc_test
225  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
226  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
227
228add_custom_target (abc_test
229  COMMAND python2 abc_testgen.py
230  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
231
232add_custom_target (check
233  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
234  DEPENDS icgrep abc_test)
235
236add_custom_target (perf_icgrep
237  COMMAND python2 perf.py icgrep
238  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
239  DEPENDS icgrep)
240
241add_custom_target (viewer
242  COMMAND python2 viewer.py
243  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
244
245add_custom_target (text_viewer
246  COMMAND python2 viewer.py -t
247  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.