mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-13 14:04:44 +03:00
fdr: remove dead code to do with link structures
This commit is contained in:
parent
2bb0295c50
commit
05b5265aff
@ -84,7 +84,7 @@ private:
|
|||||||
void dumpMasks(const u8 *defaultMask);
|
void dumpMasks(const u8 *defaultMask);
|
||||||
#endif
|
#endif
|
||||||
void setupTab();
|
void setupTab();
|
||||||
aligned_unique_ptr<FDR> setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link);
|
aligned_unique_ptr<FDR> setupFDR();
|
||||||
void createInitialState(FDR *fdr);
|
void createInitialState(FDR *fdr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
: eng(eng_in), tab(eng_in.getTabSizeBytes()), lits(move(lits_in)),
|
: eng(eng_in), tab(eng_in.getTabSizeBytes()), lits(move(lits_in)),
|
||||||
make_small(make_small_in) {}
|
make_small(make_small_in) {}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR> build(pair<aligned_unique_ptr<u8>, size_t> &link);
|
aligned_unique_ptr<FDR> build();
|
||||||
};
|
};
|
||||||
|
|
||||||
u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) {
|
u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) {
|
||||||
@ -142,8 +142,7 @@ void FDRCompiler::createInitialState(FDR *fdr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR>
|
aligned_unique_ptr<FDR> FDRCompiler::setupFDR() {
|
||||||
FDRCompiler::setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|
||||||
size_t tabSize = eng.getTabSizeBytes();
|
size_t tabSize = eng.getTabSizeBytes();
|
||||||
|
|
||||||
auto floodControlTmp = setupFDRFloodControl(lits, eng);
|
auto floodControlTmp = setupFDRFloodControl(lits, eng);
|
||||||
@ -152,10 +151,9 @@ FDRCompiler::setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|||||||
assert(ISALIGNED_16(tabSize));
|
assert(ISALIGNED_16(tabSize));
|
||||||
assert(ISALIGNED_16(confirmTmp.second));
|
assert(ISALIGNED_16(confirmTmp.second));
|
||||||
assert(ISALIGNED_16(floodControlTmp.second));
|
assert(ISALIGNED_16(floodControlTmp.second));
|
||||||
assert(ISALIGNED_16(link.second));
|
|
||||||
size_t headerSize = ROUNDUP_16(sizeof(FDR));
|
size_t headerSize = ROUNDUP_16(sizeof(FDR));
|
||||||
size_t size = ROUNDUP_16(headerSize + tabSize + confirmTmp.second +
|
size_t size = ROUNDUP_16(headerSize + tabSize + confirmTmp.second +
|
||||||
floodControlTmp.second + link.second);
|
floodControlTmp.second);
|
||||||
|
|
||||||
DEBUG_PRINTF("sizes base=%zu tabSize=%zu confirm=%zu floodControl=%zu "
|
DEBUG_PRINTF("sizes base=%zu tabSize=%zu confirm=%zu floodControl=%zu "
|
||||||
"total=%zu\n",
|
"total=%zu\n",
|
||||||
@ -189,13 +187,6 @@ FDRCompiler::setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|||||||
fdr->tabSize = (1 << eng.bits) * (eng.schemeWidth / 8);
|
fdr->tabSize = (1 << eng.bits) * (eng.schemeWidth / 8);
|
||||||
fdr->stride = eng.stride;
|
fdr->stride = eng.stride;
|
||||||
|
|
||||||
if (link.first) {
|
|
||||||
fdr->link = verify_u32(ptr - fdr_base);
|
|
||||||
memcpy(ptr, link.first.get(), link.second);
|
|
||||||
} else {
|
|
||||||
fdr->link = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fdr;
|
return fdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,11 +526,10 @@ void FDRCompiler::setupTab() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR>
|
aligned_unique_ptr<FDR> FDRCompiler::build() {
|
||||||
FDRCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|
||||||
assignStringsToBuckets();
|
assignStringsToBuckets();
|
||||||
setupTab();
|
setupTab();
|
||||||
return setupFDR(link);
|
return setupFDR();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -549,12 +539,10 @@ aligned_unique_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &lits,
|
|||||||
bool make_small,
|
bool make_small,
|
||||||
const target_t &target,
|
const target_t &target,
|
||||||
const Grey &grey, u32 hint) {
|
const Grey &grey, u32 hint) {
|
||||||
pair<aligned_unique_ptr<u8>, size_t> link(nullptr, 0);
|
|
||||||
|
|
||||||
DEBUG_PRINTF("cpu has %s\n", target.has_avx2() ? "avx2" : "no-avx2");
|
DEBUG_PRINTF("cpu has %s\n", target.has_avx2() ? "avx2" : "no-avx2");
|
||||||
|
|
||||||
if (grey.fdrAllowTeddy) {
|
if (grey.fdrAllowTeddy) {
|
||||||
auto fdr = teddyBuildTableHinted(lits, make_small, hint, target, link);
|
auto fdr = teddyBuildTableHinted(lits, make_small, hint, target);
|
||||||
if (fdr) {
|
if (fdr) {
|
||||||
DEBUG_PRINTF("build with teddy succeeded\n");
|
DEBUG_PRINTF("build with teddy succeeded\n");
|
||||||
return fdr;
|
return fdr;
|
||||||
@ -578,7 +566,7 @@ aligned_unique_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &lits,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FDRCompiler fc(lits, *des, make_small);
|
FDRCompiler fc(lits, *des, make_small);
|
||||||
return fc.build(link);
|
return fc.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR> fdrBuildTable(const vector<hwlmLiteral> &lits,
|
aligned_unique_ptr<FDR> fdrBuildTable(const vector<hwlmLiteral> &lits,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015-2016, Intel Corporation
|
* Copyright (c) 2015-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:
|
||||||
@ -71,11 +71,6 @@ struct FDR {
|
|||||||
u32 maxStringLen;
|
u32 maxStringLen;
|
||||||
u32 floodOffset;
|
u32 floodOffset;
|
||||||
|
|
||||||
/** link is the relative offset of a secondary included FDR table for
|
|
||||||
* stream handling if we're a primary FDR table or the subsidiary tertiary
|
|
||||||
* structures (spillover strings and hash table) if we're a secondary
|
|
||||||
* structure. */
|
|
||||||
u32 link;
|
|
||||||
u8 stride; /* stride - how frequeuntly the data is consulted by the first
|
u8 stride; /* stride - how frequeuntly the data is consulted by the first
|
||||||
* stage matcher */
|
* stage matcher */
|
||||||
u8 domain; /* number of bits used to index into main FDR table. This value
|
u8 domain; /* number of bits used to index into main FDR table. This value
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
const TeddyEngineDescription &eng_in, bool make_small_in)
|
const TeddyEngineDescription &eng_in, bool make_small_in)
|
||||||
: eng(eng_in), lits(lits_in), make_small(make_small_in) {}
|
: eng(eng_in), lits(lits_in), make_small(make_small_in) {}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR> build(pair<aligned_unique_ptr<u8>, size_t> &link);
|
aligned_unique_ptr<FDR> build();
|
||||||
bool pack(map<BucketIndex, std::vector<LiteralIndex> > &bucketToLits);
|
bool pack(map<BucketIndex, std::vector<LiteralIndex> > &bucketToLits);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -274,8 +274,7 @@ bool TeddyCompiler::pack(map<BucketIndex,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<FDR>
|
aligned_unique_ptr<FDR> TeddyCompiler::build() {
|
||||||
TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|
||||||
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
|
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
|
||||||
DEBUG_PRINTF("too many literals: %zu\n", lits.size());
|
DEBUG_PRINTF("too many literals: %zu\n", lits.size());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -314,8 +313,8 @@ TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|||||||
size_t size = ROUNDUP_N(sizeof(Teddy) +
|
size_t size = ROUNDUP_N(sizeof(Teddy) +
|
||||||
maskLen +
|
maskLen +
|
||||||
confirmTmp.second +
|
confirmTmp.second +
|
||||||
floodControlTmp.second +
|
floodControlTmp.second,
|
||||||
link.second, 16 * maskWidth);
|
16 * maskWidth);
|
||||||
|
|
||||||
aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
|
aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
|
||||||
assert(fdr); // otherwise would have thrown std::bad_alloc
|
assert(fdr); // otherwise would have thrown std::bad_alloc
|
||||||
@ -334,13 +333,6 @@ TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|||||||
memcpy(ptr, floodControlTmp.first.get(), floodControlTmp.second);
|
memcpy(ptr, floodControlTmp.first.get(), floodControlTmp.second);
|
||||||
ptr += floodControlTmp.second;
|
ptr += floodControlTmp.second;
|
||||||
|
|
||||||
if (link.first) {
|
|
||||||
teddy->link = verify_u32(ptr - teddy_base);
|
|
||||||
memcpy(ptr, link.first.get(), link.second);
|
|
||||||
} else {
|
|
||||||
teddy->link = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 *baseMsk = teddy_base + sizeof(Teddy);
|
u8 *baseMsk = teddy_base + sizeof(Teddy);
|
||||||
|
|
||||||
for (const auto &b2l : bucketToLits) {
|
for (const auto &b2l : bucketToLits) {
|
||||||
@ -423,10 +415,9 @@ TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
aligned_unique_ptr<FDR>
|
aligned_unique_ptr<FDR> teddyBuildTableHinted(const vector<hwlmLiteral> &lits,
|
||||||
teddyBuildTableHinted(const vector<hwlmLiteral> &lits, bool make_small,
|
bool make_small, u32 hint,
|
||||||
u32 hint, const target_t &target,
|
const target_t &target) {
|
||||||
pair<aligned_unique_ptr<u8>, size_t> &link) {
|
|
||||||
unique_ptr<TeddyEngineDescription> des;
|
unique_ptr<TeddyEngineDescription> des;
|
||||||
if (hint == HINT_INVALID) {
|
if (hint == HINT_INVALID) {
|
||||||
des = chooseTeddyEngine(target, lits);
|
des = chooseTeddyEngine(target, lits);
|
||||||
@ -437,7 +428,7 @@ teddyBuildTableHinted(const vector<hwlmLiteral> &lits, bool make_small,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
TeddyCompiler tc(lits, *des, make_small);
|
TeddyCompiler tc(lits, *des, make_small);
|
||||||
return tc.build(link);
|
return tc.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015-2016, Intel Corporation
|
* Copyright (c) 2015-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:
|
||||||
@ -37,7 +37,6 @@
|
|||||||
#include "util/alloc.h"
|
#include "util/alloc.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility> // std::pair
|
|
||||||
|
|
||||||
struct FDR;
|
struct FDR;
|
||||||
struct target_t;
|
struct target_t;
|
||||||
@ -48,8 +47,7 @@ struct hwlmLiteral;
|
|||||||
|
|
||||||
ue2::aligned_unique_ptr<FDR>
|
ue2::aligned_unique_ptr<FDR>
|
||||||
teddyBuildTableHinted(const std::vector<hwlmLiteral> &lits, bool make_small,
|
teddyBuildTableHinted(const std::vector<hwlmLiteral> &lits, bool make_small,
|
||||||
u32 hint, const target_t &target,
|
u32 hint, const target_t &target);
|
||||||
std::pair<aligned_unique_ptr<u8>, size_t> &link);
|
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user