Changeset 4945


Ignore:
Timestamp:
Feb 29, 2016, 3:09:51 PM (3 years ago)
Author:
lindanl
Message:

Use kernel state methods.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r4930 r4945  
    144144}
    145145
    146 void KernelBuilder::changeKernelInternalState(int idx, Value * stateValue){
     146void KernelBuilder::changeKernelInternalState(Value * kernelStruct, int idx, Value * stateValue){
    147147    Value* indices[] = {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(idx)};
    148     Value* gep = iBuilder->CreateGEP(mKernelStructParam, indices);
     148    Value* gep = iBuilder->CreateGEP(kernelStruct, indices);
    149149    iBuilder->CreateAlignedStore(stateValue, gep, mBlockSize/8, false);
    150150}
    151151
    152 Value * KernelBuilder::getKernelInternalState(int idx){
     152Value * KernelBuilder::getKernelInternalState(Value * kernelStruct, int idx){
    153153    Value* indices[] = {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(idx)};
    154     Value* gep = iBuilder->CreateGEP(mKernelStructParam, indices);
     154    Value* gep = iBuilder->CreateGEP(kernelStruct, indices);
    155155    return iBuilder->CreateAlignedLoad(gep, mBlockSize/8, false, "state"+std::to_string(idx));
    156156}
    157157
    158 Value * KernelBuilder::getKernelInternalStatePtr(int idx){
     158Value * KernelBuilder::getKernelInternalStatePtr(Value * kernelStruct, int idx){
    159159    Value* indices[] = {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(idx)};
    160     Value* gep = iBuilder->CreateGEP(mKernelStructParam, indices);
     160    Value* gep = iBuilder->CreateGEP(kernelStruct, indices);
    161161    return gep;
    162162}
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r4930 r4945  
    6262    Value * getKernelStructParam();
    6363
    64     void changeKernelInternalState(int idx, Value * stateValue);
    65     Value * getKernelInternalState(int idx);
    66     Value * getKernelInternalStatePtr(int idx);
     64    void changeKernelInternalState(Value * kernelStruct, int idx, Value * stateValue);
     65    Value * getKernelInternalState(Value * kernelStruct, int idx);
     66    Value * getKernelInternalStatePtr(Value * kernelStruct, int idx);
    6767
    6868private:
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r4940 r4945  
    9191    Value * scanMatchKernelStruct = mScanMatchKernel->generateKernelInstance();
    9292
    93     Value * gep = iBuilder->CreateGEP(scanMatchKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(mFileBufIdx)});
    9493    Value* filebuf = iBuilder->CreateBitCast(input_param, S);
    95     iBuilder->CreateStore(filebuf, gep);
    96     gep = iBuilder->CreateGEP(scanMatchKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(mFileSizeIdx)});
    97     iBuilder->CreateStore(buffersize_param, gep);
    98     gep = iBuilder->CreateGEP(scanMatchKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(mFileNameIdx)});
    99     iBuilder->CreateStore(filename_param, gep);
     94    mScanMatchKernel->changeKernelInternalState(scanMatchKernelStruct, mFileBufIdx, filebuf);
     95    mScanMatchKernel->changeKernelInternalState(scanMatchKernelStruct, mFileSizeIdx, buffersize_param);
     96    mScanMatchKernel->changeKernelInternalState(scanMatchKernelStruct, mFileNameIdx, filename_param);
    10097
    10198    Value * basis_bits = iBuilder->CreateGEP(s2pKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
     
    115112    iBuilder->SetInsertPoint(pipeline_do_block);
    116113
    117     gep = iBuilder->CreateGEP(input_param, {blkNo_phi});
     114    Value * gep = iBuilder->CreateGEP(input_param, {blkNo_phi});
    118115    Value * update_blkNo = iBuilder->CreateAdd(blkNo_phi, iBuilder->getInt64(1));
    119116    blkNo_phi->addIncoming(update_blkNo, pipeline_do_block);
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r4939 r4945  
    3434       
    3535       
    36 void generateScanWordRoutine(Module * m, IDISA::IDISA_Builder * iBuilder, int scanwordBitWidth, Type * kernelStuctType, bool isNameExpression) {
     36void generateScanWordRoutine(Module * m, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder, int scanwordBitWidth, bool isNameExpression) {
    3737    LLVMContext & ctxt = m->getContext();
    3838    Type * T = iBuilder->getIntNTy(scanwordBitWidth);   
    3939    Type * S = PointerType::get(iBuilder->getIntNTy(8), 0);
    4040    Type * returnType = StructType::get(ctxt, std::vector<Type *>({T, T}));
     41    Type * kernelStuctType = PointerType::get(kBuilder->getKernelStructType(), 0);
    4142    FunctionType * functionType = FunctionType::get(returnType, std::vector<Type *>({kernelStuctType, T, T, T, T, T}), false);
    4243    Function * sFunction;
     
    141142    Value * matchRecordEnd = iBuilder->CreateAdd(scanwordPos, generateCountForwardZeroes(iBuilder, matches_phi));
    142143
    143     Value* filebuf_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(7)});
    144     Value* filebufptr = iBuilder->CreateLoad(filebuf_gep, "filebuf");
    145 
    146     Value* filesize_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(8)});
    147     Value* filesize = iBuilder->CreateLoad(filesize_gep, "filensize");
    148 
    149     Value* filename_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(9)});
    150     Value* filenameptr = iBuilder->CreateLoad(filename_gep, "filename");
     144    Value* filebufptr = kBuilder->getKernelInternalState(this_input_parm, 7);
     145    Value* filesize = kBuilder->getKernelInternalState(this_input_parm, 8);
     146    Value* filenameptr = kBuilder->getKernelInternalState(this_input_parm, 9);
    151147
    152148    if(isNameExpression)
     
    215211    kBuilder->PrepareDoBlockFunction();
    216212
    217     Type * kernelStuctType = PointerType::get(kBuilder->getKernelStructType(), 0);
    218     generateScanWordRoutine(m, iBuilder, scanwordBitWidth, kernelStuctType, isNameExpression);
     213    generateScanWordRoutine(m, iBuilder, kBuilder, scanwordBitWidth, isNameExpression);
    219214
    220215    struct Inputs inputs = kBuilder->openDoBlock();
     
    222217    Value * kernelStuctParam = kBuilder->getKernelStructParam();
    223218   
    224     Value * scanwordPos = kBuilder->getKernelInternalState(blockPosIdx);
    225     Value * recordStart = kBuilder->getKernelInternalState(lineStartIdx);
    226     Value * recordNum = kBuilder->getKernelInternalState(lineNumIdx);
     219    Value * scanwordPos = kBuilder->getKernelInternalState(kernelStuctParam, blockPosIdx);
     220    Value * recordStart = kBuilder->getKernelInternalState(kernelStuctParam, lineStartIdx);
     221    Value * recordNum = kBuilder->getKernelInternalState(kernelStuctParam, lineNumIdx);
    227222    Value * wordResult = nullptr;
    228223
     
    242237    }
    243238
    244     kBuilder->changeKernelInternalState(blockPosIdx, scanwordPos);
    245     kBuilder->changeKernelInternalState(lineStartIdx, recordStart);
    246     kBuilder->changeKernelInternalState(lineNumIdx, recordNum);
     239    kBuilder->changeKernelInternalState(kernelStuctParam, blockPosIdx, scanwordPos);
     240    kBuilder->changeKernelInternalState(kernelStuctParam, lineStartIdx, recordStart);
     241    kBuilder->changeKernelInternalState(kernelStuctParam, lineNumIdx, recordNum);
    247242
    248243    kBuilder->closeDoBlock(outputs);
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4942 r4945  
    6868
    6969void CarryManager::initialize_setPtrs(KernelBuilder * kBuilder) {
    70    
    71     Value * cdArrayPtr = kBuilder->getKernelInternalStatePtr(mCdArrayIdx);
     70
     71    Value * kernelStuctParam = kBuilder->getKernelStructParam();
     72    Value * cdArrayPtr = kBuilder->getKernelInternalStatePtr(kernelStuctParam, mCdArrayIdx);
    7273 
    7374    mCarryPackBasePtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mCarryPackType, 0));
    74     mCarryBitBlockPtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mBitBlockType, 0));
    75    
     75    mCarryBitBlockPtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mBitBlockType, 0));   
    7676   
    7777    if (mPabloCountCount > 0) {
    78         Value * pcArrayPtr = kBuilder->getKernelInternalStatePtr(mPcArrayIdx);
     78        Value * pcArrayPtr = kBuilder->getKernelInternalStatePtr(kernelStuctParam, mPcArrayIdx);
    7979        mPopcountBasePtr = iBuilder->CreateBitCast(pcArrayPtr, Type::getInt64PtrTy(iBuilder->getContext()));
    8080    }
    8181 
    82     mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
     82    mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(kernelStuctParam, mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
    8383    mCurrentScope = mRootScope;
    8484    mCurrentFrameIndex = 0;
     
    8888
    8989void CarryManager::set_BlockNo(KernelBuilder * kBuilder){
    90     mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
     90    Value * kernelStuctParam = kBuilder->getKernelStructParam();
     91    mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(kernelStuctParam, mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
    9192}
    9293
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4942 r4945  
    149149    struct Outputs outputs;
    150150    mFunction = mKBuilder->getDoBlockFunction();
     151    Value * kernelStuctParam = mKBuilder->getKernelStructParam();
    151152
    152153    mCarryManager->initialize_setPtrs(mKBuilder);
     
    160161        compileBlock(mainScope);
    161162
    162         Value * filePos = iBuilder->CreateAdd(mKBuilder->getKernelInternalState(mFilePosIdx), iBuilder->getInt64(iBuilder->getBitBlockWidth()));
    163         mKBuilder->changeKernelInternalState(mFilePosIdx, filePos);
     163        Value * filePos = iBuilder->CreateAdd(mKBuilder->getKernelInternalState(kernelStuctParam, mFilePosIdx), iBuilder->getInt64(iBuilder->getBitBlockWidth()));
     164        mKBuilder->changeKernelInternalState(kernelStuctParam, mFilePosIdx, filePos);
    164165
    165166        mCarryManager->set_BlockNo(mKBuilder);
Note: See TracChangeset for help on using the changeset viewer.