Changeset 4480 for icGREP


Ignore:
Timestamp:
Feb 8, 2015, 1:22:56 PM (5 years ago)
Author:
nmedfort
Message:

modified CMakeLists.txt to allow for user specification of simd operations.

Location:
icGREP/icgrep-devel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/README-icgrep-0.98.txt

    r4397 r4480  
    4545system generator.
    4646(IC1)  open a terminal window and cd to the icgrep-build directory
    47 (IC2)  enter the following command to build the makefiles
     47(IC2.1)  enter the following command to build the makefiles
    4848cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang ../icgrep
     49(IC2.2)  to specify the type of supported SIMD operations rather than relying on auto detection
     50cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang -DSIMD_SUPPORT=XXX ../icgrep
     51     Where XXX can be SSE2, SSE3, SSE4_1, SSE4_2, AVX1 or AVX2.
    4952(IC3) Enter the command "make"
    5053
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4456 r4480  
    4343# Let's suppose we want to build a JIT compiler with support for
    4444# binary code (no interpreter):
    45 llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES mcjit native)
     45llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES mcjit native)
    4646
    4747message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
     
    169169}")
    170170
    171 set(AVX_1_CODE "
     171set(AVX1_CODE "
    172172#include <immintrin.h>
    173173int main()
     
    180180}")
    181181
    182 set(AVX_2_CODE "
     182set(AVX2_CODE "
    183183#include <immintrin.h>
    184184int main()
     
    197197  SET(ENABLE_SSE4_1 "/arch:SSE4")
    198198  SET(ENABLE_SSE4_2 "/arch:SSE4")
    199   SET(ENABLE_AVX_1 "/arch:AVX1")
    200   SET(ENABLE_AVX_2 "/arch:AVX2")
     199  SET(ENABLE_AVX1 "/arch:AVX1")
     200  SET(ENABLE_AVX2 "/arch:AVX2")
    201201ELSE() # using Clang, GCC, Intel C++, etc 
    202202  SET(ENABLE_SSE1 "-msse")
     
    206206  SET(ENABLE_SSE4_2 "-msse4.2")
    207207  IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    208     SET(ENABLE_AVX_1 "-mavx -fabi-version=6")
    209     SET(ENABLE_AVX_2 "-mavx2 -fabi-version=6") 
     208    SET(ENABLE_AVX1 "-mavx -fabi-version=6")
     209    SET(ENABLE_AVX2 "-mavx2 -fabi-version=6") 
    210210  ELSE()
    211     SET(ENABLE_AVX_1 "-mavx")
    212     SET(ENABLE_AVX_2 "-mavx2")
     211    SET(ENABLE_AVX1 "-mavx")
     212    SET(ENABLE_AVX2 "-mavx2")
    213213  ENDIF()
    214214ENDIF()
    215215
    216 set(CMAKE_REQUIRED_FLAGS)
    217 set(SIMD_SUPPORT_FOUND)
    218 set(SIMD_MAX_BLOCK_SIZE)
    219 
    220 MACRO(CHECK_SIMD_SUPPORT type maxBlockSize)
    221   IF(NOT SIMD_SUPPORT_FOUND) 
    222     set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
    223     set(CMAKE_REQUIRED_FLAGS ${ENABLE_${type}})
    224     check_cxx_source_runs("${${type}_CODE}" ${type})   
    225     IF(${type})
    226       SET(SIMD_SUPPORT_FOUND ${CMAKE_REQUIRED_FLAGS})
    227       SET(SIMD_MAX_BLOCK_SIZE ${maxBlockSize})
     216SET(CMAKE_REQUIRED_FLAGS)
     217
     218MACRO(CHECK_SIMD_SUPPORT SIMD_TYPE RESULT)
     219  IF(NOT RESULT) 
     220    SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
     221    SET(CMAKE_REQUIRED_FLAGS ${ENABLE_${SIMD_TYPE}})
     222    SET(SUCCESS "${SIMD_TYPE}")
     223    check_cxx_source_runs("${${SIMD_TYPE}_CODE}" ${SUCCESS})   
     224    IF(${SUCCESS})
     225      SET(${RESULT} "${SIMD_TYPE}")
    228226    ENDIF()
    229227    SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
     
    231229ENDMACRO()
    232230
    233 CHECK_SIMD_SUPPORT("AVX_2" 256)
    234 CHECK_SIMD_SUPPORT("AVX_1" 128)
    235 CHECK_SIMD_SUPPORT("SSE4_2" 128)
    236 CHECK_SIMD_SUPPORT("SSE4_1" 128)
    237 CHECK_SIMD_SUPPORT("SSE3" 128)
    238 CHECK_SIMD_SUPPORT("SSE2" 128)
    239 CHECK_SIMD_SUPPORT("SSE1" 128)
    240 
    241 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_SUPPORT_FOUND}")
     231IF(NOT SIMD_SUPPORT)
     232SET(RESULT)
     233CHECK_SIMD_SUPPORT("AVX2" RESULT)
     234CHECK_SIMD_SUPPORT("AVX1" RESULT)
     235CHECK_SIMD_SUPPORT("SSE4_2" RESULT)
     236CHECK_SIMD_SUPPORT("SSE4_1" RESULT)
     237CHECK_SIMD_SUPPORT("SSE3" RESULT)
     238CHECK_SIMD_SUPPORT("SSE2" RESULT)
     239CHECK_SIMD_SUPPORT("SSE1" RESULT)
     240SET(SIMD_SUPPORT ${RESULT} CACHE STRING "SSE2")
     241ENDIF()
     242
     243SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ENABLE_${SIMD_SUPPORT}}")
    242244
    243245# detect LLVM version and add compiler flags.
    244246if (${LLVM_PACKAGE_VERSION} MATCHES "3.4")
    245247  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_4")
    246 elseif (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
     248ELSEIF (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
    247249  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_5")
    248 endif(${LLVM_PACKAGE_VERSION} MATCHES "3.4")
     250ENDIF()
    249251
    250252IF (BLOCK_SIZE_256)
    251   IF(${SIMD_MAX_BLOCK_SIZE} GREATER 128)
    252253    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_S2P_AVX2 -DBLOCK_SIZE=256 -march=core-avx2 -m64")
    253   ELSE()
    254     MESSAGE(FATAL_ERROR "AVX2 or better is required for BLOCK_SIZE=256")
    255   ENDIF()
    256254ENDIF()
    257255
Note: See TracChangeset for help on using the changeset viewer.