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

Last change on this file since 5510 was 5510, checked in by nmedfort, 22 months ago

Back up check-in. Should have no effect on current programs.

File size: 12.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(TOOLCHAIN_SRC toolchain/toolchain.cpp toolchain/pipeline.cpp)
62
63SET(DRIVER_SRC toolchain/driver.cpp toolchain/cpudriver.cpp toolchain/NVPTXDriver.cpp)
64
65SET(KERNEL_SRC kernels/kernel.cpp kernels/streamset.cpp kernels/interface.cpp kernels/kernel_builder.cpp)
66SET(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)
67
68SET(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)
69SET(IDISA_SRC ${IDISA_SRC} IR_Gen/idisa_target.cpp)
70
71SET(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)
72SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp)
73IF (CARRYPACK_MANAGER)
74SET(PABLO_SRC ${PABLO_SRC} pablo/carrypack_manager.cpp)
75ELSE()
76SET(PABLO_SRC ${PABLO_SRC} pablo/carry_manager.cpp)
77ENDIF()
78SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
79SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
80SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/optimizers/schedulingprepass.cpp)
81SET(PABLO_SRC ${PABLO_SRC} pablo/passes/flattenif.cpp)
82IF(ENABLE_MULTIPLEXING)
83SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_automultiplexing.cpp)
84ENDIF()
85
86add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
87add_library(PabloADT ${PABLO_SRC})
88add_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)
89add_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)
90add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
91add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
92
93# force the compiler to compile the object cache to ensure that the versioning information is up to date
94add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
95add_dependencies(CodeGen RecompileObjectCache)
96
97# add the executable
98target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
99target_link_libraries (PabloADT CodeGen)
100target_link_libraries (CCADT PabloADT)
101target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
102target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
103target_link_libraries (RegExpCompiler RegExpADT)
104
105add_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)
106add_executable(u8u16 u8u16.cpp)
107add_executable(base64 base64.cpp kernels/radix64.cpp)
108add_executable(wc wc.cpp)
109add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
110add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
111add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
112
113target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
114target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
115target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
116target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
117target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
118target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
119target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
120
121IF(ENABLE_MULTIPLEXING)
122    message(STATUS "Enabling Multiplexing")
123    find_package(Z3 REQUIRED)
124    include_directories(${Z3_INCLUDE_DIRS})
125    target_link_libraries(PabloADT ${Z3_LIBRARIES})
126    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
127ENDIF()
128
129include_directories("${PROJECT_SOURCE_DIR}")
130
131#Check compiler support for 0x / 11
132include(CheckCXXCompilerFlag)
133CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
134if(COMPILER_SUPPORTS_CXX11)
135  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
136else()
137  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
138  if(COMPILER_SUPPORTS_CXX0X)
139    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
140  else()
141    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
142    if(COMPILER_SUPPORTS_GNU11)
143      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
144    else()
145      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
146      if(COMPILER_SUPPORTS_GNU0X)
147        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
148      endif()
149    endif()
150  endif()
151endif()
152
153#Disable RunTime Type Information
154IF (MSVC) # using Visual Studio C++
155  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
156ELSE() # using Clang, GCC, Intel C++, etc
157  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
158ENDIF()
159
160#Disable Dual ABI support
161IF(DISABLE_DUAL_ABI)
162SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
163ENDIF()
164
165#Enable all warnings
166SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
167
168UNSET(HAS_EXECINFO CACHE)
169UNSET(HAS_MACH_VM_TYPES CACHE)
170include(CheckIncludeFileCXX)
171CHECK_INCLUDE_FILE_CXX(mach/vm_types.h HAS_MACH_VM_TYPES)
172IF (HAS_MACH_VM_TYPES)
173  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_MACH_VM_TYPES")
174ELSE()
175  UNSET(LIBUNWIND_FOUND CACHE)
176  find_package(Libunwind)
177  IF (LIBUNWIND_FOUND)
178    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_LIBUNWIND")
179    include_directories(${LIBUNWIND_INCLUDE_DIR})
180    target_link_libraries(CodeGen ${LIBUNWIND_LIBRARIES})
181  ELSE()
182    CHECK_INCLUDE_FILE_CXX(execinfo.h HAS_EXECINFO)
183    IF (HAS_EXECINFO)
184       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_EXECINFO")
185    ENDIF()
186  ENDIF()
187ENDIF()
188
189IF (CARRYPACK_MANAGER)
190SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_CARRYPACK_MANAGER")
191ENDIF()
192
193SET(CMAKE_REQUIRED_FLAGS)
194
195# detect LLVM version and add compiler flags.
196SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
197IF (${LLVM_VERSION_MAJOR} EQUAL 3)
198  IF (${LLVM_VERSION_MINOR} EQUAL 6)
199    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
200    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
201  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
202    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
203  ENDIF()
204ENDIF()
205
206SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
207
208SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
209
210SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
211
212UNSET(HAS_ADDRESS_SANITIZER)
213CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
214IF (HAS_ADDRESS_SANITIZER)
215SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
216ENDIF()
217
218
219add_test(
220  NAME greptest
221  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
222  COMMAND python greptest.py ${CMAKE_BINARY_DIR}/icgrep)
223
224add_test(
225  NAME proptest
226  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
227  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
228
229add_test(
230  NAME abc_test
231  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
232  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
233
234add_test(
235  NAME u8u16_test
236  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
237  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
238
239add_test(
240  NAME lz4d_test
241  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
242  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
243
244add_test(
245  NAME editd_test
246  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
247  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
248
249add_test(
250  NAME base64_test
251  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
252  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
253
254SET_PROPERTY(TEST greptest PROPERTY TIMEOUT 400)
255SET_PROPERTY(TEST proptest PROPERTY TIMEOUT 1500)
256SET_PROPERTY(TEST abc_test u8u16_test lz4d_test editd_test base64_test PROPERTY TIMEOUT 40)
257
258
259add_custom_target (greptest
260  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
261  COMMAND python greptest.py "${CMAKE_BINARY_DIR}/icgrep -ea")
262
263add_custom_target (proptest
264  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
265  COMMAND python greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml "${CMAKE_BINARY_DIR}/icgrep -ea")
266
267add_custom_target (u8u16_test
268  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
269  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -ea -segment-size=16 -enable-segment-pipeline-parallel")
270
271add_custom_target (lz4d_test
272  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
273  COMMAND ./run_all "${CMAKE_BINARY_DIR}/lz4d -ea")
274
275add_custom_target (editd_test
276  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
277  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
278
279add_custom_target (base64_test
280  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
281  COMMAND python base64test.py "${CMAKE_BINARY_DIR}/base64 -ea")
282
283add_custom_target (abc_gen
284  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
285  COMMAND python abc_testgen.py)
286 
287add_custom_target (abc_test
288  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
289  COMMAND ./run_abc "${CMAKE_BINARY_DIR}/icgrep -ea")
290
291add_custom_target (check
292  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
293  DEPENDS icgrep abc_gen)
294
295add_custom_target (perf_icgrep
296  COMMAND python2 perf.py icgrep
297  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
298  DEPENDS icgrep)
299
300add_custom_target (viewer
301  COMMAND python2 viewer.py
302  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
303
304add_custom_target (text_viewer
305  COMMAND python2 viewer.py -t
306  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
307
308add_custom_target (clear_cache
309  COMMAND rm ~/.cache/parabix/*)
310
311
Note: See TracBrowser for help on using the repository browser.