Ignore:
Timestamp:
Apr 22, 2017, 4:03:25 PM (2 years ago)
Author:
nmedfort
Message:

Removed non-functional CUDA code from icgrep and consolidated grep and multigrep mode into a single function; allowed segment parallel pipeline to utilize process as its initial thread; modified MMapSourceKernel to map and perform mmap directly and advise the OS to drop consumed data streams.

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5415 r5418  
    1313#include <llvm/Support/raw_ostream.h>
    1414#include <kernels/toolchain.h>
     15#include <llvm/ADT/Triple.h>
    1516#include <fcntl.h>
    1617#include <unistd.h>
    1718#include <sys/mman.h>
     19#include <sys/stat.h>
    1820#include <errno.h>
    19 #include <llvm/ADT/Triple.h>
    2021
    2122using namespace llvm;
     
    3334
    3435// ssize_t write(int fildes, const void *buf, size_t nbyte);
    35 Value * CBuilder::CreateWriteCall(Value * fildes, Value * buf, Value * nbyte) {
     36Value * CBuilder::CreateWriteCall(Value * fileDescriptor, Value * buf, Value * nbyte) {
    3637    Function * write = mMod->getFunction("write");
    3738    if (write == nullptr) {
     
    4344                                                        sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
    4445    }
    45     return CreateCall(write, {fildes, buf, nbyte});
     46    return CreateCall(write, {fileDescriptor, buf, nbyte});
    4647}
    4748
     
    5960}
    6061
    61 Value * CBuilder::CreateCloseCall(Value * fildes) {
     62Value * CBuilder::CreateCloseCall(Value * fileDescriptor) {
    6263    Function * closeFn = mMod->getFunction("close");
    6364    if (closeFn == nullptr) {
     
    6667        closeFn = Function::Create(fty, Function::ExternalLinkage, "close", mMod);
    6768    }
    68     return CreateCall(closeFn, {fildes});
     69    return CreateCall(closeFn, {fileDescriptor});
    6970}
    7071
     
    7879    }
    7980    return CreateCall(unlinkFunc, {path});
     81}
     82
     83Value * CBuilder::CreateFileSize(Value * fileDescriptor) {
     84    Function * fileSizeFunc = mMod->getFunction("file_size");
     85    if (fileSizeFunc == nullptr) {
     86        FunctionType * fty = FunctionType::get(getSizeTy(), {getInt32Ty()}, true);
     87        fileSizeFunc = Function::Create(fty, Function::ExternalLinkage, "file_size", mMod);
     88    }
     89    return CreateCall(fileSizeFunc, {fileDescriptor});
    8090}
    8191
     
    212222}
    213223
    214 Value * CBuilder::CreateFileSourceMMap(Value * const fd, Value * size) {
     224Value * CBuilder::CreateFileSourceMMap(Value * fd, Value * size) {
    215225    PointerType * const voidPtrTy = getVoidPtrTy();
    216226    IntegerType * const intTy = getInt32Ty();
     227    fd = CreateZExtOrTrunc(fd, intTy);
    217228    IntegerType * const sizeTy = getSizeTy();
    218229    size = CreateZExtOrTrunc(size, sizeTy);
     
    256267*/
    257268
    258 Value * CBuilder::CreateMMapAdvise(Value * addr, Value * length, std::initializer_list<MADV> advice) {
     269Value * CBuilder::CreateMAdvise(Value * addr, Value * length, std::initializer_list<MAdviceFlags> advice) {
    259270    Triple T(mMod->getTargetTriple());
    260271    Value * result = nullptr;
     
    272283        length = CreateZExtOrTrunc(length, sizeTy);
    273284        int adviceFlags = 0;
    274         for (const MADV adv : advice) {
     285        for (const MAdviceFlags adv : advice) {
    275286            switch (adv) {
    276                 case MADV::NORMAL: adviceFlags |= MADV_NORMAL; break;
    277                 case MADV::RANDOM: adviceFlags |= MADV_RANDOM; break;
    278                 case MADV::SEQUENTIAL: adviceFlags |= MADV_SEQUENTIAL; break;
    279                 case MADV::DONTNEED: adviceFlags |= MADV_DONTNEED; break;
    280                 case MADV::WILLNEED: adviceFlags |= MADV_WILLNEED; break;
     287                case MAdviceFlags::MMAP_NORMAL: adviceFlags |= MADV_NORMAL; break;
     288                case MAdviceFlags::MMAP_RANDOM: adviceFlags |= MADV_RANDOM; break;
     289                case MAdviceFlags::MMAP_SEQUENTIAL: adviceFlags |= MADV_SEQUENTIAL; break;
     290                case MAdviceFlags::MMAP_DONTNEED: adviceFlags |= MADV_DONTNEED; break;
     291                case MAdviceFlags::MMAP_WILLNEED: adviceFlags |= MADV_WILLNEED; break;
    281292//                case MADV::REMOVE: adviceFlags |= MADV_REMOVE; break;
    282293//                case MADV::DONTFORK: adviceFlags |= MADV_DONTFORK; break;
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5415 r5418  
    7575    llvm::Value * CreateOpenCall(llvm::Value * filename, llvm::Value * oflag, llvm::Value * mode);
    7676    //  Create a call to:  ssize_t write(int fildes, const void *buf, size_t nbyte);
    77     llvm::Value * CreateWriteCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
     77    llvm::Value * CreateWriteCall(llvm::Value * fileDescriptor, llvm::Value * buf, llvm::Value * nbyte);
    7878    //  Create a call to:  ssize_t read(int fildes, void *buf, size_t nbyte);
    79     llvm::Value * CreateReadCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
     79    llvm::Value * CreateReadCall(llvm::Value * fileDescriptor, llvm::Value * buf, llvm::Value * nbyte);
    8080    //  Create a call to:  int close(int filedes);
    81     llvm::Value * CreateCloseCall(llvm::Value * fildes);
     81    llvm::Value * CreateCloseCall(llvm::Value * fileDescriptor);
    8282    //  Create a call to:  int unlink(const char *path);
    8383    llvm::Value * CreateUnlinkCall(llvm::Value * path);
     84
     85    llvm::Value * CreateFileSize(llvm::Value * fileDescriptor);
    8486
    8587    //  Create calls to stdlib.h functions.
     
    9193    llvm::Value * CreateStrlenCall(llvm::Value * str);
    9294   
    93    
    94    
    9595    llvm::Value * CreateAnonymousMMap(llvm::Value * size);
    9696
    9797    llvm::Value * CreateFileSourceMMap(llvm::Value * fd, llvm::Value * size);
    9898
    99     enum class MADV {
    100         NORMAL
    101         , RANDOM
    102         , SEQUENTIAL
    103         , WILLNEED
    104         , DONTNEED
    105 //        , REMOVE
    106 //        , DONTFORK
    107 //        , DOFORK
    108 //        , HWPOISON
    109 //        , MERGEABLE
    110 //        , UNMERGEABLE
    111 //        , HUGEPAGE
    112 //        , NOHUGEPAGE
    113 //        , DONTDUMP
    114 //        , DODUMP
     99    enum MAdviceFlags {
     100        MMAP_NORMAL
     101        , MMAP_RANDOM
     102        , MMAP_SEQUENTIAL
     103        , MMAP_WILLNEED
     104        , MMAP_DONTNEED
    115105    };
    116106
    117     llvm::Value * CreateMMapAdvise(llvm::Value * addr, llvm::Value * length, MADV advice) {
    118         return CreateMMapAdvise(addr, length, { advice });
     107    llvm::Value * CreateMAdvise(llvm::Value * addr, llvm::Value * length, MAdviceFlags advice) {
     108        return CreateMAdvise(addr, length, { advice });
    119109    }
    120110
    121     llvm::Value * CreateMMapAdvise(llvm::Value * addr, llvm::Value * length, std::initializer_list<MADV> advice);
     111    llvm::Value * CreateMAdvise(llvm::Value * addr, llvm::Value * length, std::initializer_list<MAdviceFlags> advice);
    122112
    123113    llvm::Value * CreateMMap(llvm::Value * const addr, llvm::Value * size, llvm::Value * const prot, llvm::Value * const flags, llvm::Value * const fd, llvm::Value * const offset);
Note: See TracChangeset for help on using the changeset viewer.