Ignore:
Timestamp:
Mar 14, 2017, 7:06:06 PM (3 years ago)
Author:
cameron
Message:

Consolidate pipeline compiler options in toolchain

Location:
icGREP/icgrep-devel/icgrep
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/array-test.cpp

    r5361 r5364  
    154154    errors.allocateBuffer();
    155155
    156     generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &bm, &printer});
     156    generatePipeline(iBuilder, {&mmapK, &s2pk, &bm, &printer});
    157157    iBuilder->CreateRetVoid();
    158158
  • icGREP/icgrep-devel/icgrep/base64.cpp

    r5307 r5364  
    3030static cl::list<std::string> inputFiles(cl::Positional, cl::desc("<input file ...>"), cl::OneOrMore, cl::cat(base64Options));
    3131
    32 static cl::opt<bool> segmentPipelineParallel("enable-segment-pipeline-parallel", cl::desc("Enable multithreading with segment pipeline parallelism."), cl::cat(base64Options));
    3332static cl::opt<bool> mMapBuffering("mmap-buffering", cl::desc("Enable mmap buffering."), cl::cat(base64Options));
    3433static cl::opt<bool> memAlignBuffering("memalign-buffering", cl::desc("Enable posix_memalign buffering."), cl::cat(base64Options));
     
    9291    Base64out.allocateBuffer();
    9392
    94     if (segmentPipelineParallel) {
    95         generateSegmentParallelPipeline(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
    96     } else {
    97         generatePipelineLoop(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
    98     }
     93    generatePipeline(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
    9994
    10095    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5363 r5364  
    2020#include <kernels/streams_merge.h>
    2121#include <kernels/match_count.h>
    22 #include <kernels/pipeline.h>
    2322#include <kernels/mmap_kernel.h>
    2423#include <kernels/s2p_kernel.h>
     
    5857static cl::alias ShowLineNumbersLong("line-number", cl::desc("Alias for -n"), cl::aliasopt(ShowLineNumbers));
    5958
    60 static cl::opt<bool> pipelineParallel("enable-pipeline-parallel", cl::desc("Enable multithreading with pipeline parallelism."), cl::cat(bGrepOutputOptions));
    61 
    62 static cl::opt<bool> segmentPipelineParallel("enable-segment-pipeline-parallel", cl::desc("Enable multithreading with segment pipeline parallelism."), cl::cat(bGrepOutputOptions));
    63 
    6459bool isUTF_16 = false;
    6560std::string IRFilename = "icgrep.ll";
     
    247242    scanMatchK.setInitialArguments({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
    248243   
    249     generatePipelineLoop(iBuilder, {&mmapK1, &mmapK2, &scanMatchK});
     244    generatePipeline(iBuilder, {&mmapK1, &mmapK2, &scanMatchK});
    250245    iBuilder->CreateRetVoid();
    251246
     
    260255
    261256    const unsigned segmentSize = codegen::SegmentSize;
    262     const unsigned bufferSegments = segmentPipelineParallel ? (codegen::BufferSegments * codegen::ThreadNum) : codegen::BufferSegments;
     257    const unsigned bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
    263258    const unsigned encodingBits = UTF_16 ? 16 : 8;
    264259
     
    335330        KernelList.push_back(&matchCountK); 
    336331
    337         if (pipelineParallel){
    338             generateParallelPipeline(iBuilder, KernelList);
    339         } else if (segmentPipelineParallel){
    340             generateSegmentParallelPipeline(iBuilder, KernelList);
    341         }  else{
    342             generatePipelineLoop(iBuilder, KernelList);
    343         }
     332        generatePipeline(iBuilder, KernelList);
    344333        iBuilder->CreateRet(matchCountK.getScalarField(matchCountK.getInstance(), "matchedLineCount"));
    345334
     
    351340        KernelList.push_back(&scanMatchK);
    352341
    353         if (pipelineParallel) {
    354             generateParallelPipeline(iBuilder, KernelList);
    355         } else if (segmentPipelineParallel) {
    356             generateSegmentParallelPipeline(iBuilder, KernelList);
    357         } else {
    358             generatePipelineLoop(iBuilder, KernelList);
    359         }
     342        generatePipeline(iBuilder, KernelList);
    360343       
    361344        iBuilder->CreateRetVoid();
     
    413396    // segment size made availabe for each call to the mmap source kernel
    414397    const unsigned segmentSize = codegen::SegmentSize;
    415     const unsigned bufferSegments = segmentPipelineParallel ? (codegen::BufferSegments * codegen::ThreadNum) : codegen::BufferSegments;
     398    const unsigned bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
    416399    const unsigned encodingBits = UTF_16 ? 16 : 8;
    417400
     
    497480    if (CountOnly) {
    498481        icgrepK.generateKernel({&BasisBits, &LineBreakStream}, {});
    499         if (pipelineParallel) {
    500             generateParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    501         } else if (segmentPipelineParallel) {
    502             generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    503         } else {
    504             generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    505         }
     482        generatePipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    506483        iBuilder->CreateRet(icgrepK.createGetAccumulatorCall(icgrepK.getInstance(), "matchedLineCount"));
    507484    } else {
     
    526503            scanMatchK.setInitialArguments({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
    527504           
    528             if (pipelineParallel) {
    529                 generateParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    530             } else if (segmentPipelineParallel) {
    531                 generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    532             } else {
    533                 generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    534             }
     505            generatePipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    535506        }
    536507        iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5363 r5364  
    227227
    228228void generateSegmentParallelPipeline(IDISA::IDISA_Builder * iBuilder, const std::vector<KernelBuilder *> & kernels) {
    229    
    230     const unsigned threadNum = codegen::ThreadNum;
    231    
     229       
    232230    Module * m = iBuilder->getModule();
    233231   
     
    240238    ProducerTable producerTable = createProducerTable(kernels);
    241239   
    242     Type * const pthreadsTy = ArrayType::get(size_ty, threadNum);
     240    Type * const pthreadsTy = ArrayType::get(size_ty, codegen::ThreadNum);
    243241    AllocaInst * const pthreads = iBuilder->CreateAlloca(pthreadsTy);
    244242    std::vector<Value *> pthreadsPtrs;
    245     for (unsigned i = 0; i < threadNum; i++) {
     243    for (unsigned i = 0; i < codegen::ThreadNum; i++) {
    246244        pthreadsPtrs.push_back(iBuilder->CreateGEP(pthreads, {iBuilder->getInt32(0), iBuilder->getInt32(i)}));
    247245    }
     
    266264    std::vector<Function *> thread_functions;
    267265    const auto ip = iBuilder->saveIP();
    268     for (unsigned i = 0; i < threadNum; i++) {
     266    for (unsigned i = 0; i < codegen::ThreadNum; i++) {
    269267        thread_functions.push_back(generateSegmentParallelPipelineThreadFunction("thread"+std::to_string(i), iBuilder, kernels, sharedStructType, producerTable, i));
    270268    }
    271269    iBuilder->restoreIP(ip);
    272270   
    273     for (unsigned i = 0; i < threadNum; i++) {
     271    for (unsigned i = 0; i < codegen::ThreadNum; i++) {
    274272        iBuilder->CreatePThreadCreateCall(pthreadsPtrs[i], nullVal, thread_functions[i], iBuilder->CreateBitCast(sharedStruct, int8PtrTy));
    275273    }
    276274   
    277275    std::vector<Value *> threadIDs;
    278     for (unsigned i = 0; i < threadNum; i++) {
     276    for (unsigned i = 0; i < codegen::ThreadNum; i++) {
    279277        threadIDs.push_back(iBuilder->CreateLoad(pthreadsPtrs[i]));
    280278    }
    281279   
    282     for (unsigned i = 0; i < threadNum; i++) {
     280    for (unsigned i = 0; i < codegen::ThreadNum; i++) {
    283281        iBuilder->CreatePThreadJoinCall(threadIDs[i], status);
    284282    }
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5361 r5364  
    2323#include <llvm/Transforms/Utils/Local.h>
    2424#include <object_cache.h>
     25#include <kernels/pipeline.h>
    2526#ifdef CUDA_ENABLED
    2627#include <IR_Gen/llvm2ptx.h>
     
    7980
    8081bool DebugOptionIsSet(DebugFlags flag) {return DebugOptions.isSet(flag);}
     82
     83static cl::opt<bool> pipelineParallel("enable-pipeline-parallel", cl::desc("Enable multithreading with pipeline parallelism."), cl::cat(CodeGenOptions));
     84   
     85static cl::opt<bool> segmentPipelineParallel("enable-segment-pipeline-parallel", cl::desc("Enable multithreading with segment pipeline parallelism."), cl::cat(CodeGenOptions));
     86   
    8187
    8288   
     
    239245}
    240246
    241 
     247void generatePipeline(IDISA::IDISA_Builder * iBuilder, const std::vector<kernel::KernelBuilder *> & kernels) {
     248    if (codegen::pipelineParallel) {
     249        generateParallelPipeline(iBuilder, kernels);
     250    } else if (codegen::segmentPipelineParallel) {
     251        generateSegmentParallelPipeline(iBuilder, kernels);
     252    } else {
     253        codegen::ThreadNum = 1;
     254        generatePipelineLoop(iBuilder, kernels);
     255    }
     256}
     257
     258
  • icGREP/icgrep-devel/icgrep/toolchain.h

    r5347 r5364  
    88#define TOOLCHAIN_H
    99#include <string>
     10#include <IR_Gen/idisa_builder.h>
     11
    1012namespace llvm { class ExecutionEngine; }
    1113namespace llvm { class Module; }
    1214namespace llvm { namespace cl { class OptionCategory; } }
     15namespace IDISA { class IDISA_Builder; }
     16namespace kernel { class KernelBuilder; }
    1317
    1418namespace codegen {
     
    5054void ApplyObjectCache(llvm::ExecutionEngine * e);
    5155
     56void generatePipeline(IDISA::IDISA_Builder * iBuilder, const std::vector<kernel::KernelBuilder *> & kernels);
     57
    5258#endif
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5362 r5364  
    4646static cl::opt<std::string> inputFile(cl::Positional, cl::desc("<input file>"), cl::Required, cl::cat(u8u16Options));
    4747static cl::opt<std::string> outputFile(cl::Positional, cl::desc("<output file>"),  cl::Required, cl::cat(u8u16Options));
    48 static cl::opt<bool> segmentPipelineParallel("enable-segment-pipeline-parallel", cl::desc("Enable multithreading with segment pipeline parallelism."), cl::cat(u8u16Options));
    4948static cl::opt<bool> enableAVXdel("enable-AVX-deletion", cl::desc("Enable AVX2 deletion algorithms."), cl::cat(u8u16Options));
    5049static cl::opt<bool> mMapBuffering("mmap-buffering", cl::desc("Enable mmap buffering."), cl::cat(u8u16Options));
     
    376375    outK.setInitialArguments({fName});
    377376
    378     if (segmentPipelineParallel){
    379         generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &compressK, &unSwizzleK, &p2sk, &outK});
    380     } else {
    381         generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &compressK, &unSwizzleK, &p2sk, &outK});
    382     }
     377    generatePipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &compressK, &unSwizzleK, &p2sk, &outK});
    383378
    384379    iBuilder->CreateRetVoid();
     
    475470    outK.setInitialArguments({fName});
    476471   
    477     if (segmentPipelineParallel){
    478         generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
    479     } else {
    480         generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
    481     }
     472    generatePipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
    482473   
    483474    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5329 r5364  
    173173    BasisBits.allocateBuffer();
    174174   
    175     generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &wck});
     175    generatePipeline(iBuilder, {&mmapK, &s2pk, &wck});
    176176   
    177177    Value * lineCount = wck.createGetAccumulatorCall(wck.getInstance(), "lineCount");
Note: See TracChangeset for help on using the changeset viewer.