Skip to content

Commit 64a995b

Browse files
committed
Merge branch 'github_develop' into github_master
2 parents c00683d + 433d2f3 commit 64a995b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+7230
-507
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
This is a list of notable changes to Hyperscan, in reverse chronological order.
44

5+
## [5.4.0] 2020-12-31
6+
- Improvement on literal matcher "Fat Teddy" performance, including
7+
support for Intel(R) AVX-512 Vector Byte Manipulation Instructions (Intel(R)
8+
AVX-512 VBMI).
9+
- Introduce a new 32-state shuffle-based DFA engine ("Sheng32"). This improves
10+
scanning performance by leveraging AVX-512 VBMI.
11+
- Introduce a new 64-state shuffle-based DFA engine ("Sheng64"). This improves
12+
scanning performance by leveraging AVX-512 VBMI.
13+
- Introduce a new shuffle-based hybrid DFA engine ("McSheng64"). This improves
14+
scanning performance by leveraging AVX-512 VBMI.
15+
- Improvement on exceptional state handling performance for LimEx NFA, including
16+
support for AVX-512 VBMI.
17+
- Improvement on lookaround performance with new models, including support for
18+
AVX-512.
19+
- Improvement on DFA state space efficiency.
20+
- Optimization on decision of NFA/DFA generation.
21+
- hsbench: add CSV dump support for hsbench.
22+
- Bugfix for cmake error on Icelake under release mode.
23+
- Bugfix in find_vertices_in_cycles() to avoid self-loop checking in SCC.
24+
- Bugfix for issue #270: fix return value handling in chimera.
25+
- Bugfix for issue #284: use correct free function in logical combination.
26+
- Add BUILD_EXAMPLES cmake option to enable example code compilation. (#260)
27+
- Some typo fixing. (#242, #259)
28+
529
## [5.3.0] 2020-05-15
630
- Improvement on literal matcher "Teddy" performance, including support for
731
Intel(R) AVX-512 Vector Byte Manipulation Instructions (Intel(R) AVX-512

CMakeLists.txt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8.11)
22
project (hyperscan C CXX)
33

44
set (HS_MAJOR_VERSION 5)
5-
set (HS_MINOR_VERSION 3)
5+
set (HS_MINOR_VERSION 4)
66
set (HS_PATCH_VERSION 0)
77
set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION})
88

