Ignore:
Timestamp:
Apr 24, 2018, 2:57:34 PM (15 months ago)
Author:
nmedfort
Message:

Restructured MultiBlock? kernel. Removal of Swizzled buffers. Inclusion of PopCount? rates / non-linear access. Modifications to several kernels to better align them with the kernel and pipeline changes.

File:
1 edited

Legend:

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

    r5927 r5985  
    2525/// MMAP SOURCE KERNEL
    2626
    27 Function * MMapSourceKernel::linkFileSizeMethod(const std::unique_ptr<kernel::KernelBuilder> & kb) {
    28     return kb->LinkFunction("file_size", &file_size);
    29 }
    30 
    31 void MMapSourceKernel::generateInitializeMethod(Function * const fileSizeMethod, const unsigned codeUnitWidth, const std::unique_ptr<KernelBuilder> & kb) {
    32 
    33     BasicBlock * const emptyFile = kb->CreateBasicBlock("emptyFile");
    34     BasicBlock * const nonEmptyFile = kb->CreateBasicBlock("NonEmptyFile");
    35     BasicBlock * const exit = kb->CreateBasicBlock("Exit");
    36     IntegerType * const sizeTy = kb->getSizeTy();
    37     Value * const fd = kb->getScalarField("fileDescriptor");
     27Function * MMapSourceKernel::linkFileSizeMethod(const std::unique_ptr<kernel::KernelBuilder> & b) {
     28    return b->LinkFunction("file_size", &file_size);
     29}
     30
     31void MMapSourceKernel::generateInitializeMethod(Function * const fileSizeMethod, const unsigned codeUnitWidth, const std::unique_ptr<KernelBuilder> & b) {
     32
     33    BasicBlock * const emptyFile = b->CreateBasicBlock("emptyFile");
     34    BasicBlock * const nonEmptyFile = b->CreateBasicBlock("NonEmptyFile");
     35    BasicBlock * const exit = b->CreateBasicBlock("Exit");
     36    IntegerType * const sizeTy = b->getSizeTy();
     37    Value * const fd = b->getScalarField("fileDescriptor");
    3838    assert (fileSizeMethod);
    39     Value * fileSize = kb->CreateZExtOrTrunc(kb->CreateCall(fileSizeMethod, fd), sizeTy);
    40     kb->CreateLikelyCondBr(kb->CreateIsNotNull(fileSize), nonEmptyFile, emptyFile);
    41 
    42     kb->SetInsertPoint(nonEmptyFile);
    43     PointerType * const codeUnitPtrTy = kb->getIntNTy(codeUnitWidth)->getPointerTo();
    44     Value * const fileBuffer = kb->CreatePointerCast(kb->CreateFileSourceMMap(fd, fileSize), codeUnitPtrTy);
    45     kb->setScalarField("buffer", fileBuffer);
    46     kb->setBaseAddress("sourceBuffer", fileBuffer);
    47     kb->CreateMAdvise(fileBuffer, fileSize, CBuilder::ADVICE_WILLNEED);
    48     if (codeUnitWidth > 8) {
    49         fileSize = kb->CreateUDiv(fileSize, kb->getSize(codeUnitWidth / 8));
     39    Value * fileSize = b->CreateZExtOrTrunc(b->CreateCall(fileSizeMethod, fd), sizeTy);
     40    b->CreateLikelyCondBr(b->CreateIsNotNull(fileSize), nonEmptyFile, emptyFile);
     41
     42    b->SetInsertPoint(nonEmptyFile);
     43    PointerType * const codeUnitPtrTy = b->getIntNTy(codeUnitWidth)->getPointerTo();
     44    Value * const fileBuffer = b->CreatePointerCast(b->CreateFileSourceMMap(fd, fileSize), codeUnitPtrTy);
     45    b->setScalarField("buffer", fileBuffer);
     46    b->setBaseAddress("sourceBuffer", fileBuffer);
     47    b->CreateMAdvise(fileBuffer, fileSize, CBuilder::ADVICE_WILLNEED);
     48    if (LLVM_UNLIKELY(codeUnitWidth > 8)) {
     49        fileSize = b->CreateUDiv(fileSize, b->getSize(codeUnitWidth / 8));
    5050    }
    51     kb->setBufferedSize("sourceBuffer", fileSize);
    52     kb->setScalarField("fileSize", fileSize);
    53     kb->setProducedItemCount("sourceBuffer", fileSize);
    54     kb->setCapacity("sourceBuffer", fileSize);
    55     kb->CreateBr(exit);
    56 
    57     kb->SetInsertPoint(emptyFile);
    58     kb->setTerminationSignal();
    59     kb->CreateBr(exit);
    60 
    61     kb->SetInsertPoint(exit);
    62 }
    63 
    64 void MMapSourceKernel::generateDoSegmentMethod(const unsigned codeUnitWidth, const std::unique_ptr<KernelBuilder> & kb) {
    65 
    66     BasicBlock * dropPages = kb->CreateBasicBlock("dropPages");
    67     BasicBlock * checkRemaining = kb->CreateBasicBlock("checkRemaining");
    68     BasicBlock * setTermination = kb->CreateBasicBlock("setTermination");
    69     BasicBlock * exit = kb->CreateBasicBlock("mmapSourceExit");
    70 
    71     Value * const fileSize = kb->getScalarField("fileSize");
    72     Constant * const pageSize = kb->getSize(getpagesize());
    73 
    74     Value * consumed = kb->getConsumedItemCount("sourceBuffer");
    75     consumed = kb->CreateMul(consumed, kb->getSize(codeUnitWidth / 8));
    76     consumed = kb->CreateAnd(consumed, ConstantExpr::getNeg(pageSize));
    77     Value * const consumedBuffer = kb->getRawOutputPointer("sourceBuffer", consumed);
    78     Value * const readableBuffer = kb->getScalarField("buffer");
    79     Value * const unnecessaryBytes = kb->CreatePtrDiff(consumedBuffer, readableBuffer);
     51    b->setBufferedSize("sourceBuffer", fileSize);
     52    b->setScalarField("fileSize", fileSize);
     53    b->setProducedItemCount("sourceBuffer", fileSize);
     54    b->setCapacity("sourceBuffer", fileSize);
     55    b->CreateBr(exit);
     56
     57    b->SetInsertPoint(emptyFile);
     58    ConstantInt * const PAGE_SIZE = b->getSize(getpagesize());
     59    ConstantInt * const ZERO = b->getSize(0);
     60    Value * const emptyFilePtr = b->CreatePointerCast(b->CreateAnonymousMMap(PAGE_SIZE), codeUnitPtrTy);
     61    b->setScalarField("buffer", emptyFilePtr);
     62    b->setBaseAddress("sourceBuffer", emptyFilePtr);
     63    b->setScalarField("fileSize", ZERO);
     64    b->setBufferedSize("sourceBuffer", PAGE_SIZE);
     65    b->setCapacity("sourceBuffer", PAGE_SIZE);
     66    b->setTerminationSignal();
     67    b->CreateBr(exit);
     68
     69    b->SetInsertPoint(exit);
     70}
     71
     72void MMapSourceKernel::generateDoSegmentMethod(const unsigned codeUnitWidth, const std::unique_ptr<KernelBuilder> & b) {
     73
     74    BasicBlock * const dropPages = b->CreateBasicBlock("dropPages");
     75    BasicBlock * const checkRemaining = b->CreateBasicBlock("checkRemaining");
     76    BasicBlock * const setTermination = b->CreateBasicBlock("setTermination");
     77    BasicBlock * const exit = b->CreateBasicBlock("mmapSourceExit");
     78
     79    Value * const fileSize = b->getScalarField("fileSize");
     80    Constant * const PAGE_SIZE = b->getSize(getpagesize());
     81
     82    Value * const consumedItems = b->getConsumedItemCount("sourceBuffer");
     83    Value * const consumedBytes = b->CreateMul(consumedItems, b->getSize(codeUnitWidth / 8));
     84    Value * const consumedPageOffset = b->CreateAnd(consumedBytes, ConstantExpr::getNeg(PAGE_SIZE));
     85    Value * const consumedBuffer = b->getRawOutputPointer("sourceBuffer", consumedPageOffset);
     86    Value * const readableBuffer = b->getScalarField("buffer");
     87    Value * const unnecessaryBytes = b->CreatePtrDiff(consumedBuffer, readableBuffer);
    8088
    8189    // avoid calling madvise unless an actual page table change could occur
    82     kb->CreateLikelyCondBr(kb->CreateIsNotNull(unnecessaryBytes), dropPages, checkRemaining);
    83 
    84     kb->SetInsertPoint(dropPages);
     90    b->CreateLikelyCondBr(b->CreateIsNotNull(unnecessaryBytes), dropPages, checkRemaining);
     91
     92    b->SetInsertPoint(dropPages);
    8593    // instruct the OS that it can safely drop any fully consumed pages
    86     kb->CreateMAdvise(readableBuffer, unnecessaryBytes, CBuilder::ADVICE_DONTNEED);
    87     kb->setScalarField("buffer", kb->CreateGEP(readableBuffer, unnecessaryBytes));
    88     kb->CreateBr(checkRemaining);
     94    b->CreateMAdvise(readableBuffer, unnecessaryBytes, CBuilder::ADVICE_DONTNEED);
     95    b->setScalarField("buffer", b->CreateGEP(readableBuffer, unnecessaryBytes));
     96    b->CreateBr(checkRemaining);
    8997
    9098    // determine whether or not we've exhausted the file buffer
    91     kb->SetInsertPoint(checkRemaining);
    92     Value * const remaining = kb->CreateSub(fileSize, consumed);
    93     Value * const lastPage = kb->CreateICmpULE(remaining, pageSize);
    94     kb->CreateUnlikelyCondBr(lastPage, setTermination, exit);
    95 
    96     kb->SetInsertPoint(setTermination);
    97     kb->setTerminationSignal();
    98     kb->CreateBr(exit);
     99    b->SetInsertPoint(checkRemaining);
     100    Value * const producedItems = b->getProducedItemCount("sourceBuffer");
     101    Value * const pageItems = b->CreateUDiv(PAGE_SIZE, b->getSize(codeUnitWidth / 8));
     102    Value * const nextProducedItems = b->CreateAdd(producedItems, pageItems);
     103    Value * const lastPage = b->CreateICmpULE(fileSize, nextProducedItems);
     104    b->CreateUnlikelyCondBr(lastPage, setTermination, exit);
     105
     106    b->SetInsertPoint(setTermination);
     107    b->setTerminationSignal();
     108    b->CreateBr(exit);
    99109
    100110    // finally, set the "produced" count to reflect current position in the file
    101     kb->SetInsertPoint(exit);
    102 }
    103 
    104 void MMapSourceKernel::unmapSourceBuffer(const std::unique_ptr<KernelBuilder> & kb) {
    105     kb->CreateMUnmap(kb->getBaseAddress("sourceBuffer"), kb->getBufferedSize("sourceBuffer"));
     111    b->SetInsertPoint(exit);
     112    PHINode * const newProducedItems = b->CreatePHI(b->getSizeTy(), 2);
     113    newProducedItems->addIncoming(nextProducedItems, checkRemaining);
     114    newProducedItems->addIncoming(fileSize, setTermination);
     115    b->setProducedItemCount("sourceBuffer", newProducedItems);
     116}
     117
     118void MMapSourceKernel::unmapSourceBuffer(const unsigned codeUnitWidth, const std::unique_ptr<KernelBuilder> & b) {
     119    Value * fileSize = b->getBufferedSize("sourceBuffer");
     120    if (LLVM_UNLIKELY(codeUnitWidth > 8)) {
     121        fileSize = b->CreateMul(fileSize, b->getSize(codeUnitWidth / 8));
     122    }
     123    b->CreateMUnmap(b->getBaseAddress("sourceBuffer"), fileSize);
    106124}
    107125
     
    223241}
    224242
    225 void ReadSourceKernel::freeBuffer(const std::unique_ptr<KernelBuilder> & kb) {
    226     kb->CreateFree(kb->getScalarField("buffer"));
     243void ReadSourceKernel::freeBuffer(const std::unique_ptr<KernelBuilder> & b) {
     244    b->CreateFree(b->getScalarField("buffer"));
    227245}
    228246
    229247/// Hybrid MMap/Read source kernel
    230248
    231 void FDSourceKernel::linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & kb) {
    232     mFileSizeFunction = MMapSourceKernel::linkFileSizeMethod(kb);
    233 }
    234 
    235 void FDSourceKernel::generateFinalizeMethod(const std::unique_ptr<KernelBuilder> & kb) {
    236     BasicBlock * finalizeRead = kb->CreateBasicBlock("finalizeRead");
    237     BasicBlock * finalizeMMap = kb->CreateBasicBlock("finalizeMMap");
    238     BasicBlock * finalizeDone = kb->CreateBasicBlock("finalizeDone");
    239     kb->CreateCondBr(kb->CreateTrunc(kb->getScalarField("useMMap"), kb->getInt1Ty()), finalizeMMap, finalizeRead);
    240     kb->SetInsertPoint(finalizeMMap);
    241     MMapSourceKernel::unmapSourceBuffer(kb);
    242     kb->CreateBr(finalizeDone);
    243     kb->SetInsertPoint(finalizeRead);
    244     ReadSourceKernel::freeBuffer(kb);
    245     kb->CreateBr(finalizeDone);
    246     kb->SetInsertPoint(finalizeDone);
    247 }
    248 
    249 void FDSourceKernel::generateInitializeMethod(const std::unique_ptr<KernelBuilder> & kb) {
    250     BasicBlock * initializeRead = kb->CreateBasicBlock("initializeRead");
    251     BasicBlock * tryMMap = kb->CreateBasicBlock("tryMMap");
    252     BasicBlock * initializeMMap = kb->CreateBasicBlock("initializeMMap");
    253     BasicBlock * initializeDone = kb->CreateBasicBlock("initializeDone");
     249void FDSourceKernel::linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & b) {
     250    mFileSizeFunction = MMapSourceKernel::linkFileSizeMethod(b);
     251}
     252
     253void FDSourceKernel::generateFinalizeMethod(const std::unique_ptr<KernelBuilder> & b) {
     254    BasicBlock * finalizeRead = b->CreateBasicBlock("finalizeRead");
     255    BasicBlock * finalizeMMap = b->CreateBasicBlock("finalizeMMap");
     256    BasicBlock * finalizeDone = b->CreateBasicBlock("finalizeDone");
     257    b->CreateCondBr(b->CreateTrunc(b->getScalarField("useMMap"), b->getInt1Ty()), finalizeMMap, finalizeRead);
     258    b->SetInsertPoint(finalizeMMap);
     259    MMapSourceKernel::unmapSourceBuffer(mCodeUnitWidth, b);
     260    b->CreateBr(finalizeDone);
     261    b->SetInsertPoint(finalizeRead);
     262    ReadSourceKernel::freeBuffer(b);
     263    b->CreateBr(finalizeDone);
     264    b->SetInsertPoint(finalizeDone);
     265}
     266
     267void FDSourceKernel::generateInitializeMethod(const std::unique_ptr<KernelBuilder> & b) {
     268    BasicBlock * initializeRead = b->CreateBasicBlock("initializeRead");
     269    BasicBlock * tryMMap = b->CreateBasicBlock("tryMMap");
     270    BasicBlock * initializeMMap = b->CreateBasicBlock("initializeMMap");
     271    BasicBlock * initializeDone = b->CreateBasicBlock("initializeDone");
     272
    254273    // The source will use MMapSource or readSoure kernel logic depending on the useMMap
    255274    // parameter, possibly overridden.
    256     Value * useMMap = kb->CreateTrunc(kb->getScalarField("useMMap"), kb->getInt1Ty());
     275    Value * useMMap = b->CreateTrunc(b->getScalarField("useMMap"), b->getInt1Ty());
    257276    // if the fileDescriptor is 0, the file is stdin, use readSource kernel logic.
    258     Value * fd = kb->getScalarField("fileDescriptor");
    259     useMMap = kb->CreateAnd(useMMap, kb->CreateICmpNE(fd, kb->getInt32(STDIN_FILENO)));
    260     kb->CreateCondBr(useMMap, tryMMap, initializeRead);
    261    
    262     kb->SetInsertPoint(tryMMap);
     277    Value * fd = b->getScalarField("fileDescriptor");
     278    useMMap = b->CreateAnd(useMMap, b->CreateICmpNE(fd, b->getInt32(STDIN_FILENO)));
     279    b->CreateCondBr(useMMap, tryMMap, initializeRead);
     280
     281    b->SetInsertPoint(tryMMap);
    263282    // If the fileSize is 0, we may have a virtual file such as /proc/cpuinfo
    264     Value * fileSize = kb->CreateZExtOrTrunc(kb->CreateCall(mFileSizeFunction, fd), kb->getSizeTy());
    265     useMMap = kb->CreateICmpNE(fileSize, kb->getSize(0));
    266     kb->CreateCondBr(useMMap, initializeMMap, initializeRead);
    267     kb->SetInsertPoint(initializeMMap);
    268     MMapSourceKernel::generateInitializeMethod(mFileSizeFunction, mCodeUnitWidth, kb);
    269     kb->CreateBr(initializeDone);
    270 
    271     kb->SetInsertPoint(initializeRead);
     283    Value * fileSize = b->CreateZExtOrTrunc(b->CreateCall(mFileSizeFunction, fd), b->getSizeTy());
     284    useMMap = b->CreateICmpNE(fileSize, b->getSize(0));
     285    b->CreateCondBr(useMMap, initializeMMap, initializeRead);
     286    b->SetInsertPoint(initializeMMap);
     287    MMapSourceKernel::generateInitializeMethod(mFileSizeFunction, mCodeUnitWidth, b);
     288    b->CreateBr(initializeDone);
     289
     290    b->SetInsertPoint(initializeRead);
    272291    // Ensure that readSource logic is used throughout.
    273     kb->setScalarField("useMMap", kb->getInt8(0));
    274     ReadSourceKernel::generateInitializeMethod(mCodeUnitWidth, getStride(), kb);
    275     kb->CreateBr(initializeDone);
    276     kb->SetInsertPoint(initializeDone);
    277 }
    278 
    279 void FDSourceKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> & kb) {
    280     BasicBlock * DoSegmentRead = kb->CreateBasicBlock("DoSegmentRead");
    281     BasicBlock * DoSegmentMMap = kb->CreateBasicBlock("DoSegmentMMap");
    282     BasicBlock * DoSegmentDone = kb->CreateBasicBlock("DoSegmentDone");
    283     kb->CreateCondBr(kb->CreateTrunc(kb->getScalarField("useMMap"), kb->getInt1Ty()), DoSegmentMMap, DoSegmentRead);
    284     kb->SetInsertPoint(DoSegmentMMap);
    285     MMapSourceKernel::generateDoSegmentMethod(mCodeUnitWidth, kb);
    286     kb->CreateBr(DoSegmentDone);
    287     kb->SetInsertPoint(DoSegmentRead);
    288     ReadSourceKernel::generateDoSegmentMethod(mCodeUnitWidth, getStride(), kb);
    289     kb->CreateBr(DoSegmentDone);
    290     kb->SetInsertPoint(DoSegmentDone);
     292    b->setScalarField("useMMap", b->getInt8(0));
     293    ReadSourceKernel::generateInitializeMethod(mCodeUnitWidth, getStride(), b);
     294    b->CreateBr(initializeDone);
     295    b->SetInsertPoint(initializeDone);
     296}
     297
     298void FDSourceKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> & b) {
     299    BasicBlock * DoSegmentRead = b->CreateBasicBlock("DoSegmentRead");
     300    BasicBlock * DoSegmentMMap = b->CreateBasicBlock("DoSegmentMMap");
     301    BasicBlock * DoSegmentDone = b->CreateBasicBlock("DoSegmentDone");
     302    b->CreateCondBr(b->CreateTrunc(b->getScalarField("useMMap"), b->getInt1Ty()), DoSegmentMMap, DoSegmentRead);
     303    b->SetInsertPoint(DoSegmentMMap);
     304    MMapSourceKernel::generateDoSegmentMethod(mCodeUnitWidth, b);
     305    b->CreateBr(DoSegmentDone);
     306    b->SetInsertPoint(DoSegmentRead);
     307    ReadSourceKernel::generateDoSegmentMethod(mCodeUnitWidth, getStride(), b);
     308    b->CreateBr(DoSegmentDone);
     309    b->SetInsertPoint(DoSegmentDone);
    291310}
    292311
    293312/// MEMORY SOURCE KERNEL
    294313
    295 void MemorySourceKernel::generateInitializeMethod(const std::unique_ptr<KernelBuilder> & kb) {
    296     Value * const fileSource = kb->getScalarField("fileSource");
    297     kb->setBaseAddress("sourceBuffer", fileSource);
    298     Value * const fileSize = kb->getScalarField("fileSize");
    299     Value * const fileItems = kb->CreateUDiv(fileSize, kb->getSize(mCodeUnitWidth / 8));
    300     kb->setBufferedSize("sourceBuffer", fileItems);
    301     kb->setCapacity("sourceBuffer", fileItems);
    302     kb->setProducedItemCount("sourceBuffer", fileItems);
    303     kb->setTerminationSignal();
    304 }
    305 
    306 void MemorySourceKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> & kb) {
     314void MemorySourceKernel::generateInitializeMethod(const std::unique_ptr<KernelBuilder> & b) {
     315    Value * const fileSource = b->getScalarField("fileSource");
     316    b->setBaseAddress("sourceBuffer", fileSource);
     317    Value * const fileSize = b->getScalarField("fileSize");
     318    Value * const fileItems = b->CreateUDiv(fileSize, b->getSize(mCodeUnitWidth / 8));
     319    b->setBufferedSize("sourceBuffer", fileItems);
     320    b->setCapacity("sourceBuffer", fileItems);
     321    b->setProducedItemCount("sourceBuffer", fileItems);
     322    b->setTerminationSignal();
     323}
     324
     325void MemorySourceKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> & b) {
    307326
    308327}
    309328
    310329MMapSourceKernel::MMapSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    311 : SegmentOrientedKernel("mmap_source@" + std::to_string(codeUnitWidth),
    312 {},
    313 {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer", FixedRate(), Deferred()}},
    314 {Binding{b->getInt32Ty(), "fileDescriptor"}},
    315 {Binding{b->getSizeTy(), "fileSize"}}, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}})
     330: SegmentOrientedKernel("mmap_source@" + std::to_string(codeUnitWidth)
     331, {}
     332, {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}
     333, {Binding{b->getInt32Ty(), "fileDescriptor"}}
     334, {Binding{b->getSizeTy(), "fileSize"}}
     335, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}})
    316336, mCodeUnitWidth(codeUnitWidth)
    317337, mFileSizeFunction(nullptr) {
    318338    addAttribute(MustExplicitlyTerminate());
    319 }
    320 
     339    setStride((8 * getpagesize()) / codeUnitWidth);
     340}
    321341
    322342ReadSourceKernel::ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    323343: SegmentOrientedKernel("read_source" + std::to_string(codegen::SegmentSize) + "@" + std::to_string(codeUnitWidth)
    324344, {}
    325 , {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer", FixedRate(), Deferred()}}
     345, {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}
    326346, {Binding{b->getInt32Ty(), "fileDescriptor"}}
    327347, {}
     
    329349, mCodeUnitWidth(codeUnitWidth) {
    330350    addAttribute(MustExplicitlyTerminate());
    331 }
    332 
    333 
    334 FDSourceKernel::FDSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & kb, const unsigned codeUnitWidth)
     351    setStride((8 * getpagesize()) / codeUnitWidth);
     352}
     353
     354
     355FDSourceKernel::FDSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned codeUnitWidth)
    335356: SegmentOrientedKernel("FD_source@" + std::to_string(codeUnitWidth)
    336357, {}
    337 , {Binding{kb->getStreamSetTy(1, codeUnitWidth), "sourceBuffer", FixedRate(), Deferred()}}
    338 , {Binding{kb->getInt8Ty(), "useMMap"}, Binding{kb->getInt32Ty(), "fileDescriptor"}}
    339 , {}
    340 , {Binding{kb->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}, Binding{kb->getSizeTy(), "fileSize"}})
     358// output
     359, {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}
     360// input scalar
     361, {Binding{b->getInt8Ty(), "useMMap"}, Binding{b->getInt32Ty(), "fileDescriptor"}}
     362, {}
     363, {Binding{b->getIntNTy(codeUnitWidth)->getPointerTo(), "buffer"}, Binding{b->getSizeTy(), "fileSize"}})
    341364, mCodeUnitWidth(codeUnitWidth)
    342365, mFileSizeFunction(nullptr) {
    343366    addAttribute(MustExplicitlyTerminate());
    344 }
    345 
    346 MemorySourceKernel::MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & kb, Type * const type, const unsigned codeUnitWidth)
     367    setStride((8 * getpagesize()) / codeUnitWidth);
     368}
     369
     370MemorySourceKernel::MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & b, Type * const type, const unsigned codeUnitWidth)
    347371: SegmentOrientedKernel("memory_source",
    348372    {},
    349     {Binding{kb->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
    350     {Binding{cast<PointerType>(type), "fileSource"}, Binding{kb->getSizeTy(), "fileSize"}}, {}, {})
     373    {Binding{b->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
     374    {Binding{cast<PointerType>(type), "fileSource"}, Binding{b->getSizeTy(), "fileSize"}}, {}, {})
    351375, mCodeUnitWidth(codeUnitWidth) {
    352376    addAttribute(MustExplicitlyTerminate());
Note: See TracChangeset for help on using the changeset viewer.