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

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

Restructuring work for the Driver classes. Start of work to eliminate the memory leaks with the ExecutionEngine?. Replaced custom AlignedMalloc? with backend call to std::aligned_malloc. Salvaged some work on DistributionPass? for reevaluation.

File size: 12.3 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
10
11
12option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
13option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
14option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
15find_package(LLVM REQUIRED CONFIG)
16
17message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
18
19set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
20
21set (Parabix_REVISION "svn")
22include(VersionFromVCS)
23add_version_info_from_vcs(Parabix_REVISION)
24message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
25
26
27# Now set the header and library paths:
28include_directories( ${LLVM_INCLUDE_DIRS} )
29link_directories( ${LLVM_LIBRARY_DIRS} )
30add_definitions( ${LLVM_DEFINITIONS} )
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 toolchain/driver.cpp)
62
63SET(DRIVER_SRC 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 IR_Gen/idisa_target.cpp)
69
70SET(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)
71SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
72SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
73SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
74SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/passes/flattenif.cpp)
75IF(ENABLE_MULTIPLEXING)
76SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
77SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
78ENDIF()
79
80add_library(CodeGen ${TOOLCHAIN_SRC} ${DRIVER_SRC} ${OBJECT_CACHE_SRC} ${KERNEL_SRC} ${IDISA_SRC})
81add_library(PabloADT ${PABLO_SRC})
82add_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)
83add_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)
84add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
85add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
86
87# force the compiler to compile the object cache to ensure that the versioning information is up to date
88add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
89add_dependencies(CodeGen RecompileObjectCache)
90
91# add the executable
92target_link_libraries (CodeGen ${REQ_LLVM_LIBRARIES})
93target_link_libraries (PabloADT CodeGen)
94target_link_libraries (CCADT PabloADT)
95target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
96target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
97target_link_libraries (RegExpCompiler RegExpADT)
98
99add_executable(icgrep icgrep.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/match_count.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
100add_executable(u8u16 u8u16.cpp)
101add_executable(base64 base64.cpp kernels/radix64.cpp)
102add_executable(wc wc.cpp)
103add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
104add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
105add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
106
107## IWYU detects superfluous includes and when the include can be replaced with a forward declaration.
108## It can be obtained using "apt-get install iwyu" or from "github.com/include-what-you-use".
109
110#find_program(IWYU_PATH NAMES include-what-you-use iwyu)
111#if(IWYU_PATH)
112#cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
113#execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE)
114#get_filename_component(LIBGCC_PATH ${LIBGCC_FILE} DIRECTORY)
115#include_directories("${LIBGCC_PATH}/include")
116#set_property(TARGET CodeGen PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
117#set_property(TARGET PabloADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
118#set_property(TARGET RegExpADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
119#set_property(TARGET RegExpCompiler PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
120#set_property(TARGET CCADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
121#set_property(TARGET UCDlib PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
122#set_property(TARGET icgrep PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
123#set_property(TARGET u8u16 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
124#set_property(TARGET base64 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
125#set_property(TARGET wc PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
126#set_property(TARGET editd PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
127#set_property(TARGET array-test PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
128#endif()
129
130IF (PRINT_TIMING_INFORMATION)
131    find_package(PAPI REQUIRED)
132    include_directories(${PAPI_INCLUDE_DIRS})
133    target_link_libraries(icgrep ${PAPI_LIBRARIES})
134ENDIF()
135
136target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
137target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
138target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
139target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
140target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
141target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
142target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
143
144IF(ENABLE_MULTIPLEXING)
145    message(STATUS "Enabling Multiplexing")
146    find_package(Z3 REQUIRED)
147    include_directories(${Z3_INCLUDE_DIRS})
148    target_link_libraries(PabloADT ${Z3_LIBRARIES})
149    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
150ENDIF()
151
152include_directories("${PROJECT_SOURCE_DIR}")
153
154#Check compiler support for 0x / 11
155include(CheckCXXCompilerFlag)
156CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
157if(COMPILER_SUPPORTS_CXX11)
158  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
159else()
160  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
161  if(COMPILER_SUPPORTS_CXX0X)
162    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
163  else()
164    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
165    if(COMPILER_SUPPORTS_GNU11)
166      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
167    else()
168      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
169      if(COMPILER_SUPPORTS_GNU0X)
170        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
171      endif()
172    endif()
173  endif()
174endif()
175
176#Disable RunTime Type Information
177IF (MSVC) # using Visual Studio C++
178  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
179ELSE() # using Clang, GCC, Intel C++, etc
180  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
181ENDIF()
182
183#Disable Dual ABI support
184IF(DISABLE_DUAL_ABI)
185SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
186ENDIF()
187
188#Enable all warnings
189SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
190
191SET(CMAKE_REQUIRED_FLAGS)
192
193# detect LLVM version and add compiler flags.
194SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
195IF (${LLVM_VERSION_MAJOR} EQUAL 3)
196  IF (${LLVM_VERSION_MINOR} EQUAL 6)
197    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
198    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
199  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
200    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
201  ENDIF()
202ENDIF()
203
204SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
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 -fno-omit-frame-pointer -fsanitize=address")
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_test(
229  NAME u8u16_test
230  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
231  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
232
233add_test(
234  NAME lz4d_test
235  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
236  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
237
238add_test(
239  NAME editd_test
240  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
241  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
242
243add_test(
244  NAME base64_test
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
246  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
247
248add_custom_target (u8u16_test
249  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
250  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
251
252add_custom_target (lz4d_test
253  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
254  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
255
256add_custom_target (editd_test
257  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
258  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
259
260add_custom_target (base64_test
261  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
262  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
263
264add_custom_target (abc_test
265  COMMAND python2 abc_testgen.py
266  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
267
268add_custom_target (check
269  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
270  DEPENDS icgrep abc_test)
271
272add_custom_target (perf_icgrep
273  COMMAND python2 perf.py icgrep
274  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
275  DEPENDS icgrep)
276
277add_custom_target (viewer
278  COMMAND python2 viewer.py
279  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
280
281add_custom_target (text_viewer
282  COMMAND python2 viewer.py -t
283  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.