Ignore:
Timestamp:
May 13, 2017, 11:37:08 AM (2 years ago)
Author:
cameron
Message:

Hack for source/external buffers with mBufferBlocks=1; u8u16 test with segment-pipeline-parallel; simplified copying

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5435 r5448  
    229229
    230230add_test(
     231  NAME u8u16_multi_test
     232  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
     233  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel)
     234
     235add_test(
    231236  NAME lz4d_test
    232237  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/lz4d
     
    245250add_custom_target (u8u16_test
    246251  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
    247   COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
     252  COMMAND ./run_all "${CMAKE_BINARY_DIR}/u8u16 -segment-size=16 -enable-segment-pipeline-parallel")
    248253
    249254add_custom_target (lz4d_test
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5447 r5448  
    140140
    141141    for (unsigned i = 0; i < mStreamSetInputs.size(); i++) {
    142         if ((mStreamSetInputBuffers[i]->getBufferBlocks() > 0) && (mStreamSetInputBuffers[i]->getBufferBlocks() < requiredBlocks)) {
     142        if ((mStreamSetInputBuffers[i]->getBufferBlocks() > 1) && (mStreamSetInputBuffers[i]->getBufferBlocks() < requiredBlocks)) {
    143143            report_fatal_error(getName() + ": " + mStreamSetInputs[i].name + " requires buffer size " + std::to_string(requiredBlocks));
    144144        }
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5442 r5448  
    9292    Value * bytePtr = iBuilder->CreatePointerCast(iBuilder->getInputStreamBlockPtr("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
    9393    bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    94     iBuilder->CreateWriteCall(fileDes, bytePtr, iBuilder->CreateMul(itemsToDo, itemBytes));
     94    Value * bytesToDo = mCodeUnitWidth == 8 ? itemsToDo : iBuilder->CreateMul(itemsToDo, itemBytes);
     95    iBuilder->CreateWriteCall(fileDes, bytePtr, bytesToDo);
    9596   
    9697    processed = iBuilder->CreateAdd(processed, itemsToDo);
     
    109110        bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    110111        itemsToDo = iBuilder->CreateSub(available, processed);
    111         iBuilder->CreateWriteCall(fileDes, bytePtr, iBuilder->CreateMul(itemsToDo, itemBytes));
     112        bytesToDo = mCodeUnitWidth == 8 ? itemsToDo : iBuilder->CreateMul(itemsToDo, itemBytes);
     113        iBuilder->CreateWriteCall(fileDes, bytePtr, bytesToDo);
    112114        processed = iBuilder->CreateAdd(processed, itemsToDo);
    113115        iBuilder->setProcessedItemCount("codeUnitBuffer", available);
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5446 r5448  
    138138
    139139void StreamSetBuffer::createBlockAlignedCopy(IDISA::IDISA_Builder * const iBuilder, Value * targetBlockPtr, Value * sourceBlockPtr, Value * itemsToCopy) const {
    140     Type * size_ty = iBuilder->getSizeTy();
    141140    Type * i8ptr = iBuilder->getInt8PtrTy();
     141    unsigned alignment = iBuilder->getBitBlockWidth() / 8;
    142142    Constant * blockSize = iBuilder->getSize(iBuilder->getBitBlockWidth());
    143     Function * f = iBuilder->GetInsertBlock()->getParent();
    144     BasicBlock * wholeBlockCopy = BasicBlock::Create(iBuilder->getContext(), "wholeBlockCopy", f, 0);
    145     BasicBlock * partialBlockCopy = BasicBlock::Create(iBuilder->getContext(), "partialBlockCopy", f, 0);
    146     BasicBlock * copyDone = BasicBlock::Create(iBuilder->getContext(), "copyDone", f, 0);
    147143    unsigned numStreams = getType()->getArrayNumElements();
    148144    auto elemTy = getType()->getArrayElementType();
    149145    unsigned fieldWidth = isa<ArrayType>(elemTy) ? elemTy->getArrayNumElements() : 1;
     146    if (numStreams == 1) {
     147        Value * copyBits = iBuilder->CreateMul(itemsToCopy, iBuilder->getSize(fieldWidth));
     148        Value * copyBytes = iBuilder->CreateLShr(iBuilder->CreateAdd(copyBits, iBuilder->getSize(7)), iBuilder->getSize(3));
     149        iBuilder->CreateMemMove(iBuilder->CreateBitCast(targetBlockPtr, i8ptr), iBuilder->CreateBitCast(sourceBlockPtr, i8ptr), copyBytes, alignment);
     150        return;
     151    }
    150152    Value * blocksToCopy = iBuilder->CreateUDiv(itemsToCopy, blockSize);
    151153    Value * partialItems = iBuilder->CreateURem(itemsToCopy, blockSize);
    152154    Value * partialBlockTargetPtr = iBuilder->CreateGEP(targetBlockPtr, blocksToCopy);
    153155    Value * partialBlockSourcePtr = iBuilder->CreateGEP(sourceBlockPtr, blocksToCopy);
    154     iBuilder->CreateCondBr(iBuilder->CreateICmpUGT(blocksToCopy, iBuilder->getSize(0)), wholeBlockCopy, partialBlockCopy);
    155     iBuilder->SetInsertPoint(wholeBlockCopy);
    156     unsigned alignment = iBuilder->getBitBlockWidth() / 8;
    157     Value * copyLength = iBuilder->CreateSub(iBuilder->CreatePtrToInt(partialBlockTargetPtr, size_ty), iBuilder->CreatePtrToInt(targetBlockPtr, size_ty));
    158     iBuilder->CreateMemMove(iBuilder->CreateBitCast(targetBlockPtr, i8ptr), iBuilder->CreateBitCast(sourceBlockPtr, i8ptr), copyLength, alignment);
    159     iBuilder->CreateCondBr(iBuilder->CreateICmpUGT(partialItems, iBuilder->getSize(0)), partialBlockCopy, copyDone);
    160     iBuilder->SetInsertPoint(partialBlockCopy);
    161     Value * copyBits = iBuilder->CreateMul(itemsToCopy, iBuilder->getSize(fieldWidth));
    162     Value * copyBytes = iBuilder->CreateLShr(iBuilder->CreateAdd(copyBits, iBuilder->getSize(7)), iBuilder->getSize(3));
     156    Value * blockCopyBytes = iBuilder->CreateMul(blocksToCopy, iBuilder->getSize(iBuilder->getBitBlockWidth() * numStreams * fieldWidth/8));
     157    iBuilder->CreateMemMove(iBuilder->CreateBitCast(targetBlockPtr, i8ptr), iBuilder->CreateBitCast(sourceBlockPtr, i8ptr), blockCopyBytes, alignment);
     158    Value * partialCopyBitsPreStream = iBuilder->CreateMul(partialItems, iBuilder->getSize(fieldWidth));
     159    Value * partialCopyBytesPreStream = iBuilder->CreateLShr(iBuilder->CreateAdd(partialCopyBitsPreStream, iBuilder->getSize(7)), iBuilder->getSize(3));
    163160    for (unsigned strm = 0; strm < numStreams; strm++) {
    164161        Value * strmTargetPtr = iBuilder->CreateGEP(partialBlockTargetPtr, {iBuilder->getInt32(0), iBuilder->getInt32(strm)});
    165162        Value * strmSourcePtr = iBuilder->CreateGEP(partialBlockSourcePtr, {iBuilder->getInt32(0), iBuilder->getInt32(strm)});
    166         iBuilder->CreateMemMove(iBuilder->CreateBitCast(strmTargetPtr, i8ptr), iBuilder->CreateBitCast(strmSourcePtr, i8ptr), copyBytes, alignment);
    167     }
    168     iBuilder->CreateBr(copyDone);
    169     iBuilder->SetInsertPoint(copyDone);
     163        iBuilder->CreateMemMove(iBuilder->CreateBitCast(strmTargetPtr, i8ptr), iBuilder->CreateBitCast(strmSourcePtr, i8ptr), partialCopyBytesPreStream, alignment);
     164    }
    170165}
    171166
Note: See TracChangeset for help on using the changeset viewer.