Ignore:
Timestamp:
Sep 12, 2016, 2:47:27 PM (3 years ago)
Author:
cameron
Message:

Fix for -gs mode from Xiangyu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5142 r5154  
    3535#include <kernels/deletion.h>
    3636#include <kernels/stdout_kernel.h>
     37#include <llvm/IR/TypeBuilder.h>
    3738
    3839
     
    4647
    4748static cl::list<std::string> inputFiles(cl::Positional, cl::desc("<input file ...>"), cl::OneOrMore, cl::cat(u8u16Options));
     49
     50static cl::opt<bool> pipelineParallel("enable-pipeline-parallel", cl::desc("Enable multithreading with pipeline parallelism."), cl::cat(u8u16Options));
    4851
    4952//
     
    225228    Type * mBitBlockType = iBuilder->getBitBlockType();
    226229
     230    const unsigned segmentSize = codegen::SegmentSize;
     231    const unsigned bufferSegments = codegen::BufferSegments;
    227232   
    228233    ExternalFileBuffer ByteStream(iBuilder, StreamSetType(1, i8));
    229     SingleBlockBuffer BasisBits(iBuilder, StreamSetType(8, i1));
    230     SingleBlockBuffer U8u16Bits(iBuilder, StreamSetType(18, i1));
    231     SingleBlockBuffer U16Bits(iBuilder, StreamSetType(16, i1));
    232     SingleBlockBuffer DeletionCounts(iBuilder, StreamSetType(1, i1));
     234    //SingleBlockBuffer BasisBits(iBuilder, StreamSetType(8, i1));
     235    CircularBuffer BasisBits(iBuilder, StreamSetType(8, i1), segmentSize * bufferSegments);
     236
     237    //SingleBlockBuffer U8u16Bits(iBuilder, StreamSetType(18, i1));
     238    CircularBuffer U8u16Bits(iBuilder, StreamSetType(18, i1), segmentSize * bufferSegments);
     239
     240    //SingleBlockBuffer U16Bits(iBuilder, StreamSetType(16, i1));
     241    CircularBuffer U16Bits(iBuilder, StreamSetType(16, i1), segmentSize * bufferSegments);
     242   
     243    //SingleBlockBuffer DeletionCounts(iBuilder, StreamSetType(1, i1));
     244    CircularBuffer DeletionCounts(iBuilder, StreamSetType(1, i1), segmentSize * bufferSegments);
     245   
    233246    CircularBuffer U16out(iBuilder, StreamSetType(1, i16), u16OutputBlocks);
    234247
     
    249262    Type * const voidTy = Type::getVoidTy(mMod->getContext());
    250263    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
     264    Type * const int32ty = iBuilder->getInt32Ty();
     265    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
     266    Type * const voidPtrTy = TypeBuilder<void *, false>::get(mMod->getContext());
     267
    251268   
    252269    Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", voidTy, inputType, size_ty, nullptr));
     
    274291    Value * p2sInstance = p2sk.createInstance({});
    275292   
    276     generatePipelineLoop(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk}, {s2pInstance, u8u16Instance, delInstance, p2sInstance}, fileSize);
    277    
     293    Type * pthreadTy = size_ty;
     294    FunctionType * funVoidPtrVoidTy = FunctionType::get(voidTy, int8PtrTy, false);
     295   
     296    Function * pthreadCreateFunc = cast<Function>(mMod->getOrInsertFunction("pthread_create",
     297                                                                         int32ty,
     298                                                                         pthreadTy->getPointerTo(),
     299                                                                         voidPtrTy,
     300                                                                         static_cast<Type *>(funVoidPtrVoidTy)->getPointerTo(),
     301                                                                         voidPtrTy, nullptr));
     302    pthreadCreateFunc->setCallingConv(llvm::CallingConv::C);
     303    Function * pthreadJoinFunc = cast<Function>(mMod->getOrInsertFunction("pthread_join",
     304                                                                       int32ty,
     305                                                                       pthreadTy,
     306                                                                       PointerType::get(int8PtrTy, 0), nullptr));
     307    pthreadJoinFunc->setCallingConv(llvm::CallingConv::C);
     308   
     309    Function * pthreadExitFunc = cast<Function>(mMod->getOrInsertFunction("pthread_exit",
     310                                                                       voidTy,
     311                                                                       voidPtrTy, nullptr));
     312    pthreadExitFunc->addFnAttr(llvm::Attribute::NoReturn);
     313    pthreadExitFunc->setCallingConv(llvm::CallingConv::C);
     314
     315    if (pipelineParallel){
     316        generatePipelineParallel(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk}, {s2pInstance, u8u16Instance, delInstance, p2sInstance});
     317    }
     318    else{
     319        generatePipelineLoop(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk}, {s2pInstance, u8u16Instance, delInstance, p2sInstance}, fileSize);
     320    }
     321
    278322    iBuilder->CreateRetVoid();
    279323    return main;
Note: See TracChangeset for help on using the changeset viewer.