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

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

lz4d cmake entry and test case

File size: 12.0 KB
RevLine 
[5179]1cmake_minimum_required (VERSION 2.8)
[3850]2
3project (icgrep)
4
[4096]5enable_testing()
[3850]6# The version number.
[4508]7set (icgrep_VERSION_MAJOR 1)
[5178]8set (icgrep_VERSION_MINOR 6)
[4096]9
[5373]10
11
[4583]12option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
[4919]13option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
[5240]14option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
[5178]15find_package(LLVM REQUIRED CONFIG)
[3850]16
[5240]17message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
[5373]18
[5202]19set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
[3850]20
[5373]21set (Parabix_REVISION "svn")
22include(VersionFromVCS)
23add_version_info_from_vcs(Parabix_REVISION)
24message(STATUS "Parabix_REVISION: ${Parabix_REVISION}")
25
26
[3850]27# Now set the header and library paths:
28include_directories( ${LLVM_INCLUDE_DIRS} )
29link_directories( ${LLVM_LIBRARY_DIRS} )
30add_definitions( ${LLVM_DEFINITIONS} )
31
[5151]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
[3850]44# Let's suppose we want to build a JIT compiler with support for
45# binary code (no interpreter):
[5151]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)
[3850]48
[4196]49# Check if boost has been installed on this system.
[4210]50set(Boost_USE_STATIC_LIBS ON)
51set(Boost_USE_MULTITHREADED OFF)
[5234]52set(Boost_USE_STATIC_RUNTIME OFF)
[4991]53find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
[5252]54message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
[4212]55
[4991]56include_directories("${Boost_INCLUDE_DIRS}")
57link_directories(${Boost_LIBRARY_DIR})
[4974]58
[5405]59SET(OBJECT_CACHE_SRC kernels/object_cache.cpp)
60
[5332]61SET(KERNEL_SRC kernels/kernel.cpp kernels/pipeline.cpp kernels/streamset.cpp kernels/interface.cpp)
[5405]62SET(KERNEL_SRC ${KERNEL_SRC} kernels/toolchain.cpp)
[5377]63SET(KERNEL_SRC ${KERNEL_SRC} kernels/s2p_kernel.cpp kernels/mmap_kernel.cpp kernels/deletion.cpp kernels/swizzle.cpp kernels/p2s_kernel.cpp kernels/stdin_kernel.cpp kernels/stdout_kernel.cpp)
[5267]64
[5298]65SET(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)
[5033]66
[5217]67SET(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)
[5227]68SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
[4766]69SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
[5371]70SET(PABLO_SRC ${PABLO_SRC} pablo/passes/ssapass.cpp)
[5202]71SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/passes/flattenif.cpp)
[4922]72IF(ENABLE_MULTIPLEXING)
[5160]73SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
[5156]74SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
[4583]75ENDIF()
76
[5405]77add_library(CodeGen ${KERNEL_SRC} ${OBJECT_CACHE_SRC} ${IDISA_SRC})
[4583]78add_library(PabloADT ${PABLO_SRC})
[4684]79add_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)
[5218]80add_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)
[5369]81add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
[4949]82add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
[4198]83
[5405]84# force the compiler to compile the object cache to ensure that the versioning information is up to date
85add_custom_target(RecompileObjectCache ALL touch ${CMAKE_CURRENT_SOURCE_DIR}/${OBJECT_CACHE_SRC})
86add_dependencies(CodeGen RecompileObjectCache)
87
[4684]88# add the executable
[5033]89target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
[4684]90target_link_libraries (CCADT PabloADT)
91target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
92target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
93target_link_libraries (RegExpCompiler RegExpADT)
94
[5404]95add_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)
[5402]96add_executable(u8u16 u8u16.cpp)
97add_executable(base64 base64.cpp kernels/radix64.cpp)
98add_executable(wc wc.cpp)
99add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
100add_executable(array-test array-test.cpp kernels/alignedprint.cpp)
[5423]101add_executable(lz4d lz4d.cpp lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4_index_decoder.cpp kernels/lz4_bytestream_decoder.cpp)
[5172]102
[5260]103## IWYU detects superfluous includes and when the include can be replaced with a forward declaration.
104## It can be obtained using "apt-get install iwyu" or from "github.com/include-what-you-use".
105
106#find_program(IWYU_PATH NAMES include-what-you-use iwyu)
107#if(IWYU_PATH)
108#cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
[5267]109#execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE)
110#get_filename_component(LIBGCC_PATH ${LIBGCC_FILE} DIRECTORY)
111#include_directories("${LIBGCC_PATH}/include")
[5260]112#set_property(TARGET CodeGen PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
113#set_property(TARGET PabloADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
114#set_property(TARGET RegExpADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
115#set_property(TARGET RegExpCompiler PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
116#set_property(TARGET CCADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
117#set_property(TARGET UCDlib PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
118#set_property(TARGET icgrep PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
119#set_property(TARGET u8u16 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
[5267]120#set_property(TARGET base64 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
[5260]121#set_property(TARGET wc PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
122#set_property(TARGET editd PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
123#set_property(TARGET array-test PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
124#endif()
125
[4919]126IF (PRINT_TIMING_INFORMATION)
127    find_package(PAPI REQUIRED)
128    include_directories(${PAPI_INCLUDE_DIRS})
129    target_link_libraries(icgrep ${PAPI_LIBRARIES})
130ENDIF()
[4583]131
[5217]132target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
133target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5232]134target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5217]135target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
136target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5227]137target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[5423]138target_link_libraries (lz4d PabloADT RegExpCompiler CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
[4919]139
[4922]140IF(ENABLE_MULTIPLEXING)
[5156]141    message(STATUS "Enabling Multiplexing")
142    find_package(Z3 REQUIRED)
143    include_directories(${Z3_INCLUDE_DIRS})
144    target_link_libraries(PabloADT ${Z3_LIBRARIES})
145    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
[4583]146ENDIF()
147
[4096]148include_directories("${PROJECT_SOURCE_DIR}")
149
[4152]150#Check compiler support for 0x / 11
151include(CheckCXXCompilerFlag)
152CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
153if(COMPILER_SUPPORTS_CXX11)
154  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
155else()
156  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
157  if(COMPILER_SUPPORTS_CXX0X)
158    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
159  else()
160    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
161    if(COMPILER_SUPPORTS_GNU11)
162      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
[5156]163    else()
164      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
[4152]165      if(COMPILER_SUPPORTS_GNU0X)
166        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
167      endif()
168    endif()
169  endif()
170endif()
[4096]171
[4200]172#Disable RunTime Type Information
[5037]173IF (MSVC) # using Visual Studio C++
[4436]174  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
[4200]175ELSE() # using Clang, GCC, Intel C++, etc
[4436]176  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
[4200]177ENDIF()
178
[5240]179#Disable Dual ABI support
180IF(DISABLE_DUAL_ABI)
181SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
182ENDIF()
183
[4227]184#Enable all warnings
[4356]185SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
[4200]186
[4480]187SET(CMAKE_REQUIRED_FLAGS)
[4152]188
[4118]189# detect LLVM version and add compiler flags.
[5196]190SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
191IF (${LLVM_VERSION_MAJOR} EQUAL 3)
192  IF (${LLVM_VERSION_MINOR} EQUAL 6)
193    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
194    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
195  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
196    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
197  ENDIF()
[4480]198ENDIF()
[4118]199
[5373]200SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
201
[5156]202IF (PRINT_TIMING_INFORMATION)
[4919]203    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
204ENDIF()
205
[4200]206SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
[5245]207SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
[4152]208
[4096]209add_test(
210  NAME greptest
211  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]212  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
[4096]213
[4137]214add_test(
[4456]215  NAME proptest
216  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[4785]217  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
[4456]218
219add_test(
[4137]220  NAME abc_test
221  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
[5151]222  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
[4137]223
[5208]224add_test(
225  NAME u8u16_test
226  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
227  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
228
[5226]229add_test(
[5423]230  NAME lz4d_test
231  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
232  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
233
234add_test(
[5226]235  NAME editd_test
236  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
237  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
238
[5288]239add_test(
240  NAME base64_test
241  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
242  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
243
[5211]244add_custom_target (u8u16_test
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
246  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
247
[5423]248add_custom_target (lz4d_test
249  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
250  COMMAND ./run_all ${CMAKE_BINARY_DIR}/lz4d)
251
[5223]252add_custom_target (editd_test
253  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
[5226]254  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
[5223]255
[5289]256add_custom_target (base64_test
257  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
258  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
259
[4137]260add_custom_target (abc_test
[4785]261  COMMAND python2 abc_testgen.py
[4137]262  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
263
[4096]264add_custom_target (check
[4130]265  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
[4137]266  DEPENDS icgrep abc_test)
[4128]267
268add_custom_target (perf_icgrep
[4785]269  COMMAND python2 perf.py icgrep
[4128]270  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
271  DEPENDS icgrep)
272
273add_custom_target (viewer
[4785]274  COMMAND python2 viewer.py
[4128]275  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
276
[4275]277add_custom_target (text_viewer
[4785]278  COMMAND python2 viewer.py -t
[4275]279  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.