@@ -133,6 +133,13 @@ CMAKE_DEPENDENT_OPTION(DISABLE_ASSERTS "Disable assert(); Asserts are enabled in
133133
option(BUILD_AVX512 "Experimental: support avx512 in the fat runtime"
134134
OFF)
135135

136+
option(BUILD_AVX512VBMI "Experimental: support avx512vbmi in the fat runtime"
137+
OFF)
138+
139+
if (BUILD_AVX512VBMI)
140+
set(BUILD_AVX512 ON)
141+
endif ()
142+
136143
option(WINDOWS_ICC "Use Intel C++ Compiler on Windows, default off, requires ICC to be set in project" OFF)
137144

138145
# TODO: per platform config files?
@@ -277,6 +284,7 @@ else()
277284
set(SKYLAKE_FLAG "-xCORE-AVX512")
278285
else ()
279286
set(SKYLAKE_FLAG "-march=skylake-avx512")
287+
set(ICELAKE_FLAG "-march=icelake-server")
280288
endif ()
281289
endif()
282290

@@ -1197,6 +1205,9 @@ else (FAT_RUNTIME)
11971205
if (NOT BUILD_AVX512)
11981206
set (DISPATCHER_DEFINE "-DDISABLE_AVX512_DISPATCH")
11991207
endif (NOT BUILD_AVX512)
1208+
if (NOT BUILD_AVX512VBMI)
1209+
set (DISPATCHER_DEFINE "${DISPATCHER_DEFINE} -DDISABLE_AVX512VBMI_DISPATCH")
1210+
endif (NOT BUILD_AVX512VBMI)
12001211
set_source_files_properties(src/dispatcher.c PROPERTIES
12011212
COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function ${DISPATCHER_DEFINE}")
12021213

@@ -1229,6 +1240,14 @@ else (FAT_RUNTIME)
12291240
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in"
12301241
)
12311242
endif (BUILD_AVX512)
1243+
if (BUILD_AVX512VBMI)
1244+
add_library(hs_exec_avx512vbmi OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
1245+
list(APPEND RUNTIME_LIBS $<TARGET_OBJECTS:hs_exec_avx512vbmi>)
1246+
set_target_properties(hs_exec_avx512vbmi PROPERTIES
1247+
COMPILE_FLAGS "${ICELAKE_FLAG}"
1248+
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512vbmi ${CMAKE_MODULE_PATH}/keep.syms.in"
1249+
)
1250+
endif (BUILD_AVX512VBMI)
12321251

12331252
add_library(hs_exec_common OBJECT
12341253
${hs_exec_common_SRCS}
@@ -1287,6 +1306,15 @@ else (FAT_RUNTIME)
12871306
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in"
12881307
)
12891308
endif (BUILD_AVX512)
1309+
if (BUILD_AVX512VBMI)
1310+
add_library(hs_exec_shared_avx512vbmi OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
1311+
list(APPEND RUNTIME_SHLIBS $<TARGET_OBJECTS:hs_exec_shared_avx512vbmi>)
1312+
set_target_properties(hs_exec_shared_avx512vbmi PROPERTIES
1313+
COMPILE_FLAGS "${ICELAKE_FLAG}"
1314+
POSITION_INDEPENDENT_CODE TRUE
1315+
RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512vbmi ${CMAKE_MODULE_PATH}/keep.syms.in"
1316+
)
1317+
endif (BUILD_AVX512VBMI)
12901318
add_library(hs_exec_common_shared OBJECT
12911319
${hs_exec_common_SRCS}
12921320
src/dispatcher.c
@@ -1380,7 +1408,7 @@ if (NOT BUILD_STATIC_LIBS)
13801408
add_library(hs ALIAS hs_shared)
13811409
endif ()
13821410

1383-
1384-
if(NOT WIN32)
1411+
option(BUILD_EXAMPLES "Build Hyperscan example code (default TRUE)" TRUE)
1412+
if(NOT WIN32 AND BUILD_EXAMPLES)
13851413
add_subdirectory(examples)
13861414
endif()

chimera/ch_common.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Intel Corporation
2+
* Copyright (c) 2018-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -345,6 +345,16 @@ ch_error_t HS_CDECL ch_set_scratch_allocator(ch_alloc_t alloc_func,
345345
*/
346346
#define CH_SCRATCH_IN_USE (-10)
347347

348+
/**
349+
* Unexpected internal error from Hyperscan.
350+
*
351+
* This error indicates that there was unexpected matching behaviors from
352+
* Hyperscan. This could be related to invalid usage of scratch space or
353+
* invalid memory operations by users.
354+
*
355+
*/
356+
#define CH_UNKNOWN_HS_ERROR (-13)
357+
348358
/**
349359
* Returned when pcre_exec (called for some expressions internally from @ref
350360
* ch_scan) failed due to a fatal error.

chimera/ch_runtime.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Intel Corporation
2+
* Copyright (c) 2018-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -419,6 +419,7 @@ int HS_CDECL multiCallback(unsigned int id, unsigned long long from,
419419
DEBUG_PRINTF("user callback told us to skip this pattern\n");
420420
pd->scanStart = hyctx->length;
421421
ret = HS_SUCCESS;
422+
hyctx->scratch->ret = ret;
422423
} else if (ret == CH_FAIL_INTERNAL) {
423424
return ret;
424425
}
@@ -590,11 +591,24 @@ ch_error_t ch_scan_i(const ch_database_t *hydb,
590591

591592
if (!(db->flags & CHIMERA_FLAG_NO_MULTIMATCH)) {
592593
ret = scanHyperscan(&hyctx, data, length);
593-
if (ret != HS_SUCCESS && scratch->ret != CH_SUCCESS) {
594-
DEBUG_PRINTF("Hyperscan returned error %d\n", scratch->ret);
594+
// Errors from pcre scan.
595+
if (scratch->ret == CH_CALLBACK_TERMINATE) {
596+
DEBUG_PRINTF("Pcre terminates scan\n");
597+
unmarkScratchInUse(scratch);
598+
return CH_SCAN_TERMINATED;
599+
} else if (scratch->ret != CH_SUCCESS) {
600+
DEBUG_PRINTF("Pcre internal error\n");
595601
unmarkScratchInUse(scratch);
596602
return scratch->ret;
597603
}
604+
// Errors from Hyperscan scan. Note Chimera could terminate
605+
// Hyperscan callback on purpose so this is not counted as an error.
606+
if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
607+
assert(scratch->ret == CH_SUCCESS);
608+
DEBUG_PRINTF("Hyperscan returned error %d\n", ret);
609+
unmarkScratchInUse(scratch);
610+
return ret;
611+
}
598612
}
599613

600614
DEBUG_PRINTF("Flush priority queue\n");

cmake/arch.cmake

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,21 @@ if (BUILD_AVX512)
1717
endif ()
1818
endif ()
1919

20+
if (BUILD_AVX512VBMI)
21+
CHECK_C_COMPILER_FLAG(${ICELAKE_FLAG} HAS_ARCH_ICELAKE)
22+
if (NOT HAS_ARCH_ICELAKE)
23+
message (FATAL_ERROR "AVX512VBMI not supported by compiler")
24+
endif ()
25+
endif ()
26+
2027
if (FAT_RUNTIME)
2128
# test the highest level microarch to make sure everything works
2229
if (BUILD_AVX512)
23-
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${SKYLAKE_FLAG}")
30+
if (BUILD_AVX512VBMI)
31+
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${ICELAKE_FLAG}")
32+
else ()
33+
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${SKYLAKE_FLAG}")
34+
endif (BUILD_AVX512VBMI)
2435
else ()
2536
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} -march=core-avx2")
2637
endif ()
@@ -80,13 +91,19 @@ if (FAT_RUNTIME)
8091
if (BUILD_AVX512 AND NOT HAVE_AVX512)
8192
message(FATAL_ERROR "AVX512 support requested but not supported")
8293
endif ()
94+
if (BUILD_AVX512VBMI AND NOT HAVE_AVX512VBMI)
95+
message(FATAL_ERROR "AVX512VBMI support requested but not supported")
96+
endif ()
8397
else (NOT FAT_RUNTIME)
8498
if (NOT HAVE_AVX2)
8599
message(STATUS "Building without AVX2 support")
86100
endif ()
87101
if (NOT HAVE_AVX512)
88102
message(STATUS "Building without AVX512 support")
89103
endif ()
104+
if (NOT HAVE_AVX512VBMI)
105+
message(STATUS "Building without AVX512VBMI support")
106+
endif ()
90107
if (NOT HAVE_SSSE3)
91108
message(FATAL_ERROR "A minimum of SSSE3 compiler support is required")
92109
endif ()

cmake/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
/* Define if building AVX-512 in the fat runtime. */
2525
#cmakedefine BUILD_AVX512
2626

27+
/* Define if building AVX512VBMI in the fat runtime. */
28+
#cmakedefine BUILD_AVX512VBMI
29+
2730
/* Define to 1 if `backtrace' works. */
2831
#cmakedefine HAVE_BACKTRACE
2932

doc/dev-reference/chimera.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ space is required for that context.
212212
In the absence of recursive scanning, only one such space is required per thread
213213
and can (and indeed should) be allocated before data scanning is to commence.
214214

215-
In a scenario where a set of expressions are compiled by a single "master"
215+
In a scenario where a set of expressions are compiled by a single "main"
216216
thread and data will be scanned by multiple "worker" threads, the convenience
217217
function :c:func:`ch_clone_scratch` allows multiple copies of an existing
218218
scratch space to be made for each thread (rather than forcing the caller to pass

doc/dev-reference/compilation.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ interpreted independently. No syntax association happens between any adjacent
6464
characters.
6565

6666
For example, given an expression written as :regexp:`/bc?/`. We could say it is
67-
a regluar expression, with the meaning that character ``b`` followed by nothing
67+
a regular expression, with the meaning that character ``b`` followed by nothing
6868
or by one character ``c``. On the other view, we could also say it is a pure
6969
literal expression, with the meaning that this is a character sequence of 3-byte
7070
length, containing characters ``b``, ``c`` and ``?``. In regular case, the
7171
question mark character ``?`` has a particular syntax role called 0-1 quantifier,
72-
which has an syntax association with the character ahead of it. Similar
73-
characters exist in regular grammer like ``[``, ``]``, ``(``, ``)``, ``{``,
72+
which has a syntax association with the character ahead of it. Similar
73+
characters exist in regular grammar like ``[``, ``]``, ``(``, ``)``, ``{``,
7474
``}``, ``-``, ``*``, ``+``, ``\``, ``|``, ``/``, ``:``, ``^``, ``.``, ``$``.
7575
While in pure literal case, all these meta characters lost extra meanings
7676
expect for that they are just common ASCII codes.
7777

7878
Hyperscan is initially designed to process common regular expressions. It is
79-
hence embedded with a complex parser to do comprehensive regular grammer
80-
interpretion. Particularly, the identification of above meta characters is the
81-
basic step for the interpretion of far more complex regular grammers.
79+
hence embedded with a complex parser to do comprehensive regular grammar
80+
interpretation. Particularly, the identification of above meta characters is the
81+
basic step for the interpretation of far more complex regular grammars.
8282

8383
However in real cases, patterns may not always be regular expressions. They
8484
could just be pure literals. Problem will come if the pure literals contain
@@ -165,7 +165,7 @@ The following regex constructs are supported by Hyperscan:
165165
:regexp:`{n,}` are supported with limitations.
166166

167167
* For arbitrary repeated sub-patterns: *n* and *m* should be either small
168-
or infinite, e.g. :regexp:`(a|b}{4}`, :regexp:`(ab?c?d){4,10}` or
168+
or infinite, e.g. :regexp:`(a|b){4}`, :regexp:`(ab?c?d){4,10}` or
169169
:regexp:`(ab(cd)*){6,}`.
170170

171171
* For single-character width sub-patterns such as :regexp:`[^\\a]` or

doc/dev-reference/getting_started.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,19 @@ the current platform is supported by Hyperscan.
263263
As of this release, the variants of the runtime that are built, and the CPU
264264
capability that is required, are the following:
265265

266-
+----------+-------------------------------+---------------------------+
267-
| Variant | CPU Feature Flag(s) Required | gcc arch flag |
268-
+==========+===============================+===========================+
269-
| Core 2 | ``SSSE3`` | ``-march=core2`` |
270-
+----------+-------------------------------+---------------------------+
271-
| Core i7 | ``SSE4_2`` and ``POPCNT`` | ``-march=corei7`` |
272-
+----------+-------------------------------+---------------------------+
273-
| AVX 2 | ``AVX2`` | ``-march=core-avx2`` |
274-
+----------+-------------------------------+---------------------------+
275-
| AVX 512 | ``AVX512BW`` (see note below) | ``-march=skylake-avx512`` |
276-
+----------+-------------------------------+---------------------------+
266+
+--------------+---------------------------------+---------------------------+
267+
| Variant | CPU Feature Flag(s) Required | gcc arch flag |
268+
+==============+=================================+===========================+
269+
| Core 2 | ``SSSE3`` | ``-march=core2`` |
270+
+--------------+---------------------------------+---------------------------+
271+
| Core i7 | ``SSE4_2`` and ``POPCNT`` | ``-march=corei7`` |
272+
+--------------+---------------------------------+---------------------------+
273+
| AVX 2 | ``AVX2`` | ``-march=core-avx2`` |
274+
+--------------+---------------------------------+---------------------------+
275+
| AVX 512 | ``AVX512BW`` (see note below) | ``-march=skylake-avx512`` |
276+
+--------------+---------------------------------+---------------------------+
277+
| AVX 512 VBMI | ``AVX512VBMI`` (see note below) | ``-march=icelake-server`` |
278+
+--------------+---------------------------------+---------------------------+
277279

278280
.. note::
279281

@@ -287,6 +289,16 @@ capability that is required, are the following:
287289

288290
cmake -DBUILD_AVX512=on <...>
289291

292+
Hyperscan v5.3 adds support for AVX512VBMI instructions - in particular the
293+
``AVX512VBMI`` instruction set that was introduced on Intel "Icelake" Xeon
294+
processors - however the AVX512VBMI runtime variant is **not** enabled by
295+
default in fat runtime builds as not all toolchains support AVX512VBMI
296+
instruction sets. To build an AVX512VBMI runtime, the CMake variable
297+
``BUILD_AVX512VBMI`` must be enabled manually during configuration. For
298+
example: ::
299+
300+
cmake -DBUILD_AVX512VBMI=on <...>
301+
290302
As the fat runtime requires compiler, libc, and binutils support, at this time
291303
it will only be enabled for Linux builds where the compiler supports the
292304
`indirect function "ifunc" function attribute

doc/dev-reference/runtime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ space is required for that context.
178178
In the absence of recursive scanning, only one such space is required per thread
179179
and can (and indeed should) be allocated before data scanning is to commence.
180180

181-
In a scenario where a set of expressions are compiled by a single "master"
181+
In a scenario where a set of expressions are compiled by a single "main"
182182
thread and data will be scanned by multiple "worker" threads, the convenience
183183
function :c:func:`hs_clone_scratch` allows multiple copies of an existing
184184
scratch space to be made for each thread (rather than forcing the caller to pass

0 commit comments

Comments
 (0)