class FDRCompiler : boost::noncopyable {
private:
const FDREngineDescription ŋ
+ const Grey &grey;
vector<u8> tab;
vector<hwlmLiteral> lits;
map<BucketIndex, std::vector<LiteralIndex> > bucketToLits;
public:
FDRCompiler(vector<hwlmLiteral> lits_in, const FDREngineDescription &eng_in,
- bool make_small_in)
- : eng(eng_in), tab(eng_in.getTabSizeBytes()), lits(move(lits_in)),
- make_small(make_small_in) {}
+ bool make_small_in, const Grey &grey_in)
+ : eng(eng_in), grey(grey_in), tab(eng_in.getTabSizeBytes()),
+ lits(move(lits_in)), make_small(make_small_in) {}
aligned_unique_ptr<FDR> build();
};
aligned_unique_ptr<FDR> FDRCompiler::setupFDR() {
size_t tabSize = eng.getTabSizeBytes();
- auto floodControlTmp = setupFDRFloodControl(lits, eng);
+ auto floodControlTmp = setupFDRFloodControl(lits, eng, grey);
auto confirmTmp = setupFullConfs(lits, eng, bucketToLits, make_small);
assert(ISALIGNED_16(tabSize));
DEBUG_PRINTF("cpu has %s\n", target.has_avx2() ? "avx2" : "no-avx2");
if (grey.fdrAllowTeddy) {
- auto fdr = teddyBuildTableHinted(lits, make_small, hint, target);
+ auto fdr = teddyBuildTableHinted(lits, make_small, hint, target, grey);
if (fdr) {
DEBUG_PRINTF("build with teddy succeeded\n");
return fdr;
des->stride = 1;
}
- FDRCompiler fc(lits, *des, make_small);
+ FDRCompiler fc(lits, *des, make_small, grey);
return fc.build();
}
class EngineDescription;
class FDREngineDescription;
struct hwlmStreamingControl;
+struct Grey;
std::pair<aligned_unique_ptr<u8>, size_t> setupFullConfs(
const std::vector<hwlmLiteral> &lits, const EngineDescription &eng,
// right state yet to allow blindly advancing
std::pair<aligned_unique_ptr<u8>, size_t>
setupFDRFloodControl(const std::vector<hwlmLiteral> &lits,
- const EngineDescription &eng);
+ const EngineDescription &eng, const Grey &grey);
std::pair<aligned_unique_ptr<u8>, size_t>
fdrBuildTableStreaming(const std::vector<hwlmLiteral> &lits,
/*
- * Copyright (c) 2015-2016, Intel Corporation
+ * Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#include "fdr_confirm.h"
#include "fdr_compile_internal.h"
#include "fdr_engine_description.h"
+#include "grey.h"
#include "ue2common.h"
#include "util/alloc.h"
#include "util/bitutils.h"
pair<aligned_unique_ptr<u8>, size_t>
setupFDRFloodControl(const vector<hwlmLiteral> &lits,
- const EngineDescription &eng) {
+ const EngineDescription &eng, const Grey &grey) {
vector<FDRFlood> tmpFlood(N_CHARS);
u32 default_suffix = eng.getDefaultFloodSuffixLength();
}
#endif
+ // If flood detection has been switched off in the grey box, we comply by
+ // setting idCount too high for all floods.
+ if (!grey.fdrAllowFlood) {
+ for (auto &fl : tmpFlood) {
+ fl.idCount = FDR_FLOOD_MAX_IDS;
+ }
+ }
+
map<FDRFlood, CharReach, FloodComparator> flood2chars;
for (u32 i = 0; i < N_CHARS; i++) {
FDRFlood fl = tmpFlood[i];
#include "fdr_compile_internal.h"
#include "fdr_confirm.h"
#include "fdr_engine_description.h"
+#include "grey.h"
#include "ue2common.h"
#include "util/alloc.h"
#include "util/compare.h"
class TeddyCompiler : boost::noncopyable {
const TeddyEngineDescription ŋ
+ const Grey &grey;
const vector<hwlmLiteral> &lits;
bool make_small;
public:
TeddyCompiler(const vector<hwlmLiteral> &lits_in,
- const TeddyEngineDescription &eng_in, bool make_small_in)
- : eng(eng_in), lits(lits_in), make_small(make_small_in) {}
+ const TeddyEngineDescription &eng_in, bool make_small_in,
+ const Grey &grey_in)
+ : eng(eng_in), grey(grey_in), lits(lits_in), make_small(make_small_in) {
+ }
aligned_unique_ptr<FDR> build();
bool pack(map<BucketIndex, std::vector<LiteralIndex> > &bucketToLits);
size_t maskLen = eng.numMasks * 16 * 2 * maskWidth;
- auto floodControlTmp = setupFDRFloodControl(lits, eng);
+ auto floodControlTmp = setupFDRFloodControl(lits, eng, grey);
auto confirmTmp = setupFullConfs(lits, eng, bucketToLits, make_small);
size_t size = ROUNDUP_N(sizeof(Teddy) +
aligned_unique_ptr<FDR> teddyBuildTableHinted(const vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
- const target_t &target) {
+ const target_t &target,
+ const Grey &grey) {
unique_ptr<TeddyEngineDescription> des;
if (hint == HINT_INVALID) {
des = chooseTeddyEngine(target, lits);
if (!des) {
return nullptr;
}
- TeddyCompiler tc(lits, *des, make_small);
+ TeddyCompiler tc(lits, *des, make_small, grey);
return tc.build();
}
namespace ue2 {
+struct Grey;
struct hwlmLiteral;
ue2::aligned_unique_ptr<FDR>
teddyBuildTableHinted(const std::vector<hwlmLiteral> &lits, bool make_small,
- u32 hint, const target_t &target);
+ u32 hint, const target_t &target, const Grey &grey);
} // namespace ue2
allowDecoratedLiteral(true),
allowNoodle(true),
fdrAllowTeddy(true),
+ fdrAllowFlood(true),
violetAvoidSuffixes(true),
violetAvoidWeakInfixes(true),
violetDoubleCut(true),
G_UPDATE(allowDecoratedLiteral);
G_UPDATE(allowNoodle);
G_UPDATE(fdrAllowTeddy);
+ G_UPDATE(fdrAllowFlood);
G_UPDATE(violetAvoidSuffixes);
G_UPDATE(violetAvoidWeakInfixes);
G_UPDATE(violetDoubleCut);
bool allowNoodle;
bool fdrAllowTeddy;
+ bool fdrAllowFlood;
u32 violetAvoidSuffixes; /* 0=never, 1=sometimes, 2=always */
bool violetAvoidWeakInfixes;