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:
: 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) {
}
}
-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);
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",
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;
}
#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
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;
}
FDRCompiler fc(lits, *des, make_small);
- return fc.build(link);
+ return fc.build();
}
aligned_unique_ptr<FDR> fdrBuildTable(const 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:
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
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);
};
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;
auto confirmTmp = setupFullConfs(lits, eng, bucketToLits, make_small);
size_t size = ROUNDUP_N(sizeof(Teddy) +
- maskLen +
- confirmTmp.second +
- floodControlTmp.second +
- link.second, 16 * maskWidth);
+ maskLen +
+ confirmTmp.second +
+ floodControlTmp.second,
+ 16 * maskWidth);
aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
assert(fdr); // otherwise would have thrown std::bad_alloc
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) {
} // 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);
return nullptr;
}
TeddyCompiler tc(lits, *des, make_small);
- return tc.build(link);
+ return tc.build();
}
} // namespace ue2
/*
- * 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 "util/alloc.h"
#include <vector>
-#include <utility> // std::pair
struct FDR;
struct target_t;
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