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

Last change on this file since 5493 was 5493, checked in by cameron, 2 years ago

Restore check-ins from the last several days

File size: 12.2 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(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
12find_package(LLVM REQUIRED CONFIG)
13
14message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
15
16set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
17
18set (Parabix_REVISION "svn")
19include(VersionFromVCS)
20add_version_info_from_vcs(Parabix_REVISION)
21message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
22
23
24# Now set the header and library paths:
25include_directories( ${LLVM_INCLUDE_DIRS} )
26link_directories( ${LLVM_LIBRARY_DIRS} )
27add_definitions( ${LLVM_DEFINITIONS} )
28
29# include(FindCUDA) # https://cmake.org/cmake/help/v3.0/module/FindCUDA.html
30
31option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
32set(CUDA_LIB "")
33if(ENABLE_CUDA_COMPILE)
34  find_package(CUDA)
35  if(CUDA_FOUND)
36    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
37    include_directories(${CUDA_INCLUDE})
38    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
39    SET(CUDA_LIB "cuda")
40  endif(CUDA_FOUND)
41endif()
42
43# Let's suppose we want to build a JIT compiler with support for
44# binary code (no interpreter):
45set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
46llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
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 OFF)
52find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
53message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
54
55include_directories("${Boost_INCLUDE_DIRS}")
56link_directories(${Boost_LIBRARY_DIR})
57
58SET(OBJECT_CACHE_SRC toolchain/object_cache.cpp)
59
60SET(TOOLCHAIN_SRC toolchain/toolchain.cpp toolchain/pipeline.cpp toolchain/driver.cpp)
61
62SET(DRIVER_SRC toolchain/cpudriver.cpp toolchain/NVPTXDriver.cpp)
63
64SET(KERNEL_SRC kernels/kernel.cpp kernels/streamset.cpp kernels/interface.cpp kernels/kernel_builder.cpp)
65SET(KERNEL_SRC ${KERNEL_SRC} kernels/source_kernel.cpp kernels/s2p_kernel.cpp kernels/deletion.cpp kernels/swizzle.cpp kernels/p2s_kernel.cpp kernels/stdout_kernel.cpp)
66
67SET(IDISA_SRC IR_Gen/CBuilder.cpp IR_Gen/idisa_builder.cpp IR_Gen/idisa_avx_builder.cpp IR_Gen/idisa_i64_builder.cpp IR_Gen/idisa_sse_builder.cpp IR_Gen/idisa_nvptx_builder.cpp IR_Gen/idisa_target.cpp)
68
69SET(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)
70SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
71SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
72SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
73SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/passes/flattenif.cpp)
74IF(ENABLE_MULTIPLEXING)
75SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
76SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
77ENDIF()
78
79add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
80add_library(PabloADT ${PABLO_SRC})
81add_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)
82add_library(RegExpCompiler re/re_parser.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_star_normal.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)
83add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
84add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
85
86# force the compiler to compile the object cache to ensure that the versioning information is up to date
87add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
88add_dependencies(CodeGen RecompileObjectCache)
89
90# add the executable
91target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
92target_link_libraries (PabloADT CodeGen)
93target_link_libraries (CCADT PabloADT)
94target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
95target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
96target_link_libraries (RegExpCompiler RegExpADT)
97
98add_executable(icgrep icgrep.cpp grep_interface.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
99add_executable(u8u16 u8u16.cpp)
100add_executable(base64 base64.cpp kernels/radix64.cpp)
101add_executable(wc wc.cpp)
102add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
103add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
104add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
105
106target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
107target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
108target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
109target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
110target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
111target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
112target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
113
114IF(ENABLE_MULTIPLEXING)
115    message(STATUS "Enabling Multiplexing")
116    find_package(Z3 REQUIRED)
117    include_directories(${Z3_INCLUDE_DIRS})
118    target_link_libraries(PabloADT ${Z3_LIBRARIES})
119    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
120ENDIF()
121
122include_directories("${PROJECT_SOURCE_DIR}")
123
124#Check compiler support for 0x / 11
125include(CheckCXXCompilerFlag)
126CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
127if(COMPILER_SUPPORTS_CXX11)
128  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
129else()
130  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
131  if(COMPILER_SUPPORTS_CXX0X)
132    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
133  else()
134    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
135    if(COMPILER_SUPPORTS_GNU11)
136      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
137    else()
138      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
139      if(COMPILER_SUPPORTS_GNU0X)
140        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
141      endif()
142    endif()
143  endif()
144endif()
145
146#Disable RunTime Type Information
147IF (MSVC) # using Visual Studio C++
148  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
149ELSE() # using Clang, GCC, Intel C++, etc
150  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
151ENDIF()
152
153#Disable Dual ABI support
154IF(DISABLE_DUAL_ABI)
155SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
156ENDIF()
157
158#Enable all warnings
159SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
160
161UNSET(HAS_EXECINFO CACHE)
162UNSET(HAS_MACH_VM_TYPES CACHE)
163include(CheckIncludeFileCXX)
164CHECK_INCLUDE_FILE_CXX(mach/vm_types.h HAS_MACH_VM_TYPES)
165IF (HAS_MACH_VM_TYPES)
166  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_MACH_VM_TYPES")
167ELSE()
168  UNSET(LIBUNWIND_FOUND CACHE)
169  find_package(Libunwind)
170  IF (LIBUNWIND_FOUND)
171    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_LIBUNWIND")
172    include_directories(${LIBUNWIND_INCLUDE_DIR})
173    target_link_libraries(CodeGen ${LIBUNWIND_LIBRARIES})
174  ELSE()
175    CHECK_INCLUDE_FILE_CXX(execinfo.h HAS_EXECINFO)
176    IF (HAS_EXECINFO)
177       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_EXECINFO")
178    ENDIF()
179  ENDIF()
180ENDIF()
181
182SET(CMAKE_REQUIRED_FLAGS)
183
184# detect LLVM version and add compiler flags.
185SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
186IF (${LLVM_VERSION_MAJOR} EQUAL 3)
187  IF (${LLVM_VERSION_MINOR} EQUAL 6)
188    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
189    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
190  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
191    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
192  ENDIF()
193ENDIF()
194
195SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
196
197SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
198
199SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
200
201UNSET(HAS_ADDRESS_SANITIZER)
202CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
203IF (HAS_ADDRESS_SANITIZER)
204SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
205ENDIF()
206
207add_test(
208  NAME greptest
209  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
210  COMMAND timeout 1000 python greptest.py ${CMAKE_BINARY_DIR}/icgrep)
211
212add_test(
213  NAME proptest
214  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
215  COMMAND timeout 2000 python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
216
217add_test(
218  NAME abc_test
219  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
220  COMMAND timeout 200 ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
221
222add_test(
223  NAME u8u16_test
224  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
225  COMMAND timeout 15 ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
226
227add_test(
228  NAME lz4d_test
229  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
230  COMMAND timeout 15 ./run_all ${CMAKE_BINARY_DIR}/lz4d)
231
232add_test(
233  NAME editd_test
234  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
235  COMMAND timeout 50 python run_all.py -e ${CMAKE_BINARY_DIR})
236
237add_test(
238  NAME base64_test
239  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
240  COMMAND timeout 15 python base64test.py ${CMAKE_BINARY_DIR}/base64)
241
242add_custom_target (greptest
243  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
244  COMMAND timeout 600 python greptest.py "${CMAKE_BINARY_DIR}/icgrep -ea")
245
246add_custom_target (proptest
247  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
248  COMMAND timeout 1000 python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml "${CMAKE_BINARY_DIR}/icgrep -ea")
249
250add_custom_target (u8u16_test
251  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
252  COMMAND timeout 15 ./run_all "${CMAKE_BINARY_DIR}/u8u16 -ea -segment-size=16 -enable-segment-pipeline-parallel")
253
254add_custom_target (lz4d_test
255  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
256  COMMAND timeout 15 ./run_all "${CMAKE_BINARY_DIR}/lz4d -ea")
257
258add_custom_target (editd_test
259  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
260  COMMAND timeout 50 python run_all.py -e ${CMAKE_BINARY_DIR})
261
262add_custom_target (base64_test
263  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
264  COMMAND timeout 20 python base64test.py "${CMAKE_BINARY_DIR}/base64 -ea")
265
266add_custom_target (abc_test
267  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
268  COMMAND timeout 200 ./run_abc "${CMAKE_BINARY_DIR}/icgrep -ea")
269
270add_custom_target (check
271  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
272  DEPENDS icgrep abc_test)
273
274add_custom_target (perf_icgrep
275  COMMAND python2 perf.py icgrep
276  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
277  DEPENDS icgrep)
278
279add_custom_target (viewer
280  COMMAND python2 viewer.py
281  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
282
283add_custom_target (text_viewer
284  COMMAND python2 viewer.py -t
285  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
286
287add_custom_target (clear_cache
288  COMMAND rm ~/.cache/parabix/*)
289
290
Note: See TracBrowser for help on using the repository browser.