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

Last change on this file since 5706 was 5706, checked in by nmedfort, 17 months ago

First stage of MultiBlockKernel? and pipeline restructuring

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