Ignore:
Timestamp:
May 17, 2018, 3:41:00 PM (14 months ago)
Author:
nmedfort
Message:

Major refactoring of buffer types. Static buffers replace Circular and CircularCopyback?. External buffers unify Source/External?.

File:
1 edited

Legend:

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

    r6025 r6047  
    3535    BasicBlock * const exit = b->CreateBasicBlock("Exit");
    3636    IntegerType * const sizeTy = b->getSizeTy();
    37 
    3837    ConstantInt * const PAGE_SIZE = b->getSize(getpagesize());
    39     ConstantInt * const ZERO = b->getSize(0);
    40 
    41 
    4238    Value * const fd = b->getScalarField("fileDescriptor");
    4339    assert (fileSizeMethod);
     
    5450        fileSize = b->CreateUDiv(fileSize, b->getSize(codeUnitWidth / 8));
    5551    }
    56     b->setBufferedSize("sourceBuffer", fileSize);
    5752    b->setScalarField("fileSize", fileSize);
    58     b->setProducedItemCount("sourceBuffer", ZERO);
    59     b->setCapacity("sourceBuffer", fileSize);
    6053    b->CreateBr(exit);
    6154
     
    6457    b->setScalarField("buffer", emptyFilePtr);
    6558    b->setBaseAddress("sourceBuffer", emptyFilePtr);
    66     b->setScalarField("fileSize", ZERO);
    67     b->setBufferedSize("sourceBuffer", PAGE_SIZE);
    68     b->setCapacity("sourceBuffer", PAGE_SIZE);
     59    b->setScalarField("fileSize", PAGE_SIZE);
    6960    b->setTerminationSignal();
    7061    b->CreateBr(exit);
     
    160151    b->setScalarField("buffer", buffer);
    161152    b->setCapacity("sourceBuffer", bufferItems);
     153    b->setScalarField("fileSize", b->getSize(0));
    162154}
    163155
     
    179171    // Do we have enough unread data to support one segment?
    180172    Value * const produced = b->getProducedItemCount("sourceBuffer");
    181     Value * const buffered = b->getBufferedSize("sourceBuffer");
     173    Value * const buffered = b->getScalarField("fileSize");
    182174    Value * const itemsPending = b->CreateAdd(produced, itemsPerSegment);
    183175
     
    245237    Value * const itemsRead = b->CreateUDiv(bytesRead, codeUnitBytes);
    246238    Value * const itemsBuffered = b->CreateAdd(buffered, itemsRead);
    247     b->setBufferedSize("sourceBuffer", itemsBuffered);
     239    b->setScalarField("fileSize", itemsBuffered);
    248240    b->CreateUnlikelyCondBr(b->CreateICmpULT(itemsBuffered, itemsPending), setTermination, readExit);
    249241
     
    255247    b->CreateBr(readExit);
    256248
    257     readExit->moveAfter(setTermination);
    258249    b->SetInsertPoint(readExit);
    259250    PHINode * const itemsProduced = b->CreatePHI(itemsPending->getType(), 3);
     
    339330    b->setBaseAddress("sourceBuffer", fileSource);
    340331    Value * const fileSize = b->getScalarField("fileSize");
    341     b->setBufferedSize("sourceBuffer", fileSize);
    342332    b->setCapacity("sourceBuffer", fileSize);
    343333    if (mStreamSetCount > 1) {
     
    403393MMapSourceKernel::MMapSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    404394: SegmentOrientedKernel("mmap_source@" + std::to_string(codeUnitWidth)
    405 , {}
     395// input streams
     396, {}
     397// output streams
    406398, {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}
     399// input scalars
    407400, {Binding{b->getInt32Ty(), "fileDescriptor"}}
    408 , {Binding{b->getSizeTy(), "fileSize"}}
    409 , {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}})
     401// output scalars
     402, {}
     403// internal scalars
     404, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}
     405,  Binding{b->getSizeTy(), "fileSize"}})
    410406, mCodeUnitWidth(codeUnitWidth)
    411407, mFileSizeFunction(nullptr) {
     
    416412ReadSourceKernel::ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    417413: SegmentOrientedKernel("read_source" + std::to_string(codegen::SegmentSize) + "@" + std::to_string(codeUnitWidth)
    418 , {}
     414// input streams
     415, {}
     416// output streams
    419417, {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}
     418// input scalars
    420419, {Binding{b->getInt32Ty(), "fileDescriptor"}}
    421 , {}
    422 , {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}})
     420// output scalars
     421, {}
     422// internal scalars
     423, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}
     424,  Binding{b->getSizeTy(), "fileSize"}})
    423425, mCodeUnitWidth(codeUnitWidth) {
    424426    addAttribute(MustExplicitlyTerminate());
     
    429431FDSourceKernel::FDSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    430432: SegmentOrientedKernel("FD_source@" + std::to_string(codeUnitWidth)
     433// input streams
    431434, {}
    432435// output stream
     
    435438, {Binding{b->getInt8Ty(), "useMMap"}, Binding{b->getInt32Ty(), "fileDescriptor"}}
    436439, {}
    437 // internal scalar
    438 , {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}, Binding{b->getSizeTy(), "fileSize"}})
     440// internal scalars
     441, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"},
     442   Binding{b->getSizeTy(), "fileSize"}})
    439443, mCodeUnitWidth(codeUnitWidth)
    440444, mFileSizeFunction(nullptr) {
     
    445449MemorySourceKernel::MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned streamSetCount, const unsigned codeUnitWidth)
    446450: SegmentOrientedKernel("memory_source@" + std::to_string(streamSetCount) + ":" + std::to_string(codeUnitWidth),
     451// input streams
    447452{},
    448453// output stream
Note: See TracChangeset for help on using the changeset viewer.