Skip to content

Commit 5f6096d

Browse files
author
Matthew Barr
committed
Merge branch develop into master
2 parents a00bd31 + 2b788f1 commit 5f6096d

File tree

7 files changed

+82
-20
lines changed

7 files changed

+82
-20
lines changed

CHANGELOG.md

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

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

5+
## [4.5.1] 2017-06-16
6+
- Bugfix for issue #56: workaround for gcc-4.8 C++11 defect.
7+
- Bugfix for literal matching table generation, reversing a regression in
8+
performance for some literal matching cases.
9+
- Bugfixes for hsbench, related to multicore benchmarking, portability fixes
10+
for FreeBSD, and clarifying output results.
11+
- CMake: removed a duplicate else branch that causes very recent (v3.9) builds
12+
of CMake to fail.
13+
514
## [4.5.0] 2017-06-09
615
- New API feature: approximate matching using the "edit distance" extended
716
parameter. This allows the user to request all matches that are a given edit

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project (hyperscan C CXX)
33

44
set (HS_MAJOR_VERSION 4)
55
set (HS_MINOR_VERSION 5)
6-
set (HS_PATCH_VERSION 0)
6+
set (HS_PATCH_VERSION 1)
77
set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION})
88

99
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

cmake/arch.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ else (NOT FAT_RUNTIME)
7575
if (NOT HAVE_AVX512)
7676
message(STATUS "Building without AVX512 support")
7777
endif ()
78-
else (NOT FAT_RUNTIME)
7978
if (NOT HAVE_SSSE3)
8079
message(FATAL_ERROR "A minimum of SSSE3 compiler support is required")
8180
endif ()

src/fdr/fdr_confirm_compile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
163163
if (make_small) {
164164
nBits = min(10U, lg2(lits.size()) + 1);
165165
} else {
166-
nBits = lg2(lits.size() + 4);
166+
nBits = lg2(lits.size()) + 4;
167167
}
168168

169169
CONF_TYPE mult = (CONF_TYPE)0x0b4e0ef37bc32127ULL;

src/util/small_vector.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ using small_vector = boost::container::small_vector<T, N, Allocator>;
5555
template <class T, std::size_t N, typename Allocator = std::allocator<T>>
5656
using small_vector = std::vector<T, Allocator>;
5757

58+
// Support workarounds for flat_set/flat_map and GCC 4.8.
59+
#define SMALL_VECTOR_IS_STL_VECTOR 1
60+
5861
#endif // HAVE_BOOST_CONTAINER_SMALL_VECTOR
5962

6063
} // namespace ue2

src/util/ue2_containers.h

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,19 @@ class flat_set
162162
public totally_ordered<flat_set<T, Compare, Allocator>> {
163163
using base_type = flat_detail::flat_base<T, Compare, Allocator>;
164164
using storage_type = typename base_type::storage_type;
165+
using storage_iterator = typename storage_type::iterator;
166+
using storage_const_iterator = typename storage_type::const_iterator;
165167
using base_type::data;
166168
using base_type::comp;
167169

170+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
171+
// Construct a non-const iterator from a const iterator. Used in flat_map
172+
// and flat_set erase() calls to work around g++-4.8 compatibility issues.
173+
storage_iterator mutable_iterator(storage_const_iterator it) {
174+
return data().begin() + std::distance(data().cbegin(), it);
175+
}
176+
#endif
177+
168178
public:
169179
// Member types.
170180
using key_type = T;
@@ -282,11 +292,27 @@ class flat_set
282292
}
283293

284294
void erase(const_iterator pos) {
285-
data().erase(pos.get());
295+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
296+
// Cope with libstdc++ 4.8's incomplete STL (it's missing C++11
297+
// vector::erase(const_iterator)) by explicitly using a non-const
298+
// iterator.
299+
auto pos_it = mutable_iterator(pos.get());
300+
#else
301+
auto pos_it = pos.get();
302+
#endif
303+
data().erase(pos_it);
286304
}
287305

288306
void erase(const_iterator first, const_iterator last) {
289-
data().erase(first.get(), last.get());
307+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
308+
// As above, work around libstdc++ 4.8's incomplete C++11 support.
309+
auto first_it = mutable_iterator(first.get());
310+
auto last_it = mutable_iterator(last.get());
311+
#else
312+
auto first_it = first.get();
313+
auto last_it = last.get();
314+
#endif
315+
data().erase(first_it, last_it);
290316
}
291317

