mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
avx512 fat runtime support: experimental
This commit is contained in:
parent
91db20d8eb
commit
ec7869711f
@ -125,6 +125,9 @@ CMAKE_DEPENDENT_OPTION(DUMP_SUPPORT "Dump code support; normally on, except in r
|
|||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(DISABLE_ASSERTS "Disable assert(); Asserts are enabled in debug builds, disabled in release builds" OFF "NOT RELEASE_BUILD" ON)
|
CMAKE_DEPENDENT_OPTION(DISABLE_ASSERTS "Disable assert(); Asserts are enabled in debug builds, disabled in release builds" OFF "NOT RELEASE_BUILD" ON)
|
||||||
|
|
||||||
|
option(BUILD_AVX512 "Experimental: support avx512 in the fat runtime"
|
||||||
|
OFF)
|
||||||
|
|
||||||
option(WINDOWS_ICC "Use Intel C++ Compiler on Windows, default off, requires ICC to be set in project" OFF)
|
option(WINDOWS_ICC "Use Intel C++ Compiler on Windows, default off, requires ICC to be set in project" OFF)
|
||||||
|
|
||||||
# TODO: per platform config files?
|
# TODO: per platform config files?
|
||||||
@ -456,6 +459,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||||
|
set(SKYLAKE_FLAG "-xCORE-AVX512")
|
||||||
|
else()
|
||||||
|
set(SKYLAKE_FLAG "-march=skylake-avx512")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
set(RAGEL_C_FLAGS "-Wno-unused")
|
set(RAGEL_C_FLAGS "-Wno-unused")
|
||||||
@ -1079,6 +1087,7 @@ if (NOT FAT_RUNTIME)
|
|||||||
if (HAVE_AVX2)
|
if (HAVE_AVX2)
|
||||||
set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_STATIC_LIBS)
|
if (BUILD_STATIC_LIBS)
|
||||||
add_library(hs_exec OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec OBJECT ${hs_exec_SRCS})
|
||||||
|
|
||||||
@ -1096,27 +1105,41 @@ if (NOT FAT_RUNTIME)
|
|||||||
else (FAT_RUNTIME)
|
else (FAT_RUNTIME)
|
||||||
|
|
||||||
set(BUILD_WRAPPER "${PROJECT_SOURCE_DIR}/cmake/build_wrapper.sh")
|
set(BUILD_WRAPPER "${PROJECT_SOURCE_DIR}/cmake/build_wrapper.sh")
|
||||||
|
if (NOT BUILD_AVX512)
|
||||||
|
set (DISPATCHER_DEFINE "-DDISABLE_AVX512_DISPATCH")
|
||||||
|
endif (NOT BUILD_AVX512)
|
||||||
set_source_files_properties(src/dispatcher.c PROPERTIES
|
set_source_files_properties(src/dispatcher.c PROPERTIES
|
||||||
COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function")
|
COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function ${DISPATCHER_DEFINE}")
|
||||||
|
|
||||||
if (BUILD_STATIC_LIBS)
|
if (BUILD_STATIC_LIBS)
|
||||||
add_library(hs_exec_core2 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_core2 OBJECT ${hs_exec_SRCS})
|
||||||
|
list(APPEND RUNTIME_LIBS $<TARGET_OBJECTS:hs_exec_core2>)
|
||||||
set_target_properties(hs_exec_core2 PROPERTIES
|
set_target_properties(hs_exec_core2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core2"
|
COMPILE_FLAGS "-march=core2"
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(hs_exec_corei7 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_corei7 OBJECT ${hs_exec_SRCS})
|
||||||
|
list(APPEND RUNTIME_LIBS $<TARGET_OBJECTS:hs_exec_corei7>)
|
||||||
set_target_properties(hs_exec_corei7 PROPERTIES
|
set_target_properties(hs_exec_corei7 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=corei7"
|
COMPILE_FLAGS "-march=corei7"
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(hs_exec_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
add_library(hs_exec_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
|
list(APPEND RUNTIME_LIBS $<TARGET_OBJECTS:hs_exec_avx2>)
|
||||||
set_target_properties(hs_exec_avx2 PROPERTIES
|
set_target_properties(hs_exec_avx2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core-avx2"
|
COMPILE_FLAGS "-march=core-avx2"
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
|
if (BUILD_AVX512)
|
||||||
|
add_library(hs_exec_avx512 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
|
list(APPEND RUNTIME_LIBS $<TARGET_OBJECTS:hs_exec_avx512>)
|
||||||
|
set_target_properties(hs_exec_avx512 PROPERTIES
|
||||||
|
COMPILE_FLAGS "${SKYLAKE_FLAG}"
|
||||||
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
|
)
|
||||||
|
endif (BUILD_AVX512)
|
||||||
|
|
||||||
add_library(hs_exec_common OBJECT
|
add_library(hs_exec_common OBJECT
|
||||||
${hs_exec_common_SRCS}
|
${hs_exec_common_SRCS}
|
||||||
@ -1127,37 +1150,51 @@ else (FAT_RUNTIME)
|
|||||||
# create a lib without any src (I'm looking at you Xcode)
|
# create a lib without any src (I'm looking at you Xcode)
|
||||||
|
|
||||||
add_library(hs_runtime STATIC src/hs_version.c
|
add_library(hs_runtime STATIC src/hs_version.c
|
||||||
$<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
$<TARGET_OBJECTS:hs_exec_common>
|
||||||
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
${RUNTIME_LIBS})
|
||||||
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
||||||
|
|
||||||
# we want the static lib for testing
|
# we want the static lib for testing
|
||||||
add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c
|
add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c
|
||||||
${hs_SRCS} $<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
${hs_SRCS}
|
||||||
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
$<TARGET_OBJECTS:hs_exec_common>
|
||||||
|
${RUNTIME_LIBS})
|
||||||
|
|
||||||
endif (BUILD_STATIC_LIBS)
|
endif (BUILD_STATIC_LIBS)
|
||||||
|
|
||||||
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
||||||
# build shared libs
|
# build shared libs
|
||||||
add_library(hs_exec_shared_core2 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_shared_core2 OBJECT ${hs_exec_SRCS})
|
||||||
|
list(APPEND RUNTIME_SHLIBS $<TARGET_OBJECTS:hs_exec_core2>)
|
||||||
set_target_properties(hs_exec_shared_core2 PROPERTIES
|
set_target_properties(hs_exec_shared_core2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core2"
|
COMPILE_FLAGS "-march=core2"
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
add_library(hs_exec_shared_corei7 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_shared_corei7 OBJECT ${hs_exec_SRCS})
|
||||||
|
list(APPEND RUNTIME_SHLIBS $<TARGET_OBJECTS:hs_exec_corei7>)
|
||||||
set_target_properties(hs_exec_shared_corei7 PROPERTIES
|
set_target_properties(hs_exec_shared_corei7 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=corei7"
|
COMPILE_FLAGS "-march=corei7"
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
add_library(hs_exec_shared_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
add_library(hs_exec_shared_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
|
list(APPEND RUNTIME_SHLIBS $<TARGET_OBJECTS:hs_exec_avx2>)
|
||||||
set_target_properties(hs_exec_shared_avx2 PROPERTIES
|
set_target_properties(hs_exec_shared_avx2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core-avx2"
|
COMPILE_FLAGS "-march=core-avx2"
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (BUILD_AVX512)
|
||||||
|
add_library(hs_exec_shared_avx512 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
|
list(APPEND RUNTIME_SHLIBS $<TARGET_OBJECTS:hs_exec_avx512>)
|
||||||
|
set_target_properties(hs_exec_shared_avx512 PROPERTIES
|
||||||
|
COMPILE_FLAGS "${SKYLAKE_FLAG}"
|
||||||
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
|
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in"
|
||||||
|
)
|
||||||
|
endif (BUILD_AVX512)
|
||||||
add_library(hs_exec_common_shared OBJECT
|
add_library(hs_exec_common_shared OBJECT
|
||||||
${hs_exec_common_SRCS}
|
${hs_exec_common_SRCS}
|
||||||
src/dispatcher.c
|
src/dispatcher.c
|
||||||
@ -1176,15 +1213,13 @@ endif()
|
|||||||
|
|
||||||
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
||||||
if (NOT FAT_RUNTIME)
|
if (NOT FAT_RUNTIME)
|
||||||
add_library(hs_runtime_shared SHARED src/hs_version.c src/hs_valid_platform.c
|
add_library(hs_runtime_shared SHARED src/hs_version.c
|
||||||
$<TARGET_OBJECTS:hs_exec_shared>)
|
src/hs_valid_platform.c $<TARGET_OBJECTS:hs_exec_shared>)
|
||||||
else()
|
else()
|
||||||
add_library(hs_runtime_shared SHARED src/hs_version.c
|
add_library(hs_runtime_shared SHARED src/hs_version.c
|
||||||
src/hs_valid_platform.c
|
src/hs_valid_platform.c
|
||||||
$<TARGET_OBJECTS:hs_exec_common_shared>
|
$<TARGET_OBJECTS:hs_exec_common_shared>
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_core2>
|
${RUNTIME_SHLIBS})
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_corei7>
|
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_avx2>)
|
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(hs_runtime_shared PROPERTIES
|
set_target_properties(hs_runtime_shared PROPERTIES
|
||||||
VERSION ${LIB_VERSION}
|
VERSION ${LIB_VERSION}
|
||||||
@ -1213,9 +1248,7 @@ if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
|||||||
else()
|
else()
|
||||||
add_library(hs_shared SHARED src/hs_version.c src/hs_valid_platform.c
|
add_library(hs_shared SHARED src/hs_version.c src/hs_valid_platform.c
|
||||||
${hs_SRCS} $<TARGET_OBJECTS:hs_exec_common_shared>
|
${hs_SRCS} $<TARGET_OBJECTS:hs_exec_common_shared>
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_core2>
|
${RUNTIME_SHLIBS})
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_corei7>
|
|
||||||
$<TARGET_OBJECTS:hs_exec_shared_avx2>)
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
add_dependencies(hs_shared ragel_Parser)
|
add_dependencies(hs_shared ragel_Parser)
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
/* "Define if building for EM64T" */
|
/* "Define if building for EM64T" */
|
||||||
#cmakedefine ARCH_X86_64
|
#cmakedefine ARCH_X86_64
|
||||||
|
|
||||||
/* Define if AVX-512BW available */
|
|
||||||
#cmakedefine HAVE_AVX512
|
|
||||||
|
|
||||||
/* internal build, switch on dump support. */
|
/* internal build, switch on dump support. */
|
||||||
#cmakedefine DUMP_SUPPORT
|
#cmakedefine DUMP_SUPPORT
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Intel Corporation
|
* Copyright (c) 2016-2017, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -33,8 +33,14 @@
|
|||||||
#include "util/cpuid_flags.h"
|
#include "util/cpuid_flags.h"
|
||||||
#include "util/join.h"
|
#include "util/join.h"
|
||||||
|
|
||||||
|
#if defined(DISABLE_AVX512_DISPATCH)
|
||||||
|
#define avx512_ disabled_
|
||||||
|
#define check_avx512() (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CREATE_DISPATCH(RTYPE, NAME, ...) \
|
#define CREATE_DISPATCH(RTYPE, NAME, ...) \
|
||||||
/* create defns */ \
|
/* create defns */ \
|
||||||
|
RTYPE JOIN(avx512_, NAME)(__VA_ARGS__); \
|
||||||
RTYPE JOIN(avx2_, NAME)(__VA_ARGS__); \
|
RTYPE JOIN(avx2_, NAME)(__VA_ARGS__); \
|
||||||
RTYPE JOIN(corei7_, NAME)(__VA_ARGS__); \
|
RTYPE JOIN(corei7_, NAME)(__VA_ARGS__); \
|
||||||
RTYPE JOIN(core2_, NAME)(__VA_ARGS__); \
|
RTYPE JOIN(core2_, NAME)(__VA_ARGS__); \
|
||||||
@ -46,6 +52,9 @@
|
|||||||
\
|
\
|
||||||
/* resolver */ \
|
/* resolver */ \
|
||||||
static void(*JOIN(resolve_, NAME)(void)) { \
|
static void(*JOIN(resolve_, NAME)(void)) { \
|
||||||
|
if (check_avx512()) { \
|
||||||
|
return JOIN(avx512_, NAME); \
|
||||||
|
} \
|
||||||
if (check_avx2()) { \
|
if (check_avx2()) { \
|
||||||
return JOIN(avx2_, NAME); \
|
return JOIN(avx2_, NAME); \
|
||||||
} \
|
} \
|
||||||
|
@ -133,13 +133,12 @@ int check_avx2(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
int check_avx512(void) {
|
int check_avx512(void) {
|
||||||
/*
|
/*
|
||||||
* For our purposes, having avx512 really means "can we use AVX512BW?"
|
* For our purposes, having avx512 really means "can we use AVX512BW?"
|
||||||
*/
|
*/
|
||||||
#if defined(__INTEL_COMPILER)
|
#if defined(__INTEL_COMPILER)
|
||||||
return _may_i_use_cpu_feature(_FEATURE_AVX512BW);
|
return _may_i_use_cpu_feature(_FEATURE_AVX512BW | _FEATURE_AVX512VL);
|
||||||
#else
|
#else
|
||||||
unsigned int eax, ebx, ecx, edx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ u64a cpuid_flags(void);
|
|||||||
|
|
||||||
u32 cpuid_tune(void);
|
u32 cpuid_tune(void);
|
||||||
|
|
||||||
|
int check_avx512(void);
|
||||||
int check_avx2(void);
|
int check_avx2(void);
|
||||||
int check_ssse3(void);
|
int check_ssse3(void);
|
||||||
int check_sse42(void);
|
int check_sse42(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user