Ignore:
Timestamp:
Dec 14, 2018, 2:28:41 PM (7 months ago)
Author:
nmedfort
Message:

redesign of PopCount? calculation + mem leak fix

File:
1 edited

Legend:

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

    r6184 r6228  
    1010#include <fcntl.h>
    1111#include <toolchain/toolchain.h>
     12#include <boost/interprocess/mapped_region.hpp>
    1213
    1314using namespace llvm;
    1415
     16inline unsigned getPageSize() {
     17    return boost::interprocess::mapped_region::get_page_size();
     18}
    1519
    1620extern "C" uint64_t file_size(const uint32_t fd) {
     
    3640    BasicBlock * const exit = b->CreateBasicBlock("Exit");
    3741    IntegerType * const sizeTy = b->getSizeTy();
    38     ConstantInt * const PAGE_SIZE = b->getSize(stride);
     42    ConstantInt * const STRIDE_SIZE = b->getSize(stride);
    3943    Constant * const PAGE_ITEMS = b->getSize(stride /(codeUnitWidth/8));
    4044    Value * const fd = b->getScalarField("fileDescriptor");
     
    6064
    6165    b->SetInsertPoint(emptyFile);
    62     Value * const emptyFilePtr = b->CreatePointerCast(b->CreateAnonymousMMap(PAGE_SIZE), codeUnitPtrTy);
     66    Value * const emptyFilePtr = b->CreatePointerCast(b->CreateAnonymousMMap(STRIDE_SIZE), codeUnitPtrTy);
    6367    b->setScalarField("buffer", emptyFilePtr);
    6468    b->setBaseAddress("sourceBuffer", emptyFilePtr);
     
    7882    BasicBlock * const exit = b->CreateBasicBlock("mmapSourceExit");
    7983
    80     Constant * const PAGE_SIZE = b->getSize(stride);
     84    Constant * const PAGE_SIZE = b->getSize(getPageSize());
     85
     86    Constant * const STRIDE_SIZE = b->getSize(stride);
     87
    8188    Constant * const PAGE_ITEMS = b->getSize((8 * stride) / codeUnitWidth);
    8289    Constant * const BLOCK_WIDTH = b->getSize(b->getBitBlockWidth());
     
    97104    // instruct the OS that it can safely drop any fully consumed pages
    98105    b->CreateMAdvise(readableBuffer, unnecessaryBytes, CBuilder::ADVICE_DONTNEED);
    99     b->setScalarField("buffer", b->CreateGEP(readableBuffer, unnecessaryBytes));
     106    //b->setScalarField("buffer", b->CreateGEP(readableBuffer, unnecessaryBytes));
    100107    b->CreateBr(checkRemaining);
    101108
     
    122129    unconsumedBytes = b->CreateTrunc(unconsumedBytes, b->getSizeTy());
    123130
    124     Value * const bufferSize = b->CreateRoundUp(b->CreateAdd(unconsumedBytes, PADDING_SIZE), PAGE_SIZE);
     131    Value * const bufferSize = b->CreateRoundUp(b->CreateAdd(unconsumedBytes, PADDING_SIZE), STRIDE_SIZE);
    125132    Value * const buffer = b->CreateAlignedMalloc(bufferSize, b->getCacheAlignment());
    126133
     
    134141    PointerType * const codeUnitPtrTy = b->getIntNTy(codeUnitWidth)->getPointerTo();
    135142    // set the original base address as the buffer address.
    136     b->setScalarField("buffer", b->CreatePointerCast(base, codeUnitPtrTy));
     143    //b->setScalarField("buffer", b->CreatePointerCast(base, codeUnitPtrTy));
    137144    b->setScalarField("ancillaryBuffer", b->CreatePointerCast(buffer, codeUnitPtrTy));
    138145    b->setBaseAddress("sourceBuffer", b->CreatePointerCast(offsettedBuffer, codeUnitPtrTy));
Note: See TracChangeset for help on using the changeset viewer.