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

Last change on this file since 5232 was 5232, checked in by xwa163, 2 years ago

Add based64 related kernels

File size: 10.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 6)
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
14find_package(LLVM REQUIRED CONFIG)
15
16message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
17message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
18set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
19
20# Now set the header and library paths:
21include_directories( ${LLVM_INCLUDE_DIRS} )
22link_directories( ${LLVM_LIBRARY_DIRS} )
23add_definitions( ${LLVM_DEFINITIONS} )
24
25option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
26set(CUDA_LIB "")
27if(ENABLE_CUDA_COMPILE)
28  find_package(CUDA)
29  if(CUDA_FOUND)
30    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
31    include_directories(${CUDA_INCLUDE})
32    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
33    SET(CUDA_LIB "cuda")
34  endif(CUDA_FOUND)
35endif()
36
37# Let's suppose we want to build a JIT compiler with support for
38# binary code (no interpreter):
39set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
40llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
41
42# Check if boost has been installed on this system.
43set(Boost_USE_STATIC_LIBS ON)
44set(Boost_USE_MULTITHREADED OFF)
45set(Boost_USE_STATIC_RUNTIME ON)
46find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
47
48include_directories("${Boost_INCLUDE_DIRS}")
49link_directories(${Boost_LIBRARY_DIR})
50SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
51
52SET(KERNEL_SRC kernels/kernel.cpp kernels/s2p_kernel.cpp kernels/streamset.cpp kernels/interface.cpp)
53SET(IDISA_SRC IDISA/types/streamtype.cpp 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)
54
55SET(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)
56SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
57SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
58SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/passes/flattenif.cpp)
59IF(ENABLE_MULTIPLEXING)
60SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
61SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
62ENDIF()
63
64
65add_library(CodeGen ${KERNEL_SRC} ${IDISA_SRC} object_cache.cpp)
66add_library(PabloADT ${PABLO_SRC})
67add_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)
68add_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)
69add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp)
70add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
71
72
73# add the executable
74target_link_libraries (PabloADT CodeGen ${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 kernels/pipeline.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp ${PRECOMPILED_FILES})
111add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
112add_executable(base64 base64.cpp kernels/radix64.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
113add_executable(wc wc.cpp toolchain.cpp kernels/pipeline.cpp)
114add_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)
115add_executable(array-test array-test.cpp toolchain.cpp kernels/pipeline.cpp)
116
117IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
118add_dependencies(icgrep run_generate_predefined_ucd_functions)
119ENDIF()
120
121IF (PRINT_TIMING_INFORMATION)
122    find_package(PAPI REQUIRED)
123    include_directories(${PAPI_INCLUDE_DIRS})
124    target_link_libraries(icgrep ${PAPI_LIBRARIES})
125ENDIF()
126
127target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
128target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
129target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
130target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
131target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
132target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
133
134IF(ENABLE_MULTIPLEXING)
135    message(STATUS "Enabling Multiplexing")
136    find_package(Z3 REQUIRED)
137    include_directories(${Z3_INCLUDE_DIRS})
138    target_link_libraries(PabloADT ${Z3_LIBRARIES})
139    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
140ENDIF()
141
142include_directories("${PROJECT_SOURCE_DIR}")
143
144#Check compiler support for 0x / 11
145include(CheckCXXCompilerFlag)
146CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
147if(COMPILER_SUPPORTS_CXX11)
148  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
149else()
150  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
151  if(COMPILER_SUPPORTS_CXX0X)
152    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
153  else()
154    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
155    if(COMPILER_SUPPORTS_GNU11)
156      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
157    else()
158      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
159      if(COMPILER_SUPPORTS_GNU0X)
160        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
161      endif()
162    endif()
163  endif()
164endif()
165
166#Disable RunTime Type Information
167IF (MSVC) # using Visual Studio C++
168  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
169ELSE() # using Clang, GCC, Intel C++, etc
170  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
171ENDIF()
172
173#Enable all warnings
174SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
175
176SET(CMAKE_REQUIRED_FLAGS)
177
178# detect LLVM version and add compiler flags.
179SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
180IF (${LLVM_VERSION_MAJOR} EQUAL 3)
181  IF (${LLVM_VERSION_MINOR} EQUAL 6)
182    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
183    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
184  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
185    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
186  ENDIF()
187ENDIF()
188
189IF (PRINT_TIMING_INFORMATION)
190    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
191ENDIF()
192
193SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
194SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g") #  -fsanitize=address -fno-omit-frame-pointer
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 ${CMAKE_BINARY_DIR}/icgrep)
210
211add_test(
212  NAME u8u16_test
213  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
214  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
215
216add_test(
217  NAME editd_test
218  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
219  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
220
221add_custom_target (u8u16_test
222  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
223  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
224
225add_custom_target (editd_test
226  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
227  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
228
229add_custom_target (abc_test
230  COMMAND python2 abc_testgen.py
231  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
232
233add_custom_target (check
234  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
235  DEPENDS icgrep abc_test)
236
237add_custom_target (perf_icgrep
238  COMMAND python2 perf.py icgrep
239  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
240  DEPENDS icgrep)
241
242add_custom_target (viewer
243  COMMAND python2 viewer.py
244  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
245
246add_custom_target (text_viewer
247  COMMAND python2 viewer.py -t
248  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.