Ignore:
Timestamp:
Mar 15, 2016, 10:20:07 PM (3 years ago)
Author:
nmedfort
Message:

Added the kernel instance class; removed original mmap file access in favour of the boost mmap system. corrected PrintRegister? routine.

File:
1 edited

Legend:

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

    r4970 r4974  
    1212using namespace llvm;
    1313
     14namespace kernel {
     15
    1416Value * generateForwardZeroesMask(IDISA::IDISA_Builder * iBuilder, Value * bits) {
    1517    Value * bits_minus1 = iBuilder->CreateSub(bits, ConstantInt::get(bits->getType(), 1));
     
    4850    Type * S = PointerType::get(iBuilder->getIntNTy(8), 0);
    4951    Type * returnType = StructType::get(ctxt, std::vector<Type *>({T, T}));
    50     FunctionType * functionType = FunctionType::get(returnType, std::vector<Type *>({PointerType::get(kBuilder->getKernelStructType(), 0), T, T, T, T, T}), false);
     52    FunctionType * functionType = FunctionType::get(returnType, std::vector<Type *>({PointerType::get(kBuilder->getKernelStateType(), 0), T, T, T, T, T}), false);
    5153
    5254    SmallVector<AttributeSet, 6> Attrs;
     
    6567
    6668    Function::arg_iterator args = function->arg_begin();
    67     Value * this_input_parm = args++;
    68     this_input_parm->setName("this");
     69    Value * instance = args++;
     70    instance->setName("this");
    6971    Value * matches_input_parm = args++;
    7072    matches_input_parm->setName("matches");
     
    151153    Value * matchRecordEnd = iBuilder->CreateAdd(scanwordPos, generateCountForwardZeroes(iBuilder, matches_phi));
    152154
    153     Value* filebuf_gep = kBuilder->getInternalState("FileBuf", this_input_parm);
    154     Value* filebufptr = iBuilder->CreateLoad(filebuf_gep, "filebuf");
    155 
     155    Value * fileBuf = iBuilder->CreateLoad(kBuilder->getInternalState(instance, "FileBuf"));
    156156    if (isNameExpression) {
    157         iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, filebufptr}));
     157        iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, fileBuf}));
    158158    } else {
    159         Value * filesize_gep = kBuilder->getInternalState("FileSize", this_input_parm);
    160         Value * filesize = iBuilder->CreateLoad(filesize_gep, "filesize");
    161 
    162         Value * filename_gep = kBuilder->getInternalState("FileName", this_input_parm);
    163         Value * filenameptr = iBuilder->CreateLoad(filename_gep, "filename");
    164 
    165         iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, filebufptr, filesize, filenameptr}));
     159        Value * fileSize = iBuilder->CreateLoad(kBuilder->getInternalState(instance, "FileSize"));
     160        Value * fileName = iBuilder->CreateLoad(kBuilder->getInternalState(instance, "FileName"));
     161        iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, fileBuf, fileSize, fileName}));
    166162    }
    167163
     
    225221    Function * function = kBuilder->prepareFunction();
    226222
    227     // Type * kernelStuctType = PointerType::get(kBuilder->getKernelStructType(), 0);
    228 
    229223    Function * scanWordFunction = generateScanWordRoutine(m, iBuilder, scanWordBitWidth, kBuilder, isNameExpression);
    230224
    231225    iBuilder->SetInsertPoint(&function->getEntryBlock());
    232226
    233     Value * kernelStuctParam = kBuilder->getKernelStructParam();
     227    Value * kernelStuctParam = kBuilder->getKernelState();
    234228
    235229    Value * scanwordPos = iBuilder->CreateBlockAlignedLoad(kBuilder->getInternalState("BlockNo"));
     
    238232    Value * recordStart = iBuilder->CreateBlockAlignedLoad(kBuilder->getInternalState(lineStart));
    239233    Value * recordNum = iBuilder->CreateBlockAlignedLoad(kBuilder->getInternalState(lineNum));
    240 
    241     Value * wordResult = nullptr;
    242 
    243     const unsigned segmentBlocks = kBuilder->getSegmentBlocks();
    244     const unsigned scanWordBlocks =  segmentBlocks * fieldCount;
    245     for(unsigned j = 0; j < segmentBlocks; ++j) {
    246         Value * matchWordVector = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(0)), scanwordVectorType);
    247         Value * breakWordVector = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(1)), scanwordVectorType);
    248         for(unsigned i = 0; i < scanWordBlocks; ++i){
    249             Value * matchWord = iBuilder->CreateExtractElement(matchWordVector, ConstantInt::get(T, i));
    250             Value * recordBreaksWord = iBuilder->CreateExtractElement(breakWordVector, ConstantInt::get(T, i));
    251             wordResult = iBuilder->CreateCall(scanWordFunction, std::vector<Value *>({kernelStuctParam, matchWord, recordBreaksWord, scanwordPos, recordStart, recordNum}));
    252             scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, scanWordBitWidth));
    253             recordStart = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({0}));
    254             recordNum = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({1}));
    255         }
    256         kBuilder->increment();
     234    Value * matchWordVector = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(0)), scanwordVectorType);
     235    Value * breakWordVector = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(1)), scanwordVectorType);
     236    for(unsigned i = 0; i < fieldCount; ++i){
     237        Value * matchWord = iBuilder->CreateExtractElement(matchWordVector, ConstantInt::get(T, i));
     238        Value * recordBreaksWord = iBuilder->CreateExtractElement(breakWordVector, ConstantInt::get(T, i));
     239        Value * wordResult = wordResult = iBuilder->CreateCall(scanWordFunction, std::vector<Value *>({kernelStuctParam, matchWord, recordBreaksWord, scanwordPos, recordStart, recordNum}));
     240        scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, scanWordBitWidth));
     241        recordStart = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({0}));
     242        recordNum = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({1}));
    257243    }
    258244    kBuilder->setInternalState(lineStart, recordStart);
     
    260246    kBuilder->finalize();
    261247}
     248
     249}
Note: See TracChangeset for help on using the changeset viewer.