292318
void erase(const key_type &key) {
@@ -374,9 +400,19 @@ class flat_map
374400
flat_detail::flat_base<std::pair<Key, T>, Compare, Allocator>;
375401
using keyval_storage_type = std::pair<key_type, mapped_type>;
376402
using storage_type = typename base_type::storage_type;
403+
using storage_iterator = typename storage_type::iterator;
404+
using storage_const_iterator = typename storage_type::const_iterator;
377405
using base_type::data;
378406
using base_type::comp;
379407

408+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
409+
// Construct a non-const iterator from a const iterator. Used in flat_map
410+
// and flat_set erase() calls to work around g++-4.8 compatibility issues.
411+
storage_iterator mutable_iterator(storage_const_iterator it) {
412+
return data().begin() + std::distance(data().cbegin(), it);
413+
}
414+
#endif
415+
380416
public:
381417
// More Member types.
382418
using size_type = typename storage_type::size_type;
@@ -444,9 +480,6 @@ class flat_map
444480
const_reverse_iterator rend() const { return crend(); }
445481

446482
private:
447-
using storage_iterator = typename storage_type::iterator;
448-
using storage_const_iterator = typename storage_type::const_iterator;
449-
450483
storage_iterator data_lower_bound(const key_type &key) {
451484
return std::lower_bound(
452485
data().begin(), data().end(), key,
@@ -526,11 +559,27 @@ class flat_map
526559
}
527560

528561
void erase(const_iterator pos) {
529-
data().erase(pos.get());
562+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
563+
// Cope with libstdc++ 4.8's incomplete STL (it's missing C++11
564+
// vector::erase(const_iterator)) by explicitly using a non-const
565+
// iterator.
566+
auto pos_it = mutable_iterator(pos.get());
567+
#else
568+
auto pos_it = pos.get();
569+
#endif
570+
data().erase(pos_it);
530571
}
531572

532573
void erase(const_iterator first, const_iterator last) {
533-
data().erase(first.get(), last.get());
574+
#if defined(SMALL_VECTOR_IS_STL_VECTOR)
575+
// As above, work around libstdc++ 4.8's incomplete C++11 support.
576+
auto first_it = mutable_iterator(first.get());
577+
auto last_it = mutable_iterator(last.get());
578+
#else
579+
auto first_it = first.get();
580+
auto last_it = last.get();
581+
#endif
582+
data().erase(first_it, last_it);
534583
}
535584

536585
void erase(const key_type &key) {

tools/hsbench/main.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ class ThreadContext : boost::noncopyable {
125125
// Apply processor affinity (if available) to this thread.
126126
bool affine(UNUSED int cpu) {
127127
#ifdef HAVE_DECL_PTHREAD_SETAFFINITY_NP
128-
#if defined(__linux__)
129-
cpu_set_t cpuset;
130-
#else // BSD
128+
#if defined(__FreeBSD__)
131129
cpuset_t cpuset;
130+
#else
131+
cpu_set_t cpuset;
132132
#endif
133133
CPU_ZERO(&cpuset);
134134
assert(cpu >= 0 && cpu < CPU_SETSIZE);
@@ -205,7 +205,7 @@ static
205205
void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
206206
UNUSED unique_ptr<Grey> &grey) {
207207
const char options[] = "-b:c:Cd:e:E:G:hi:n:No:p:sVw:z:"
208-
#if HAVE_DECL_PTHREAD_SETAFFINITY_N
208+
#ifdef HAVE_DECL_PTHREAD_SETAFFINITY_NP
209209
"T:" // add the thread flag
210210
#endif
211211
;
@@ -287,13 +287,15 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
287287
case 'V':
288288
scan_mode = ScanMode::VECTORED;
289289
break;
290+
#ifdef HAVE_DECL_PTHREAD_SETAFFINITY_NP
290291
case 'T':
291292
if (!strToList(optarg, threadCores)) {
292293
usage("Couldn't parse argument to -T flag, should be"
293294
" a list of positive integers.");
294295
exit(1);
295296
}
296297
break;
298+
#endif
297299
case 'z': {
298300
unsigned int sinumber;
299301
if (!fromString(optarg, sinumber)) {
@@ -649,8 +651,8 @@ void displayResults(const vector<unique_ptr<ThreadContext>> &threads,
649651
}
650652
}
651653

652-
printf("Time spent scanning: %'0.3f seconds\n", totalSecs);
653-
printf("Corpus size: %'llu bytes ", bytesPerRun);
654+
printf("Time spent scanning: %'0.3f seconds\n", totalSecs);
655+
printf("Corpus size: %'llu bytes ", bytesPerRun);
654656
switch (scan_mode) {
655657
case ScanMode::STREAMING:
656658
printf("(%'zu blocks in %'llu streams)\n", corpus_blocks.size(),
@@ -669,16 +671,16 @@ void displayResults(const vector<unique_ptr<ThreadContext>> &threads,
669671
u64a totalBlocks = corpus_blocks.size() * repeats * threads.size();
670672

671673
double matchRate = ((double)matchesPerRun * 1024) / bytesPerRun;
672-
printf("Matches per iteration: %'llu (%'0.3f matches/kilobyte)\n",
674+
printf("Matches per iteration: %'llu (%'0.3f matches/kilobyte)\n",
673675
matchesPerRun, matchRate);
674676

675677
double blockRate = (double)totalBlocks / (double)totalSecs;
676-
printf("Overall block rate: %'0.2f blocks/sec\n", blockRate);
677-
printf("Mean throughput: %'0.2Lf Mbit/sec\n",
678+
printf("Overall block rate: %'0.2f blocks/sec\n", blockRate);
679+
printf("Mean throughput (overall): %'0.2Lf Mbit/sec\n",
678680
calc_mbps(totalSecs, totalBytes));
679681

680682
double lowestScanTime = fastestResult(threads);
681-
printf("Maximum throughput: %'0.2Lf Mbit/sec\n",
683+
printf("Max throughput (per core): %'0.2Lf Mbit/sec\n",
682684
calc_mbps(lowestScanTime, bytesPerRun));
683685
printf("\n");
684686

0 commit comments

Comments
 (0)