Changeset 5705 for icGREP


Ignore:
Timestamp:
Oct 24, 2017, 1:10:49 PM (18 months ago)
Author:
cameron
Message:

Drop linebreak normalization; add1 attribute for grep kernel; pablo indexed advance initial check-in

Location:
icGREP/icgrep-devel/icgrep
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_interface.cpp

    r5698 r5705  
    193193bool LineBufferedFlag;
    194194static cl::opt<bool, true> LineBufferedOption("line-buffered", cl::location(LineBufferedFlag), cl::desc("Buffer lines to output."), cl::cat(Output_Options));
    195 
    196 bool NormalizeLineBreaksFlag;
    197 static cl::opt<bool, true> NormalizeLineBreaksOption("normalize-line-breaks", cl::location(NormalizeLineBreaksFlag), cl::desc("Normalize line breaks to LF."), cl::cat(Output_Options));
    198195
    199196int AfterContextFlag;
  • icGREP/icgrep-devel/icgrep/grep_interface.h

    r5698 r5705  
    8888extern std::string LabelFlag; // -label
    8989extern bool LineBufferedFlag; // -line-buffered
    90 extern bool NormalizeLineBreaksFlag; // -normalize-line-breaks
    9190extern int AfterContextFlag; // -A
    9291extern int BeforeContextFlag; // -B
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5646 r5705  
    185185               Binding{iBuilder->getStreamSetTy(4, 1), "required"}},
    186186
    187               {Binding{iBuilder->getStreamSetTy(1, 1), "matches"}}) {
     187              {Binding{iBuilder->getStreamSetTy(1, 1), "matches", Add1()}}) {
    188188
    189189}
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r5586 r5705  
    6868
    6969inline static bool isNonAdvanceCarryGeneratingStatement(const Statement * const stmt) {
    70     return isa<CarryProducingStatement>(stmt) && !isa<Advance>(stmt);
     70    return isa<CarryProducingStatement>(stmt) && !isa<Advance>(stmt) && !isa<IndexedAdvance>(stmt);
    7171}
    7272
     
    610610}
    611611
     612Value * CarryManager::indexedAdvanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const IndexedAdvance * const advance, Value * const value, Value * const index_strm) {
     613    llvm::report_fatal_error("IndexedAdvance not yet supported.");
     614}
     615
    612616/** ------------------------------------------------------------------------------------------------------------- *
    613617 * @brief longAdvanceCarryInCarryOut
     
    922926    Type * const carryPackType = (loopDepth == 0) ? carryTy : ArrayType::get(carryTy, 2);
    923927    std::vector<Type *> state;
    924 
    925928    for (const Statement * stmt : *scope) {
    926929        if (LLVM_UNLIKELY(isa<Advance>(stmt))) {
     
    939942            }
    940943            state.push_back(type);
     944        } else if (LLVM_UNLIKELY(isa<IndexedAdvance>(stmt))) {
     945            // The carry data for the indexed advance stores N bits of carry data,
     946            // organized in packs that can be processed with GR instructions (such as PEXT, PDEP, popcount).
     947            // A circular buffer is used.  Because the number of bits to be dequeued
     948            // and enqueued is variable (based on the popcount of the index), an extra
     949            // pack stores the offset position in the circular buffer.
     950            const auto amount = cast<IndexedAdvance>(stmt)->getAmount();
     951            const auto packWidth = sizeof(size_t) * 8;
     952            const auto packs = ceil_udiv(amount, packWidth);
     953            state.push_back(ArrayType::get(iBuilder->getSizeTy(), nearest_pow2(packs) + 1));
    941954        } else if (LLVM_UNLIKELY(isNonAdvanceCarryGeneratingStatement(stmt))) {
    942955            state.push_back(carryPackType);
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r5493 r5705  
    2020namespace llvm { class Value; }
    2121namespace pablo { class Advance; }
     22namespace pablo { class IndexedAdvance; }
    2223namespace pablo { class PabloBlock; }
    2324namespace pablo { class PabloKernel; }
     
    7980
    8081    llvm::Value * advanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const Advance * advance, llvm::Value * const strm);
     82   
     83    llvm::Value * indexedAdvanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const IndexedAdvance * advance, llvm::Value * const strm, llvm::Value * const index_strm);
    8184 
    8285    /* Methods for getting and setting carry summary values for If statements */
  • icGREP/icgrep-devel/icgrep/pablo/carrypack_manager.cpp

    r5630 r5705  
    625625}
    626626
     627
     628Value * CarryManager::indexedAdvanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const IndexedAdvance * const advance, Value * const value, Value * const index_strm) {
     629    report_fatal_error("IndexedAdvance not yet supported.");
     630}
     631
     632
     633
    627634/** ------------------------------------------------------------------------------------------------------------- *
    628635 * @brief longAdvanceCarryInCarryOut
     
    10321039            bool canPack = true;
    10331040            if (LLVM_LIKELY(isa<Advance>(stmt))) {
     1041                amount = cast<Advance>(stmt)->getAmount();
     1042                canPack = (amount < mElementWidth);
     1043            }
     1044            else if (isa<IndexedAdvance>(stmt)) {
    10341045                amount = cast<Advance>(stmt)->getAmount();
    10351046                canPack = (amount < mElementWidth);
     
    10921103            if (carryGroup.groupSize == 0) {
    10931104                Type * packTy = carryPackTy;
    1094                 if (LLVM_LIKELY(isa<Advance>(stmt))) {
     1105                if (LLVM_UNLIKELY(isa<Advance>(stmt))) {
    10951106                    const auto amount = cast<Advance>(stmt)->getAmount();
    10961107                    if (LLVM_UNLIKELY(amount >= mElementWidth)) {
     
    11031114                        packTy = ArrayType::get(carryTy, nearest_pow2(blocks + ((loopDepth != 0) ? 1 : 0)));
    11041115                    }
     1116                }
     1117                if (LLVM_UNLIKELY(isa<IndexedAdvance>(stmt))) {
     1118                    // The carry data for the indexed advance stores N bits of carry data,
     1119                    // organized in packs that can be processed with GR instructions (such as PEXT, PDEP, popcount).
     1120                    // A circular buffer is used.  Because the number of bits to be dequeued
     1121                    // and enqueued is variable (based on the popcount of the index), an extra
     1122                    // pack stores the offset position in the circular buffer.
     1123                    const auto amount = cast<IndexedAdvance>(stmt)->getAmount();
     1124                    const auto packWidth = sizeof(size_t) * 8;
     1125                    const auto packs = ceil_udiv(amount, packWidth);
     1126                    packTy = ArrayType::get(iBuilder->getSizeTy(), nearest_pow2(packs) + 1);
    11051127                }
    11061128                state.push_back(packTy);
  • icGREP/icgrep-devel/icgrep/pablo/carrypack_manager.h

    r5510 r5705  
    2020namespace llvm { class Value; }
    2121namespace pablo { class Advance; }
     22namespace pablo { class IndexedAdvance; }
    2223namespace pablo { class PabloBlock; }
    2324namespace pablo { class PabloKernel; }
     
    9293    llvm::Value * advanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const Advance * advance, llvm::Value * const strm);
    9394 
     95    llvm::Value * indexedAdvanceCarryInCarryOut(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const IndexedAdvance * advance, llvm::Value * const strm, llvm::Value * const index_strm);
     96
    9497    /* Methods for getting and setting carry summary values for If statements */
    9598         
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r5647 r5705  
    7676        // Stream operations
    7777        , Advance
     78        , IndexedAdvance
    7879        , ScanThru
    7980        , AdvanceThenScanThru
     
    298299        switch (e->getClassTypeId()) {
    299300            case PabloAST::ClassTypeId::Advance:
     301            case PabloAST::ClassTypeId::IndexedAdvance:
    300302            case PabloAST::ClassTypeId::ScanThru:
    301303            case PabloAST::ClassTypeId::AdvanceThenScanThru:
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5647 r5705  
    503503            // manager so that it properly selects the correct carry bit.
    504504            value = mCarryManager->advanceCarryInCarryOut(iBuilder, adv, compileExpression(iBuilder, adv->getExpression()));
     505        } else if (isa<IndexedAdvance>(stmt)) {
     506            const IndexedAdvance * const adv = cast<IndexedAdvance>(stmt);
     507            Value * strm = compileExpression(iBuilder, adv->getExpression());
     508            Value * index_strm = compileExpression(iBuilder, adv->getIndex());
     509            // If our expr is an Extract op on a mutable Var then we need to pass the index value to the carry
     510            // manager so that it properly selects the correct carry bit.
     511            value = mCarryManager->indexedAdvanceCarryInCarryOut(iBuilder, adv, strm, index_strm);
    505512        } else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
    506513            Value * const marker = compileExpression(iBuilder, mstar->getMarker());
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r5486 r5705  
    3737};
    3838
     39class IndexedAdvance final : public CarryProducingStatement {
     40    friend class PabloBlock;
     41public:
     42    static inline bool classof(const PabloAST * e) {
     43        return e->getClassTypeId() == ClassTypeId::IndexedAdvance;
     44    }
     45    static inline bool classof(const void *) {
     46        return false;
     47    }
     48    virtual ~IndexedAdvance() {
     49    }
     50    inline PabloAST * getExpression() const {
     51        return getOperand(0);
     52    }
     53    inline PabloAST * getIndex() const {
     54        return getOperand(1);
     55    }
     56    inline int64_t getAmount() const {
     57        return llvm::cast<Integer>(getOperand(2))->value();
     58    }
     59protected:
     60    IndexedAdvance(PabloAST * strm, PabloAST * index_strm, PabloAST * shiftAmount, const String * name, Allocator & allocator)
     61    : CarryProducingStatement(ClassTypeId::IndexedAdvance, strm->getType(), {strm, index_strm, shiftAmount}, name, allocator) {
     62        assert(llvm::isa<Integer>(shiftAmount));
     63    }
     64};
     65
     66
    3967}
    4068
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.cpp

    r5646 r5705  
    100100            print(adv->getExpression(), out);
    101101            out << ", " << std::to_string(adv->getAmount()) << ")";
     102        } else if (const IndexedAdvance * adv = dyn_cast<IndexedAdvance>(stmt)) {
     103            out << " = pablo.IndexedAdvance(";
     104            print(adv->getExpression(), out);
     105            out << ", ";
     106            print(adv->getIndex(), out);
     107            out << ", " << std::to_string(adv->getAmount()) << ")";
    102108        } else if (const Lookahead * adv = dyn_cast<Lookahead>(stmt)) {
    103109            out << " = pablo.Lookahead(";
Note: See TracChangeset for help on using the changeset viewer.