Changeset 4538 for icGREP/icgrep-devel


Ignore:
Timestamp:
Mar 23, 2015, 8:37:57 PM (4 years ago)
Author:
cameron
Message:

Restructure to use a single process_block_state data area

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r4435 r4538  
    106106                // to save space in the executable.   Add them if the property is used.
    107107                if (!aliases_initialized) {
    108             for (int v = 0; v < property_value_full_names.size(); v++) {
     108            for (auto v = 0; v < property_value_full_names.size(); v++) {
    109109                property_value_aliases.insert({canonicalize_value_name(property_value_full_names[v]), v});
    110110            }
    111             for (int v = 0; v < property_value_enum_names.size(); v++) {
     111            for (auto v = 0; v < property_value_enum_names.size(); v++) {
    112112                property_value_aliases.insert({canonicalize_value_name(property_value_enum_names[v]), v});
    113113            }
  • icGREP/icgrep-devel/icgrep/do_grep.cpp

    r4482 r4538  
    3434#define BUFFER_SEGMENTS 15
    3535#define BUFFER_SIZE (BUFFER_SEGMENTS * SEGMENT_SIZE)
    36 
    37 #define BitBlock_declare(name)  BitBlock name
    38 
    39 #define ubitblock_declare(name, n) \
    40   ubitblock name[n];\
    41   do {int i;\
    42       for (i = 0; i < n; i++) name[i]._128 = simd<1>::constant<0>();\
    43      }\
    44   while (0)
    4536
    4637BitBlock EOF_mask = simd<1>::constant<1>();
     
    143134    struct Output output;
    144135    BitBlock match_vector;
    145     BitBlock carry_q[mCarries];
    146     BitBlock advance_q[mAdvances];
    147    
     136    BitBlock process_block_state_data[(mProcessBlockStateSize + sizeof(BitBlock) - 1)/sizeof(BitBlock)];   
    148137   
    149138    mFileName = infilename + ":";
     
    158147
    159148    match_vector = simd<1>::constant<0>();
    160     memset (carry_q, 0, sizeof(BitBlock) * mCarries);
    161     memset (advance_q, 0, sizeof(BitBlock) * mAdvances);
    162    
     149    memset (process_block_state_data, 0, mProcessBlockStateSize);
    163150    int fdSrc;
    164151    struct stat infile_sb;
     
    209196            block_base = blk*BLOCK_SIZE + segment_base;
    210197            s2p_do_block((BytePack *) &mFileBuffer[block_base], basis_bits);
    211             mProcessBlockFcn(basis_bits, carry_q, advance_q, output);
     198            mProcessBlockFcn(basis_bits, process_block_state_data, output);
    212199
    213200            mLineBreak_scanner.load_block(output.LF, blk);
     
    254241        block_base = block_pos + segment_base;
    255242        s2p_do_block((BytePack *) &mFileBuffer[block_base], basis_bits);
    256         mProcessBlockFcn(basis_bits, carry_q, advance_q, output);
     243        mProcessBlockFcn(basis_bits, process_block_state_data, output);
    257244
    258245        mLineBreak_scanner.load_block(output.LF, blk);
     
    297284    }
    298285   
    299     mProcessBlockFcn(basis_bits, carry_q, advance_q, output);
     286    mProcessBlockFcn(basis_bits, process_block_state_data, output);
    300287
    301288    if (mCountOnlyOption)
  • icGREP/icgrep-devel/icgrep/do_grep.h

    r4478 r4538  
    4242
    4343
    44 typedef void (*process_block_fcn)(const Basis_bits &basis_bits, BitBlock carry_q[], BitBlock advance_q[], Output &output);
     44typedef void (*process_block_fcn)(const Basis_bits &basis_bits, BitBlock process_block_state_data[], Output &output);
    4545
    4646
     
    4848class GrepExecutor {
    4949public:
    50     GrepExecutor(int carry_count, int advance_count, process_block_fcn process_block):
     50    GrepExecutor(size_t process_block_state_size, process_block_fcn process_block):
    5151    mCountOnlyOption(false), mShowFileNameOption(false), mShowLineNumberingOption(false),
    52     mCarries(carry_count), mAdvances(advance_count),
     52    mProcessBlockStateSize(process_block_state_size),
    5353    mProcessBlockFcn(process_block)
    5454    {}
     
    6969    bool mNormalizeLineBreaksOption;
    7070
    71     int mCarries;
    72     int mAdvances;
     71    size_t mProcessBlockStateSize;
    7372    process_block_fcn mProcessBlockFcn;
    7473   
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r4516 r4538  
    106106
    107107    if (llvm_codegen.FunctionPointer) {
    108         void (*FP)(const Basis_bits &basis_bits, BitBlock carry_q[], BitBlock advance_q[], Output &output) =
    109            (void (*)(const Basis_bits &basis_bits, BitBlock carry_q[], BitBlock advance_q[], Output &output))(void*)llvm_codegen.FunctionPointer;
    110         GrepExecutor grepEngine = GrepExecutor(llvm_codegen.CarryQueueSize, llvm_codegen.AdvanceQueueSize, FP);
     108        void (*FP)(const Basis_bits &basis_bits, BitBlock process_block_state_data[], Output &output) =
     109           (void (*)(const Basis_bits &basis_bits, BitBlock process_block_state_data[], Output &output))(void*)llvm_codegen.FunctionPointer;
     110        GrepExecutor grepEngine = GrepExecutor(llvm_codegen.CarryDataSize, FP);
    111111        grepEngine.setCountOnlyOption(CountOnly);
    112112        grepEngine.setNormalizeLineBreaksOption(NormalizeLineBreaks);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4537 r4538  
    6666, mBasisBitsInputPtr(nullptr)
    6767, mCarryQueueIdx(0)
    68 , mCarryQueuePtr(nullptr)
     68, mCarryDataPtr(nullptr)
    6969, mNestingDepth(0)
    7070, mCarryQueueSize(0)
    7171, mAdvanceQueueIdx(0)
    72 , mAdvanceQueuePtr(nullptr)
    7372, mAdvanceQueueSize(0)
    7473, mZeroInitializer(ConstantAggregateZero::get(mBitBlockType))
     
    126125    mBasisBitsAddr = args++;
    127126    mBasisBitsAddr->setName("basis_bits");
    128     mCarryQueuePtr = args++;
    129     mCarryQueuePtr->setName("carry_q");
    130     mAdvanceQueuePtr = args++;
    131     mAdvanceQueuePtr->setName("advance_q");
     127    mCarryDataPtr = args++;
     128    mCarryDataPtr->setName("carry_data");
    132129    mOutputAddrPtr = args++;
    133130    mOutputAddrPtr->setName("output");
     
    174171    mExecutionEngine->finalizeObject();
    175172
    176     //Return the required size of the carry queue and a pointer to the process_block function.
    177     return CompiledPabloFunction(mCarryQueueSize, mAdvanceQueueSize, mFunction, mExecutionEngine);
     173    //Return the required size of the carry data area to the process_block function.
     174    return CompiledPabloFunction((mCarryQueueSize + mAdvanceQueueSize) * sizeof(BitBlock), mFunction, mExecutionEngine);
    178175}
    179176
     
    197194    functionTypeArgs.push_back(mBasisBitsInputPtr);
    198195
    199     //The carry q array.
     196    //The carry data array.
    200197    //A pointer to the BitBlock vector.
    201     functionTypeArgs.push_back(PointerType::get(mBitBlockType, 0));
    202     // Advance q array
    203198    functionTypeArgs.push_back(PointerType::get(mBitBlockType, 0));
    204199
     
    316311
    317312    //Starts on process_block
    318     SmallVector<AttributeSet, 5> Attrs;
     313    SmallVector<AttributeSet, 4> Attrs;
    319314    AttributeSet PAS;
    320315    {
     
    335330        B.addAttribute(Attribute::NoCapture);
    336331        PAS = AttributeSet::get(mMod->getContext(), 3U, B);
    337     }
    338     Attrs.push_back(PAS);
    339     {
    340         AttrBuilder B;
    341         B.addAttribute(Attribute::NoCapture);
    342         PAS = AttributeSet::get(mMod->getContext(), 4U, B);
    343332    }
    344333    Attrs.push_back(PAS);
     
    935924    if (mNestingDepth == 0) {
    936925        IRBuilder<> b(mBasicBlock);
    937         mCarryQueueVector[index] = b.CreateAlignedLoad(b.CreateGEP(mCarryQueuePtr, b.getInt64(index)), BLOCK_SIZE/8, false);
     926        mCarryQueueVector[index] = b.CreateAlignedLoad(b.CreateGEP(mCarryDataPtr, b.getInt64(index)), BLOCK_SIZE/8, false);
    938927    }
    939928    return mCarryQueueVector[index];
     
    945934    if (mNestingDepth == 0) {
    946935        IRBuilder<> b(mBasicBlock);
    947         b.CreateAlignedStore(carryOut, b.CreateGEP(mCarryQueuePtr, b.getInt64(index)), BLOCK_SIZE/8, false);
     936        b.CreateAlignedStore(carryOut, b.CreateGEP(mCarryDataPtr, b.getInt64(index)), BLOCK_SIZE/8, false);
    948937    }
    949938    mCarryQueueSummaryIdx[index] = -1;
     
    955944    if (mNestingDepth == 0) {
    956945        IRBuilder<> b(mBasicBlock);
    957         mAdvanceQueueVector[index] = b.CreateAlignedLoad(b.CreateGEP(mAdvanceQueuePtr, b.getInt64(index)), BLOCK_SIZE/8, false);
     946        mAdvanceQueueVector[index] = b.CreateAlignedLoad(b.CreateGEP(mCarryDataPtr, b.getInt64(mCarryQueueSize + index)), BLOCK_SIZE/8, false);
    958947    }
    959948    return mAdvanceQueueVector[index];
     
    965954    if (mNestingDepth == 0) {
    966955        IRBuilder<> b(mBasicBlock);
    967         b.CreateAlignedStore(advanceOut, b.CreateGEP(mAdvanceQueuePtr, b.getInt64(index)), BLOCK_SIZE/8, false);
     956        b.CreateAlignedStore(advanceOut, b.CreateGEP(mCarryDataPtr, b.getInt64(mCarryQueueSize + index)), BLOCK_SIZE/8, false);
    968957    }
    969958    mAdvanceQueueSummaryIdx[index] = -1;
     
    10711060}
    10721061
    1073 CompiledPabloFunction::CompiledPabloFunction(unsigned carryQSize, unsigned advanceQSize, Function * function, ExecutionEngine * executionEngine)
    1074 : CarryQueueSize(carryQSize)
    1075 , AdvanceQueueSize(advanceQSize)
     1062CompiledPabloFunction::CompiledPabloFunction(size_t carryDataSize, Function * function, ExecutionEngine * executionEngine)
     1063: CarryDataSize(carryDataSize)
    10761064, FunctionPointer(executionEngine->getPointerToFunction(function))
    10771065, mFunction(function)
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4537 r4538  
    5454
    5555struct CompiledPabloFunction {
    56     const unsigned      CarryQueueSize;
    57     const unsigned      AdvanceQueueSize;
     56    const size_t        CarryDataSize;
    5857    void * const        FunctionPointer;
    5958private:
     
    6160    ExecutionEngine *   mExecutionEngine;
    6261public:
    63     CompiledPabloFunction(unsigned carryQSize, unsigned advanceQSize, Function * function, ExecutionEngine * executionEngine);
     62    CompiledPabloFunction(size_t carryDataSize, Function * function, ExecutionEngine * executionEngine);
    6463
    6564    inline CompiledPabloFunction(CompiledPabloFunction && cpf)
    66     : CarryQueueSize(cpf.CarryQueueSize)
    67     , AdvanceQueueSize(cpf.AdvanceQueueSize)
     65    : CarryDataSize(cpf.CarryDataSize)
    6866    , FunctionPointer(cpf.FunctionPointer)
    6967    , mFunction(cpf.mFunction)
     
    149147
    150148    unsigned                            mCarryQueueIdx;
    151     Value*                              mCarryQueuePtr;
     149    Value*                              mCarryDataPtr;
    152150    unsigned                            mNestingDepth;
    153151    unsigned                            mCarryQueueSize;
    154152
    155153    unsigned                            mAdvanceQueueIdx;
    156     Value*                              mAdvanceQueuePtr;
    157154    unsigned                            mAdvanceQueueSize;
    158155
Note: See TracChangeset for help on using the changeset viewer.