Changeset 5841 for icGREP


Ignore:
Timestamp:
Jan 20, 2018, 10:17:47 PM (15 months ago)
Author:
cameron
Message:

LLVM_VERSION_CODE macro, CC-multiplex option, performance bug fixes

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

Legend:

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

    r5828 r5841  
    4141
    4242
    43 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     43#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    4444#define setReturnDoesNotAlias() setDoesNotAlias(0)
    4545#endif
     
    6262        isPoisoned->setCallingConv(CallingConv::C);
    6363        isPoisoned->setReturnDoesNotAlias();
    64         #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     64        #if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    6565        isPoisoned->setDoesNotAlias(1);
    6666        #endif
     
    183183        IntegerType * const int32Ty = getInt32Ty();
    184184        write = cast<Function>(m->getOrInsertFunction("write",
    185 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     185#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    186186        AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    187187#else
     
    205205        IntegerType * const int32Ty = getInt32Ty();
    206206        readFn = cast<Function>(m->getOrInsertFunction("read",
    207 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     207#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    208208        AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    209209#else
     
    419419            f->setCallingConv(CallingConv::C);
    420420            f->setReturnDoesNotAlias();
    421             #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     421            #if LLVM_VERSION_INTEGER <LLVM_VERSION_CODE(5, 0, 0)
    422422            f->setDoesNotAlias(1);
    423423            #endif
     
    455455        f->setCallingConv(CallingConv::C);
    456456        f->setReturnDoesNotAlias();
    457 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     457#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    458458        f->setDoesNotAlias(1);
    459459#endif
     
    984984            function = Function::Create(fty, Function::PrivateLinkage, "assert", m);
    985985            function->setDoesNotThrow();
    986 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     986#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    987987            function->setDoesNotAlias(2);
    988988#endif
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5839 r5841  
    11/*
    2  *  Copyright (c) 2015 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 *  icgrep is a trademark of International Characters.
     
    66
    77#include "idisa_avx_builder.h"
     8#include <toolchain/toolchain.h>
    89
    910using namespace llvm;
     
    102103   
    103104Value * IDISA_AVX2_Builder::esimd_mergeh(unsigned fw, Value * a, Value * b) {
    104 #if LLVM_VERSION_INTEGER < LLVM_6_0_0
     105#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(6, 0, 0)
    105106    if ((fw == 128) && (mBitBlockWidth == 256)) {
    106107        Value * vperm2i128func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_vperm2i128);
     
    113114
    114115Value * IDISA_AVX2_Builder::esimd_mergel(unsigned fw, Value * a, Value * b) {
    115 #if LLVM_VERSION_INTEGER < LLVM_6_0_0
     116#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(6, 0, 0)
    116117    if ((fw == 128) && (mBitBlockWidth == 256)) {
    117118        Value * vperm2i128func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_vperm2i128);
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.cpp

    r5733 r5841  
    263263    InlineAsm *IA = InlineAsm::get(AsmFnTy, AsmStream, "=r,r", true, false);
    264264    CallInst * result = CreateCall(IA, conv);
    265 #if LLVM_VERSION_INTEGER < LLVM_5_0_0
     265#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
    266266    result->addAttribute(AttributeSet::FunctionIndex, Attribute::NoUnwind);
    267267#else
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5837 r5841  
    5252static cl::opt<int> Threads("t", cl::desc("Total number of threads."), cl::init(2));
    5353static cl::opt<bool> PabloTransposition("enable-pablo-s2p", cl::desc("Enable experimental pablo transposition."));
     54static cl::opt<bool> CC_Multiplexing("CC-multiplexing", cl::desc("Enable CC multiplexing."), cl::init(true));
    5455
    5556namespace grep {
     
    149150        REs[i] = excludeUnicodeLineBreak(REs[i]);
    150151        REs[i] = regular_expression_passes(REs[i]);
    151 #define USE_MULTIPLEX_CC
    152 #ifdef USE_MULTIPLEX_CC
    153         const std::vector<const re::CC *> UnicodeSets = re::collectUnicodeSets(REs[i]);
    154 
    155         StreamSetBuffer * const MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    156         if (UnicodeSets.size() <= 1) {
     152        if (CC_Multiplexing) {
     153            const std::vector<const re::CC *> UnicodeSets = re::collectUnicodeSets(REs[i]);
     154
     155            StreamSetBuffer * const MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
     156            if (UnicodeSets.size() <= 1) {
     157                kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
     158                mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
     159                MatchResultsBufs[i] = MatchResults;
     160            } else {
     161                mpx = make_unique<MultiplexedAlphabet>("mpx", UnicodeSets);
     162                REs[i] = transformCCs(mpx.get(), REs[i]);
     163                std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
     164                auto numOfCharacterClasses = mpx_basis.size();
     165                StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
     166                kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
     167                mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
     168                kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i], std::vector<cc::Alphabet *>{mpx.get()});
     169                mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams, CharClasses}, {MatchResults});
     170                MatchResultsBufs[i] = MatchResults;
     171            }
     172        } else {
     173            StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    157174            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
    158175            mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
    159176            MatchResultsBufs[i] = MatchResults;
    160         } else {
    161             mpx = make_unique<MultiplexedAlphabet>("mpx", UnicodeSets);
    162             REs[i] = transformCCs(mpx.get(), REs[i]);
    163             std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
    164             auto numOfCharacterClasses = mpx_basis.size();
    165             StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
    166             kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
    167             mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});           
    168             kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i], std::vector<cc::Alphabet *>{mpx.get()});
    169             mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams, CharClasses}, {MatchResults});
    170             MatchResultsBufs[i] = MatchResults;
    171         }
    172 #else
    173         StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    174         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
    175         mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
    176         MatchResultsBufs[i] = MatchResults;
    177 #endif
     177        }
    178178    }
    179179    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5831 r5841  
    11/*
    2  *  Copyright (c) 2016-7 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 */
     
    1313#include <llvm/IR/Module.h>
    1414#include <llvm/Support/raw_ostream.h>
    15 #if LLVM_VERSION_INTEGER < LLVM_4_0_0
     15#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(4, 0, 0)
    1616#include <llvm/Bitcode/ReaderWriter.h>
    1717#else
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.h

    r5836 r5841  
    77
    88#include <pablo/pablo_kernel.h>  // for PabloKernel
    9 
    10 #define USE_DIRECT_LF_BUILDER
    119
    1210namespace kernel { class KernelBuilder; }
  • icGREP/icgrep-devel/icgrep/toolchain/NVPTXDriver.cpp

    r5731 r5841  
    2222#include <llvm/Support/ToolOutputFile.h>
    2323#include <llvm/Target/TargetMachine.h>
    24 #if LLVM_VERSION_INTEGER >= LLVM_3_9_0
     24#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 9, 0)
    2525#include <llvm/Transforms/Scalar/GVN.h>
    2626#endif
     
    4343    initializeLoopStrengthReducePass(*Registry);
    4444    initializeLowerIntrinsicsPass(*Registry);
    45 #if LLVM_VERSION_INTEGER < LLVM_3_9_0
     45#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(3, 9, 0)
    4646    initializeUnreachableBlockElimPass(*Registry);
    4747#else
  • icGREP/icgrep-devel/icgrep/toolchain/cpudriver.cpp

    r5793 r5841  
    1515#include <llvm/Target/TargetOptions.h>             // for TargetOptions
    1616#include <llvm/Transforms/Scalar.h>
    17 #if LLVM_VERSION_INTEGER >= LLVM_3_9_0
     17#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 9, 0)
    1818#include <llvm/Transforms/Scalar/GVN.h>
    1919#endif
     
    180180    }
    181181
    182 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
     182#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    183183    if (LLVM_UNLIKELY(codegen::ShowASMOption != codegen::OmittedOption)) {
    184184        if (codegen::ShowASMOption != "") {
  • icGREP/icgrep-devel/icgrep/toolchain/object_cache.cpp

    r5773 r5841  
    1616#include <boost/range/iterator_range.hpp>
    1717#include <boost/container/flat_set.hpp>
    18 #if LLVM_VERSION_INTEGER < LLVM_4_0_0
     18#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(4, 0, 0)
    1919#include <llvm/Bitcode/ReaderWriter.h>
    2020#else
     
    109109        auto kernelBuffer = MemoryBuffer::getFile(fileName.c_str(), -1, false);
    110110        if (kernelBuffer) {
    111             #if LLVM_VERSION_INTEGER < LLVM_4_0_0
     111            #if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(4, 0, 0)
    112112            auto loadedFile = getLazyBitcodeModule(std::move(kernelBuffer.get()), idb->getContext());
    113113            #else
     
    243243    // $HOME/.cache/parabix/
    244244    ParabixObjectCache::Path cachePath;
    245 #if LLVM_VERSION_INTEGER < LLVM_3_7_0
     245#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(3, 7, 0)
    246246    sys::path::user_cache_directory(cachePath, "parabix");
    247247#else
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.cpp

    r5840 r5841  
    4141                                                         cl::desc("Print generated LLVM IR to stderr (by omitting =<filename> or a file"), cl::value_desc("filename"), cl::cat(CodeGenOptions));
    4242
    43 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
     43#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    4444std::string ShowASMOption = OmittedOption;
    4545static cl::opt<std::string, true> ASMOutputFilenameOption("ShowASM", cl::location(ShowASMOption), cl::ValueOptional,
     
    150150    AddParabixVersionPrinter();
    151151    codegen::ProgramName = argv[0];
    152 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
     152#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    153153    if (hiding.size() != 0) {
    154154        cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>(hiding));
     
    162162    ObjectCacheDir = ObjectCacheDirOption.empty() ? nullptr : ObjectCacheDirOption.data();
    163163    Options = InitTargetOptionsFromCodeGenFlags();
    164 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
     164#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    165165    Options.MCOptions.AsmVerbose = true;
    166166#endif
     
    180180
    181181}
    182 #if LLVM_VERSION_INTEGER < LLVM_6_0_0
     182#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(6, 0, 0)
    183183void printParabixVersion () {
    184184    outs() << "Unicode version " << UCD::UnicodeVersion << "\n";
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.h

    r5793 r5841  
    1414
    1515// #defines for comparison with LLVM_VERSION_INTEGER
    16 #define LLVM_3_6_0 30600
    17 #define LLVM_3_7_0 30700
    18 #define LLVM_3_8_0 30800
    19 #define LLVM_3_9_0 30900
    20 #define LLVM_4_0_0 40000
    21 #define LLVM_5_0_0 50000
    22 #define LLVM_6_0_0 60000
     16#define LLVM_VERSION_CODE(major, minor, point) ((10000 * major) + (100 * minor) + point)
    2317
    2418// From LLVM 4.0.0 the clEnumValEnd sentinel is no longer needed.
    2519// We define a macro to adapt to the CommandLine syntax based on LLVM version.
    26 #if LLVM_VERSION_INTEGER < LLVM_4_0_0
     20#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(4, 0, 0)
    2721#define CL_ENUM_VAL_SENTINEL , clEnumValEnd
    2822#else
     
    6054extern std::string ShowUnoptimizedIROption;
    6155extern std::string ShowIROption;
    62 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
     56#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    6357extern std::string ShowASMOption;
    6458#endif
Note: See TracChangeset for help on using the changeset viewer.