Ignore:
Timestamp:
Dec 22, 2016, 2:35:46 PM (3 years ago)
Author:
nmedfort
Message:

Modified memory alignment mechanism for GetPropertyValueGrepString? + misc. changes.

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
5 edited

Legend:

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

    r5227 r5234  
    7272        kernels[i]->createDoSegmentCall(instancePtrs[i], segmentBlocks);
    7373        // Must be the last action, for synchronization.
    74         kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, ConstantInt::get(iBuilder->getSizeTy(), 1)));
     74        kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, iBuilder->getSize(1)));
    7575        if (i == last_kernel) break;
    7676        iBuilder->CreateBr(segmentWait[i+1]);
     
    212212        kernels[i]->createDoSegmentCall(kernels[i]->getInstance(), segBlocks);
    213213        Value * segNo = kernels[i]->acquireLogicalSegmentNo(kernels[i]->getInstance());
    214         kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->CreateAdd(segNo, ConstantInt::get(iBuilder->getSizeTy(), 1)));
     214        kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->CreateAdd(segNo, iBuilder->getSize(1)));
    215215    }
    216216    Value * endSignal = kernels.back()->getTerminationSignal(kernels.back()->getInstance());
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5232 r5234  
    291291    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    292292    Value * self = getParameter(doBlockFunction, "self");
    293     iBuilder->CreateCall(doSegmentFunction, {self, ConstantInt::get(iBuilder->getSizeTy(), 1)});
     293    iBuilder->CreateCall(doSegmentFunction, {self, iBuilder->getSize(1)});
    294294    iBuilder->CreateRetVoid();
    295295    iBuilder->restoreIP(savePoint);
     
    358358    Value * self = &*(args++);
    359359    Value * remainingBytes = &*(args++);
    360     Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
     360    Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, iBuilder->getSize(3));
    361361
    362362    const unsigned PACK_SIZE = iBuilder->getStride()/8;
     
    365365    Value * expandedstream_ptr = getStreamSetBlockPtr(self, "expandedStream", blockNo);
    366366    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    367     Type * i8_t = iBuilder->getInt8Ty();
    368 
    369     Value * step_right_6 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00C00000));
    370     Value * step_left_8 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x003F0000));
    371     Value * step_right_4 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x0000F000));
    372     Value * step_left_10 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00000F00));
    373     Value * step_right_2 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x000000FC));
    374     Value * step_left_12 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00000003));
     367
     368    Value * step_right_6 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00C00000));
     369    Value * step_left_8 = iBuilder->simd_fill(32, iBuilder->getInt32(0x003F0000));
     370    Value * step_right_4 = iBuilder->simd_fill(32, iBuilder->getInt32(0x0000F000));
     371    Value * step_left_10 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00000F00));
     372    Value * step_right_2 = iBuilder->simd_fill(32, iBuilder->getInt32(0x000000FC));
     373    Value * step_left_12 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00000003));
    375374
    376375
    377376    // Enter the loop only if there is at least one byte remaining to process.
    378     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, radix64_loop);
     377    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0)), fbExit, radix64_loop);
    379378
    380379    iBuilder->SetInsertPoint(radix64_loop);
     
    412411    iBuilder->SetInsertPoint(loopExit);
    413412    // All base64 data has been computed, but we may need to set one or two '=' padding bytes.
    414     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, handleRemainFirstByte);
     413    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(0)), fbExit, handleRemainFirstByte);
    415414    iBuilder->SetInsertPoint(handleRemainFirstByte);
    416415    // At least one padding byte required.
     
    431430
    432431
    433     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 1)), handleNoRemainSecondByte, handleRemainSecondByte);
     432    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(1)), handleNoRemainSecondByte, handleRemainSecondByte);
    434433    iBuilder->SetInsertPoint(handleRemainSecondByte);
    435434
     
    450449
    451450    iBuilder->SetInsertPoint(fbExit);
    452     Value * outputNumberAdd = iBuilder->CreateSelect(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 0)), ConstantInt::get(iBuilder->getSizeTy(), 0), ConstantInt::get(iBuilder->getSizeTy(), 1));
     451    Value * outputNumberAdd = iBuilder->CreateSelect(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(0)), iBuilder->getSize(0), iBuilder->getSize(1));
    453452    Value * produced = iBuilder->CreateAdd(getProducedItemCount(self), iBuilder->CreateAdd(remainingBytes, outputNumberAdd));
    454453    setProducedItemCount(self, produced);
     
    477476void base64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) {
    478477    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    479     Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);
    480     Type * i8_t = iBuilder->getInt8Ty();
    481    
     478    Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);   
    482479    for (unsigned i = 0; i < 8; i++) {
    483480        Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    484         Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 25)));
    485         Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 51)));
    486         Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 62)));
    487         Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 63)));
     481        Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(25)));
     482        Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(51)));
     483        Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(62)));
     484        Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(63)));
    488485        // Strategy:
    489486        // 1. add ord('A') = 65 to all radix64 values, this sets the correct values for entries 0 to 25.
     
    492489        // 4. subtract ord('0') - ord('+') + (62 - 52) = 15 for all values = 62
    493490        // 4. subtract ord('0') - ord('/') + (63 - 62) = 2 for all values = 63
    494         Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 'A')));
    495         Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 6))));
    496         Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 75))));
    497         Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 15))));
    498         Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 2))));
     491        Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8('A')));
     492        Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, iBuilder->getInt8(6))));
     493        Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, iBuilder->getInt8(75))));
     494        Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, iBuilder->getInt8(15))));
     495        Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(2))));
    499496        iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    500497    }
     
    527524    padBytes = iBuilder->CreateAnd(padBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
    528525
    529     const unsigned PACK_SIZE = iBuilder->getStride()/8;
    530     Constant * packSize = ConstantInt::get(iBuilder->getSizeTy(), PACK_SIZE);
     526    Constant * packSize = iBuilder->getSize(iBuilder->getStride() / 8);
    531527    Value * blockNo = getScalarField(self, blockNoScalar);
    532528    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    533529    Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);
    534     Type * i8_t = iBuilder->getInt8Ty();
    535530   
    536531    // Enter the loop only if there is at least one byte remaining to process.
    537     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, base64_loop);
     532    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0)), fbExit, base64_loop);
    538533   
    539534    iBuilder->SetInsertPoint(base64_loop);
     
    543538    loopRemain->addIncoming(remainingBytes, base64_fb_entry);
    544539    Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), idx});
    545     Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 25)));
    546     Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 51)));
    547     Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 62)));
    548     Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 63)));
    549     Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 'A')));
    550     Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 6))));
    551     Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 75))));
    552     Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 15))));
    553     Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 2))));
     540    Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(25)));
     541    Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(51)));
     542    Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(62)));
     543    Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(63)));
     544    Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8('A')));
     545    Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, iBuilder->getInt8(6))));
     546    Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, iBuilder->getInt8(75))));
     547    Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, iBuilder->getInt8(15))));
     548    Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(2))));
    554549    iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), idx});
    555550    idx->addIncoming(iBuilder->CreateAdd(idx, ConstantInt::get(iBuilder->getInt32Ty(), 1)), base64_loop);
     
    561556
    562557    iBuilder->SetInsertPoint(loopExit);
    563     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(padBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, doPadding);
     558    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(padBytes, iBuilder->getSize(0)), fbExit, doPadding);
    564559    iBuilder->SetInsertPoint(doPadding);
    565560    Value * i8output_ptr = iBuilder->CreatePointerCast(base64stream_ptr, iBuilder->getInt8PtrTy());
    566561    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {remainingBytes}));
    567     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 3)), fbExit, doPadding2);
     562    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(3)), fbExit, doPadding2);
    568563    iBuilder->SetInsertPoint(doPadding2);
    569     Value * finalPadPos = iBuilder->CreateAdd(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 1));
     564    Value * finalPadPos = iBuilder->CreateAdd(remainingBytes, iBuilder->getSize(1));
    570565    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {finalPadPos}));
    571566    iBuilder->CreateBr(fbExit);
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5230 r5234  
    138138    BasicBlock * exitBlock = BasicBlock::Create(iBuilder->getContext(), "exit", finalBlockFunction, 0);
    139139   
    140     Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0));
     140    Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0));
    141141    iBuilder->CreateCondBr(emptyBlockCond, finalEmptyBlock, finalPartialBlock);
    142142    iBuilder->SetInsertPoint(finalPartialBlock);
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5230 r5234  
    3131    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    3232    Value * self = getParameter(doBlockFunction, "self");
    33     iBuilder->CreateCall(doSegmentFunction, {self, ConstantInt::get(iBuilder->getSizeTy(), 1)});
     33    iBuilder->CreateCall(doSegmentFunction, {self, iBuilder->getSize(1)});
    3434    iBuilder->CreateRetVoid();
    3535    iBuilder->restoreIP(savePoint);
  • icGREP/icgrep-devel/icgrep/kernels/symboltablepipeline.cpp

    r5230 r5234  
    279279    startIndexPhi1->addIncoming(startIndex, groupBody);
    280280    PHINode * startIV = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
    281     startIV->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), 0), groupBody);
     281    startIV->addIncoming(iBuilder->getSize(0), groupBody);
    282282    Value * startOuterTest = iBuilder->CreateICmpNE(startIV, ConstantInt::get(iBuilder->getSizeTy(), fieldCount));
    283283    iBuilder->CreateCondBr(startOuterTest, startOuterBody, endOuterCond);
     
    286286    iBuilder->SetInsertPoint(startOuterBody);
    287287    Value * startField = iBuilder->CreateExtractElement(startStream, startIV);
    288     startIV->addIncoming(iBuilder->CreateAdd(startIV, ConstantInt::get(iBuilder->getSizeTy(), 1)), startInnerCond);
     288    startIV->addIncoming(iBuilder->CreateAdd(startIV, iBuilder->getSize(1)), startInnerCond);
    289289    startBlockOffset->addIncoming(iBuilder->CreateAdd(startBlockOffset, ConstantInt::get(iBuilder->getSizeTy(), scanWordBitWidth)), startInnerCond);
    290290    iBuilder->CreateBr(startInnerCond);
     
    318318    startIndexPhi3->addIncoming(startIndexPhi1, startOuterCond);
    319319    PHINode * endIV = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
    320     endIV->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), 0), startOuterCond);
     320    endIV->addIncoming(iBuilder->getSize(0), startOuterCond);
    321321    Value * endOuterTest = iBuilder->CreateICmpNE(endIV, ConstantInt::get(iBuilder->getSizeTy(), fieldCount));
    322322    iBuilder->CreateCondBr(endOuterTest, endOuterBody, nextGroup);
     
    325325    iBuilder->SetInsertPoint(endOuterBody);
    326326    Value * endField = iBuilder->CreateExtractElement(endStream, endIV);
    327     endIV->addIncoming(iBuilder->CreateAdd(endIV, ConstantInt::get(iBuilder->getSizeTy(), 1)), endInnerCond);
     327    endIV->addIncoming(iBuilder->CreateAdd(endIV, iBuilder->getSize(1)), endInnerCond);
    328328    endBlockOffset->addIncoming(iBuilder->CreateAdd(endBlockOffset, ConstantInt::get(iBuilder->getSizeTy(), scanWordBitWidth)), endInnerCond);
    329329    iBuilder->CreateBr(endInnerCond);
     
    729729    remainingBytes3->addIncoming(bufferSize, partialLeadingCond);
    730730    remainingBytes3->addIncoming(remainingBytes2, regularCondBlock);
    731     Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, ConstantInt::get(iBuilder->getSizeTy(), 0));
     731    Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, iBuilder->getSize(0);
    732732    iBuilder->CreateCondBr(partialBlockCond, partialBodyBlock, flushLengthGroupsBlock);
    733733
Note: See TracChangeset for help on using the changeset viewer.