From 05b5265affa43532283703074be46cfbce3dd254 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Wed, 25 Jan 2017 11:49:53 +1100 Subject: [PATCH] fdr: remove dead code to do with link structures --- src/fdr/fdr_compile.cpp | 28 ++++++++-------------------- src/fdr/fdr_internal.h | 7 +------ src/fdr/teddy_compile.cpp | 29 ++++++++++------------------- src/fdr/teddy_compile.h | 6 ++---- 4 files changed, 21 insertions(+), 49 deletions(-) diff --git a/src/fdr/fdr_compile.cpp b/src/fdr/fdr_compile.cpp index cd3b57de..953b2dab 100644 --- a/src/fdr/fdr_compile.cpp +++ b/src/fdr/fdr_compile.cpp @@ -84,7 +84,7 @@ private: void dumpMasks(const u8 *defaultMask); #endif void setupTab(); - aligned_unique_ptr setupFDR(pair, size_t> &link); + aligned_unique_ptr 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 build(pair, size_t> &link); + aligned_unique_ptr build(); }; u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) { @@ -142,8 +142,7 @@ void FDRCompiler::createInitialState(FDR *fdr) { } } -aligned_unique_ptr -FDRCompiler::setupFDR(pair, size_t> &link) { +aligned_unique_ptr FDRCompiler::setupFDR() { size_t tabSize = eng.getTabSizeBytes(); auto floodControlTmp = setupFDRFloodControl(lits, eng); @@ -152,10 +151,9 @@ FDRCompiler::setupFDR(pair, 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, 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 -FDRCompiler::build(pair, size_t> &link) { +aligned_unique_ptr FDRCompiler::build() { assignStringsToBuckets(); setupTab(); - return setupFDR(link); + return setupFDR(); } } // namespace @@ -549,12 +539,10 @@ aligned_unique_ptr fdrBuildTableInternal(const vector &lits, bool make_small, const target_t &target, const Grey &grey, u32 hint) { - pair, 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 fdrBuildTableInternal(const vector &lits, } FDRCompiler fc(lits, *des, make_small); - return fc.build(link); + return fc.build(); } aligned_unique_ptr fdrBuildTable(const vector &lits, diff --git a/src/fdr/fdr_internal.h b/src/fdr/fdr_internal.h index 3bf82837..a425d78c 100644 --- a/src/fdr/fdr_internal.h +++ b/src/fdr/fdr_internal.h @@ -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 diff --git a/src/fdr/teddy_compile.cpp b/src/fdr/teddy_compile.cpp index ac3a0203..66466e6c 100644 --- a/src/fdr/teddy_compile.cpp +++ b/src/fdr/teddy_compile.cpp @@ -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 build(pair, size_t> &link); + aligned_unique_ptr build(); bool pack(map > &bucketToLits); }; @@ -274,8 +274,7 @@ bool TeddyCompiler::pack(map -TeddyCompiler::build(pair, size_t> &link) { +aligned_unique_ptr TeddyCompiler::build() { if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) { DEBUG_PRINTF("too many literals: %zu\n", lits.size()); return nullptr; @@ -312,10 +311,10 @@ TeddyCompiler::build(pair, size_t> &link) { 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 = aligned_zmalloc_unique(size); assert(fdr); // otherwise would have thrown std::bad_alloc @@ -334,13 +333,6 @@ TeddyCompiler::build(pair, 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, size_t> &link) { } // namespace -aligned_unique_ptr -teddyBuildTableHinted(const vector &lits, bool make_small, - u32 hint, const target_t &target, - pair, size_t> &link) { +aligned_unique_ptr teddyBuildTableHinted(const vector &lits, + bool make_small, u32 hint, + const target_t &target) { unique_ptr des; if (hint == HINT_INVALID) { des = chooseTeddyEngine(target, lits); @@ -437,7 +428,7 @@ teddyBuildTableHinted(const vector &lits, bool make_small, return nullptr; } TeddyCompiler tc(lits, *des, make_small); - return tc.build(link); + return tc.build(); } } // namespace ue2 diff --git a/src/fdr/teddy_compile.h b/src/fdr/teddy_compile.h index 276c1347..bdd15865 100644 --- a/src/fdr/teddy_compile.h +++ b/src/fdr/teddy_compile.h @@ -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 -#include // std::pair struct FDR; struct target_t; @@ -48,8 +47,7 @@ struct hwlmLiteral; ue2::aligned_unique_ptr teddyBuildTableHinted(const std::vector &lits, bool make_small, - u32 hint, const target_t &target, - std::pair, size_t> &link); + u32 hint, const target_t &target); } // namespace ue2