fdr: remove dead code to do with link structures

This commit is contained in:
Justin Viiret 2017-01-25 11:49:53 +11:00 committed by Matthew Barr
parent 2bb0295c50
commit 05b5265aff
4 changed files with 21 additions and 49 deletions

View File

@ -84,7 +84,7 @@ private:
void dumpMasks(const u8 *defaultMask);
#endif
void setupTab();
aligned_unique_ptr<FDR> setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link);
aligned_unique_ptr<FDR> setupFDR();
void createInitialState(FDR *fdr);
public:
@ -93,7 +93,7 @@ public:
: eng(eng_in), tab(eng_in.getTabSizeBytes()), lits(move(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();
};
u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) {
@ -142,8 +142,7 @@ void FDRCompiler::createInitialState(FDR *fdr) {
}
}
aligned_unique_ptr<FDR>
FDRCompiler::setupFDR(pair<aligned_unique_ptr<u8>, size_t> &link) {
aligned_unique_ptr<FDR> FDRCompiler::setupFDR() {
size_t tabSize = eng.getTabSizeBytes();
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(confirmTmp.second));
assert(ISALIGNED_16(floodControlTmp.second));
assert(ISALIGNED_16(link.second));
size_t headerSize = ROUNDUP_16(sizeof(FDR));
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 "
"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->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;
}
@ -535,11 +526,10 @@ void FDRCompiler::setupTab() {
#endif
}
aligned_unique_ptr<FDR>
FDRCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
aligned_unique_ptr<FDR> FDRCompiler::build() {
assignStringsToBuckets();
setupTab();
return setupFDR(link);
return setupFDR();
}
} // namespace
@ -549,12 +539,10 @@ aligned_unique_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &lits,
bool make_small,
const target_t &target,
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");
if (grey.fdrAllowTeddy) {
auto fdr = teddyBuildTableHinted(lits, make_small, hint, target, link);
auto fdr = teddyBuildTableHinted(lits, make_small, hint, target);
if (fdr) {
DEBUG_PRINTF("build with teddy succeeded\n");
return fdr;
@ -578,7 +566,7 @@ aligned_unique_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &lits,
}
FDRCompiler fc(lits, *des, make_small);
return fc.build(link);
return fc.build();
}
aligned_unique_ptr<FDR> fdrBuildTable(const vector<hwlmLiteral> &lits,

View File

@ -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
* modification, are permitted provided that the following conditions are met:
@ -71,11 +71,6 @@ struct FDR {
u32 maxStringLen;
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
* stage matcher */
u8 domain; /* number of bits used to index into main FDR table. This value

View File

@ -74,7 +74,7 @@ public:
const TeddyEngineDescription &eng_in, bool 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);
};
@ -274,8 +274,7 @@ bool TeddyCompiler::pack(map<BucketIndex,
return true;
}
aligned_unique_ptr<FDR>
TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
aligned_unique_ptr<FDR> TeddyCompiler::build() {
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
DEBUG_PRINTF("too many literals: %zu\n", lits.size());
return nullptr;
@ -314,8 +313,8 @@ TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
size_t size = ROUNDUP_N(sizeof(Teddy) +
maskLen +
confirmTmp.second +
floodControlTmp.second +
link.second, 16 * maskWidth);
floodControlTmp.second,
16 * maskWidth);
aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
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);
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);
for (const auto &b2l : bucketToLits) {
@ -423,10 +415,9 @@ TeddyCompiler::build(pair<aligned_unique_ptr<u8>, size_t> &link) {
} // namespace
aligned_unique_ptr<FDR>
teddyBuildTableHinted(const vector<hwlmLiteral> &lits, bool make_small,
u32 hint, const target_t &target,
pair<aligned_unique_ptr<u8>, size_t> &link) {
aligned_unique_ptr<FDR> teddyBuildTableHinted(const vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
const target_t &target) {
unique_ptr<TeddyEngineDescription> des;
if (hint == HINT_INVALID) {
des = chooseTeddyEngine(target, lits);
@ -437,7 +428,7 @@ teddyBuildTableHinted(const vector<hwlmLiteral> &lits, bool make_small,
return nullptr;
}
TeddyCompiler tc(lits, *des, make_small);
return tc.build(link);
return tc.build();
}
} // namespace ue2

View File

@ -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
* modification, are permitted provided that the following conditions are met:
@ -37,7 +37,6 @@
#include "util/alloc.h"
#include <vector>
#include <utility> // std::pair
struct FDR;
struct target_t;
@ -48,8 +47,7 @@ struct hwlmLiteral;
ue2::aligned_unique_ptr<FDR>
teddyBuildTableHinted(const std::vector<hwlmLiteral> &lits, bool make_small,
u32 hint, const target_t &target,
std::pair<aligned_unique_ptr<u8>, size_t> &link);
u32 hint, const target_t &target);
} // namespace ue2