Changeset 5240


Ignore:
Timestamp:
Dec 28, 2016, 7:21:28 PM (12 months ago)
Author:
nmedfort
Message:

Cleaned up memory leaks + some warning messages.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5239 r5240  
    1010option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
    1111option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
    12 
     12option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
    1313find_package(LLVM REQUIRED CONFIG)
    1414
    15 message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
    16 message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
     15message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
    1716set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
    1817
     
    135134ENDIF()
    136135
     136#Disable Dual ABI support
     137IF(DISABLE_DUAL_ABI)
     138SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
     139ENDIF()
     140
    137141#Enable all warnings
    138142SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
     
    156160
    157161SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
    158 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g") #  -fsanitize=address -fno-omit-frame-pointer
     162SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer") #
    159163
    160164add_test(
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5239 r5240  
    389389}
    390390
    391 }
     391IDISA_Builder::IDISA_Builder(Module * m, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride, unsigned CacheAlignment)
     392: CBuilder(m, archBitWidth, CacheAlignment)
     393, mBitBlockWidth(bitBlockWidth)
     394, mStride(stride)
     395, mBitBlockType(VectorType::get(IntegerType::get(getContext(), 64), bitBlockWidth / 64))
     396, mZeroInitializer(Constant::getNullValue(mBitBlockType))
     397, mOneInitializer(Constant::getAllOnesValue(mBitBlockType))
     398, mPrintRegisterFunction(nullptr) {
     399
     400}
     401
     402IDISA_Builder::~IDISA_Builder() {
     403    for (const auto t : mStreamTypes) {
     404        delete std::get<1>(t);
     405    }
     406    mStreamTypes.clear();
     407}
     408
     409}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r5239 r5240  
    2828public:
    2929
    30     IDISA_Builder(Module * m, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride, unsigned CacheAlignment=64)
    31     : CBuilder(m, archBitWidth, CacheAlignment)
    32     , mBitBlockWidth(bitBlockWidth)
    33     , mStride(stride)
    34     , mBitBlockType(VectorType::get(IntegerType::get(getContext(), 64), bitBlockWidth / 64))
    35     , mZeroInitializer(Constant::getNullValue(mBitBlockType))
    36     , mOneInitializer(Constant::getAllOnesValue(mBitBlockType))
    37     , mPrintRegisterFunction(nullptr) {
     30    IDISA_Builder(Module * m, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride, unsigned CacheAlignment=64);
    3831
    39     }
    40 
    41     virtual ~IDISA_Builder() {}
     32    virtual ~IDISA_Builder();
    4233   
    4334    std::string getBitBlockTypeName() const;  // A short string such as v4i64 or i256.
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.cpp

    r5227 r5240  
    4040template <> inline int scan_forward_zeroes<unsigned long long>(unsigned long long x){return __builtin_ctzll(x);}
    4141
    42 
    43 
    44 UnicodeSet::RunAllocator UnicodeSet::mRunAllocator;
    45 UnicodeSet::QuadAllocator UnicodeSet::mQuadAllocator;
     42SlabAllocator<> UnicodeSet::mAllocator;
    4643
    4744const uint64_t QUAD_BITS = (8 * sizeof(bitquad_t));
     
    773770 ** ------------------------------------------------------------------------------------------------------------- */
    774771UnicodeSet::UnicodeSet()
    775 : mRuns(mRunAllocator)
    776 , mQuads(mQuadAllocator)
     772: mRuns(mAllocator)
     773, mQuads(mAllocator)
    777774{
    778775    append_run(Empty, UNICODE_QUAD_COUNT, mRuns);
     
    784781 ** ------------------------------------------------------------------------------------------------------------- */
    785782UnicodeSet::UnicodeSet(const codepoint_t codepoint)
    786 : mRuns(mRunAllocator)
    787 , mQuads(mQuadAllocator)
     783: mRuns(mAllocator)
     784, mQuads(mAllocator)
    788785{
    789786    const codepoint_t quad_no = codepoint / QUAD_BITS;
     
    798795 ** ------------------------------------------------------------------------------------------------------------- */
    799796UnicodeSet::UnicodeSet(const codepoint_t lo, const codepoint_t hi)
    800 : mRuns(mRunAllocator)
    801 , mQuads(mQuadAllocator)
     797: mRuns(mAllocator)
     798, mQuads(mAllocator)
    802799{
    803800    const codepoint_t lo_index = lo / QUAD_BITS;
     
    879876 ** ------------------------------------------------------------------------------------------------------------- */
    880877UnicodeSet::UnicodeSet(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end)
    881 : mRuns(0, {Empty, 0}, mRunAllocator)
    882 , mQuads(0, 0, mQuadAllocator)
    883 {
     878: mRuns(0, {Empty, 0}, mAllocator)
     879, mQuads(0, 0, mAllocator) {
    884880    convertIntervalRangesToSparseSet(begin, end, mRuns, mQuads);
    885881}
     
    889885 ** ------------------------------------------------------------------------------------------------------------- */
    890886UnicodeSet::UnicodeSet(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end)
    891 : mRuns(0, {Empty, 0}, mRunAllocator)
    892 , mQuads(0, 0, mQuadAllocator)
    893 {
     887: mRuns(0, {Empty, 0}, mAllocator)
     888, mQuads(0, 0, mAllocator) {
    894889    convertIntervalRangesToSparseSet(begin, end, mRuns, mQuads);
    895890}
     
    899894 ** ------------------------------------------------------------------------------------------------------------- */
    900895UnicodeSet::UnicodeSet(const UnicodeSet & other)
    901 : mRuns(other.mRuns, mRunAllocator)
    902 , mQuads(other.mQuads, mQuadAllocator)
    903 {
     896: mRuns(other.mRuns, mAllocator)
     897, mQuads(other.mQuads, mAllocator) {
    904898    assert (verify(mRuns, mQuads));
    905899}
     
    909903 ** ------------------------------------------------------------------------------------------------------------- */
    910904UnicodeSet::UnicodeSet(std::initializer_list<run_t> r, std::initializer_list<bitquad_t> q)
    911 : mRuns(r.begin(), r.end(), mRunAllocator)
    912 , mQuads(q.begin(), q.end(), mQuadAllocator)
    913 {
     905: mRuns(r.begin(), r.end(), mAllocator)
     906, mQuads(q.begin(), q.end(), mAllocator) {
    914907    assert (verify(mRuns, mQuads));
    915908}
     
    919912 ** ------------------------------------------------------------------------------------------------------------- */
    920913inline UnicodeSet::UnicodeSet(std::vector<run_t> && r, std::vector<bitquad_t> && q)
    921 : mRuns(r.begin(), r.end(), mRunAllocator)
    922 , mQuads(q.begin(), q.end(), mQuadAllocator)
    923 {
     914: mRuns(r.begin(), r.end(), mAllocator)
     915, mQuads(q.begin(), q.end(), mAllocator) {
    924916    assert (verify(mRuns, mQuads));
    925917}
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.h

    r5037 r5240  
    4949    using interval_t = std::pair<codepoint_t, codepoint_t>;
    5050
    51     using RunAllocator = SlabAllocator<run_t>;
    52     using QuadAllocator = SlabAllocator<bitquad_t>;
    53 
    54     using RunVector = std::vector<run_t, RunAllocator>;
    55     using QuadVector = std::vector<bitquad_t, QuadAllocator>;
     51    using RunVector = std::vector<run_t, ProxyAllocator<run_t>>;
     52    using QuadVector = std::vector<bitquad_t, ProxyAllocator<bitquad_t>>;
    5653    using RunIterator = RunVector::const_iterator;
    5754    using QuadIterator = QuadVector::const_iterator;
     
    197194    RunVector               mRuns;
    198195    QuadVector              mQuads;
    199     static RunAllocator     mRunAllocator;
    200     static QuadAllocator    mQuadAllocator;
     196    static SlabAllocator<>  mAllocator;
    201197};
    202198
  • icGREP/icgrep-devel/icgrep/base64.cpp

    r5238 r5240  
    2929#include <kernels/radix64.h>
    3030#include <kernels/stdout_kernel.h>
    31 #include <llvm/IR/TypeBuilder.h>
    3231
    3332
     
    8382    Type * const int32ty = iBuilder->getInt32Ty();
    8483    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    85     Type * const voidPtrTy = TypeBuilder<void *, false>::get(mMod->getContext());
     84    Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    8685
    8786   
     
    168167    size_t mFileSize;
    169168    char * mFileBuffer;
    170    
     169
    171170    const boost::filesystem::path file(mFileName);
    172171    if (exists(file)) {
     
    203202    else if (memAlignBuffering) {
    204203        char * outputBuffer;
    205         posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*mFileSize);
     204        if (posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*mFileSize)) {
     205            throw std::bad_alloc();
     206        }
    206207        fn_ptr(mFileBuffer, outputBuffer, mFileSize);
    207208        free(reinterpret_cast<void *>(outputBuffer));
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5238 r5240  
    7979void run_second_filter(int total_len, int pattern_segs, float errRate){
    8080   
    81     if(matchList.size() == 0) return;
     81    if(matchList.empty()) return;
    8282
    8383    //remove the duplicates
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.cpp

    r5238 r5240  
    8181    Function * bidFunc = cast<Function>(m->getOrInsertFunction("llvm.nvvm.read.ptx.sreg.ctaid.x", int32ty, nullptr));
    8282    Value * bid = iBuilder->CreateCall(bidFunc);
    83     Value * pattStartPtr = iBuilder->CreateGEP(pattBuf, {iBuilder->CreateMul(pattLen, bid)});
    84     Value * pattPtr = iBuilder->CreateGEP(pattStartPtr, {pattPos});
     83    Value * pattStartPtr = iBuilder->CreateGEP(pattBuf, iBuilder->CreateMul(pattLen, bid));
     84    Value * pattPtr = iBuilder->CreateGEP(pattStartPtr, pattPos);
    8585    Value * pattCh = iBuilder->CreateLoad(pattPtr);
    8686    Value * pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
     
    9595
    9696    for(unsigned i = 1; i<mPatternLen; i++){     
    97         pattPtr = iBuilder->CreateGEP(pattStartPtr, {pattPos});
     97        pattPtr = iBuilder->CreateGEP(pattStartPtr, pattPos);
    9898        pattCh = iBuilder->CreateLoad(pattPtr);
    9999        pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5238 r5240  
    446446}
    447447
    448 GrepEngine::~GrepEngine() {
    449 //    delete mEngine;
    450 }
    451 
    452448static int * total_count;
    453449static std::stringstream * resultStrs = nullptr;
     
    617613}
    618614
     615GrepEngine::GrepEngine()
     616: mGrepFunction(nullptr)
     617, mGrepFunction_CountOnly(nullptr)
     618, mGrepFunction_CPU(nullptr)
     619, mGrepType(GrepType::Normal)
     620, mEngine(nullptr) {
     621
     622}
     623
     624GrepEngine::~GrepEngine() {
     625    delete mEngine;
     626}
  • icGREP/icgrep-devel/icgrep/grep_engine.h

    r5234 r5240  
    2424public:
    2525
    26     GrepEngine() {}
    27 
     26    GrepEngine();
    2827    ~GrepEngine();
    2928 
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r5238 r5240  
    575575base64.cpp
    576576util/aligned_allocator.h
     577cc/cc_compiler.cpp
     578cc/cc_compiler.h
     579editd/editd.cpp
     580editd/editd_cpu_kernel.cpp
     581editd/editd_cpu_kernel.h
     582editd/editd_gpu_kernel.cpp
     583editd/editd_gpu_kernel.h
     584editd/EditdCudaDriver.h
     585editd/editdscan_kernel.cpp
     586editd/editdscan_kernel.h
     587editd/pattern_compiler.cpp
     588editd/pattern_compiler.h
     589IR_Gen/types/streamtype.cpp
     590IR_Gen/types/streamtype.h
     591IR_Gen/CBuilder.cpp
     592IR_Gen/CBuilder.h
     593IR_Gen/CudaDriver.h
     594IR_Gen/idisa_avx_builder.cpp
     595IR_Gen/idisa_avx_builder.h
     596IR_Gen/idisa_builder.cpp
     597IR_Gen/idisa_builder.h
     598IR_Gen/idisa_i64_builder.cpp
     599IR_Gen/idisa_i64_builder.h
     600IR_Gen/idisa_nvptx_builder.cpp
     601IR_Gen/idisa_nvptx_builder.h
     602IR_Gen/idisa_sse_builder.cpp
     603IR_Gen/idisa_sse_builder.h
     604IR_Gen/idisa_target.cpp
     605IR_Gen/idisa_target.h
     606IR_Gen/llvm2ptx.h
     607kernels/cc_kernel.cpp
     608kernels/cc_kernel.h
     609kernels/deletion.cpp
     610kernels/deletion.h
     611kernels/interface.cpp
     612kernels/interface.h
     613kernels/kernel.cpp
     614kernels/kernel.h
     615kernels/p2s_kernel.cpp
     616kernels/p2s_kernel.h
     617kernels/pipeline.cpp
     618kernels/pipeline.h
     619kernels/radix64.cpp
     620kernels/radix64.h
     621kernels/s2p_kernel.cpp
     622kernels/s2p_kernel.h
     623kernels/scanmatchgen.cpp
     624kernels/scanmatchgen.h
     625kernels/stdout_kernel.cpp
     626kernels/stdout_kernel.h
     627kernels/streamset.cpp
     628kernels/streamset.h
     629kernels/symboltablepipeline.cpp
     630kernels/symboltablepipeline.h
     631pablo/analysis/pabloverifier.cpp
     632pablo/analysis/pabloverifier.hpp
     633pablo/optimizers/booleanreassociationpass.cpp
     634pablo/optimizers/booleanreassociationpass.h
     635pablo/optimizers/codemotionpass.cpp
     636pablo/optimizers/codemotionpass.h
     637pablo/optimizers/distributivepass.cpp
     638pablo/optimizers/distributivepass.h
     639pablo/optimizers/graph-facade.hpp
     640pablo/optimizers/maxsat.hpp
     641pablo/optimizers/pablo_automultiplexing.cpp
     642pablo/optimizers/pablo_automultiplexing.hpp
     643pablo/optimizers/pablo_bddminimization.cpp
     644pablo/optimizers/pablo_bddminimization.h
     645pablo/optimizers/pablo_simplifier.cpp
     646pablo/optimizers/pablo_simplifier.hpp
     647pablo/optimizers/schedulingprepass.cpp
     648pablo/optimizers/schedulingprepass.h
     649pablo/passes/factorizedfg.cpp
     650pablo/passes/factorizedfg.h
     651pablo/passes/flattenassociativedfg.cpp
     652pablo/passes/flattenassociativedfg.h
     653pablo/passes/flattenif.cpp
     654pablo/passes/flattenif.hpp
     655pablo/arithmetic.h
     656pablo/boolean.h
     657pablo/branch.cpp
     658pablo/branch.h
     659pablo/builder.cpp
     660pablo/builder.hpp
     661pablo/carry_data.h
     662pablo/carry_manager.cpp
     663pablo/carry_manager.h
     664pablo/codegenstate.cpp
     665pablo/codegenstate.h
     666pablo/expression_map.hpp
     667pablo/pablo_compiler.cpp
     668pablo/pablo_compiler.h
     669pablo/pablo_kernel.cpp
     670pablo/pablo_kernel.h
     671pablo/pablo_toolchain.cpp
     672pablo/pablo_toolchain.h
     673pablo/pabloAST.cpp
     674pablo/pabloAST.h
     675pablo/pe_advance.h
     676pablo/pe_call.h
     677pablo/pe_constant.h
     678pablo/pe_count.h
     679pablo/pe_infile.h
     680pablo/pe_integer.h
     681pablo/pe_lookahead.h
     682pablo/pe_matchstar.h
     683pablo/pe_ones.h
     684pablo/pe_scanthru.h
     685pablo/pe_setithbit.h
     686pablo/pe_string.h
     687pablo/pe_var.h
     688pablo/pe_zeroes.h
     689pablo/printer_pablos.cpp
     690pablo/printer_pablos.h
     691pablo/prototype.cpp
     692pablo/prototype.h
     693pablo/ps_assign.h
     694pablo/symbol_generator.cpp
     695pablo/symbol_generator.h
     696re/printer_re.cpp
     697re/printer_re.h
     698re/re_alt.h
     699re/re_analysis.cpp
     700re/re_analysis.h
     701re/re_any.h
     702re/re_assertion.h
     703re/re_cc.cpp
     704re/re_cc.h
     705re/re_compiler.cpp
     706re/re_compiler.h
     707re/re_diff.cpp
     708re/re_diff.h
     709re/re_end.h
     710re/re_intersect.cpp
     711re/re_intersect.h
     712re/re_memoizer.hpp
     713re/re_name.h
     714re/re_name_resolve.cpp
     715re/re_name_resolve.h
     716re/re_nullable.cpp
     717re/re_nullable.h
     718re/re_parser.cpp
     719re/re_parser.h
     720re/re_parser_bre.cpp
     721re/re_parser_bre.h
     722re/re_parser_ere.cpp
     723re/re_parser_ere.h
     724re/re_parser_helper.h
     725re/re_parser_pcre.cpp
     726re/re_parser_pcre.h
     727re/re_parser_prosite.cpp
     728re/re_parser_prosite.h
     729re/re_re.cpp
     730re/re_re.h
     731re/re_rep.cpp
     732re/re_rep.h
     733re/re_seq.h
     734re/re_simplifier.cpp
     735re/re_simplifier.h
     736re/re_start.h
     737re/re_toolchain.cpp
     738re/re_toolchain.h
     739re/re_utility.cpp
     740re/re_utility.h
     741UCD/Blocks.h
     742UCD/CaseFolding_txt.cpp
     743UCD/CaseFolding_txt.h
     744UCD/DerivedAge.h
     745UCD/DerivedBidiClass.h
     746UCD/DerivedBinaryProperties.h
     747UCD/DerivedCombiningClass.h
     748UCD/DerivedCoreProperties.h
     749UCD/DerivedDecompositionType.h
     750UCD/DerivedGeneralCategory.h
     751UCD/DerivedJoiningGroup.h
     752UCD/DerivedJoiningType.h
     753UCD/DerivedNormalizationProps.h
     754UCD/DerivedNumericType.h
     755UCD/EastAsianWidth.h
     756UCD/GraphemeBreakProperty.h
     757UCD/HangulSyllableType.h
     758UCD/LineBreak.h
     759UCD/PropertyAliases.h
     760UCD/PropertyObjects.cpp
     761UCD/PropertyObjects.h
     762UCD/PropertyObjectTable.h
     763UCD/PropertyValueAliases.h
     764UCD/PropList.h
     765UCD/resolve_properties.cpp
     766UCD/resolve_properties.h
     767UCD/ScriptExtensions.h
     768UCD/Scripts.h
     769UCD/SentenceBreakProperty.h
     770UCD/ucd_compiler.cpp
     771UCD/ucd_compiler.hpp
     772UCD/unicode_set.cpp
     773UCD/unicode_set.h
     774UCD/UnicodeNameData.cpp
     775UCD/UnicodeNameData.h
     776UCD/WordBreakProperty.h
     777util/aligned_allocator.h
     778util/papi_helper.hpp
     779util/slab_allocator.h
     780array-test.cpp
     781base64.cpp
     782generate_predefined_ucd_functions.cpp
     783grep_engine.cpp
     784grep_engine.h
     785grep_type.h
     786hrtime.h
     787icgrep.cpp
     788object_cache.cpp
     789object_cache.h
     790symboltable.cpp
     791toolchain.cpp
     792toolchain.h
     793u8u16.cpp
     794utf16_encoder.cpp
     795utf16_encoder.h
     796utf8_encoder.cpp
     797utf8_encoder.h
     798wc.cpp
  • icGREP/icgrep-devel/icgrep/icgrep-devel.includes

    r5217 r5240  
    66pablo/optimizers
    77UCD
    8 /usr/include/boost/filesystem
    9 /usr/include/boost/iostreams
    10 /usr/include/boost/system
     8/usr/include/
     9../boost/include/
    1110../cudd-2.5.1/cudd
    1211../buddy-2.4/src
     
    2625kernels/type
    2726IDISA/types
     27IR_Gen
     28IR_Gen/types
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5238 r5240  
    5454    virtual llvm::Value * getProducedItemCount(llvm::Value * kernelInstance) override;
    5555    virtual void initializeKernelState(Value * self);
    56     llvm::Value * getTerminationSignal(llvm::Value * kernelInstance);
     56    llvm::Value * getTerminationSignal(llvm::Value * kernelInstance) override;
    5757   
    5858    inline llvm::IntegerType * getSizeTy() {
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5238 r5240  
    142142    iBuilder->CreateAlignedStore(expand0, loopOutput_ptr, packAlign);
    143143    // Step 2 of the main loop.
    144     Value * inPack1_ptr = iBuilder->CreateGEP(loopInput_ptr, {iBuilder->getInt32(1)});
    145     Value * outPack1_ptr = iBuilder->CreateGEP(loopOutput_ptr, {iBuilder->getInt32(1)});
     144    Value * inPack1_ptr = iBuilder->CreateGEP(loopInput_ptr, iBuilder->getInt32(1));
     145    Value * outPack1_ptr = iBuilder->CreateGEP(loopOutput_ptr, iBuilder->getInt32(1));
    146146    Value * pack1 = iBuilder->fwCast(8, iBuilder->CreateAlignedLoad(inPack1_ptr, packAlign));
    147147    Value * expand1 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack0, pack1, expand_3_4_shuffle[1]));
    148148    iBuilder->CreateAlignedStore(expand1, outPack1_ptr, packAlign);
    149149    // Step 3 of the main loop.
    150     Value * inPack2_ptr = iBuilder->CreateGEP(loopInput_ptr, {iBuilder->getInt32(2)});
    151     Value * outPack2_ptr = iBuilder->CreateGEP(loopOutput_ptr, {iBuilder->getInt32(2)});
     150    Value * inPack2_ptr = iBuilder->CreateGEP(loopInput_ptr, iBuilder->getInt32(2));
     151    Value * outPack2_ptr = iBuilder->CreateGEP(loopOutput_ptr, iBuilder->getInt32(2));
    152152    Value * pack2 = iBuilder->fwCast(8, iBuilder->CreateAlignedLoad(inPack2_ptr, packAlign));
    153153    Value * expand2 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack1, pack2, expand_3_4_shuffle[2]));
    154154    iBuilder->CreateAlignedStore(expand2, outPack2_ptr, packAlign);
    155     Value * outPack3_ptr = iBuilder->CreateGEP(loopOutput_ptr, {iBuilder->getInt32(3)});
     155    Value * outPack3_ptr = iBuilder->CreateGEP(loopOutput_ptr, iBuilder->getInt32(3));
    156156    Value * expand3 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack2, undefPack, expand_3_4_shuffle[3]));
    157157    iBuilder->CreateAlignedStore(expand3, outPack3_ptr, packAlign);
    158158
    159     Value * loopNextInputPack = iBuilder->CreateGEP(loopInput_ptr, {iBuilder->getInt32(3)});
     159    Value * loopNextInputPack = iBuilder->CreateGEP(loopInput_ptr, iBuilder->getInt32(3));
    160160
    161161
     
    167167
    168168    Value * loopNextOutputPack;
    169     loopNextOutputPack = iBuilder->CreateGEP(loopOutput_ptr, {iBuilder->getInt32(4)});
     169    loopNextOutputPack = iBuilder->CreateGEP(loopOutput_ptr, iBuilder->getInt32(4));
    170170
    171171    loopInput_ptr->addIncoming(loopNextInputPack, expand_3_4_loop);
     
    212212    iBuilder->CreateCondBr(condition_c, step2store, step2load);
    213213    iBuilder->SetInsertPoint(step2load);
    214     inPack1_ptr = iBuilder->CreateGEP(loopExitInput_ptr, {iBuilder->getInt32(1)});
     214    inPack1_ptr = iBuilder->CreateGEP(loopExitInput_ptr, iBuilder->getInt32(1));
    215215    pack1 = iBuilder->fwCast(8, iBuilder->CreateAlignedLoad(inPack1_ptr, packAlign));
    216216    iBuilder->CreateBr(step2store);
     
    219219    pack1phi->addIncoming(undefPack, finalStep2);
    220220    pack1phi->addIncoming(pack1, step2load);
    221     outPack1_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, {iBuilder->getInt32(1)});
     221    outPack1_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, iBuilder->getInt32(1));
    222222    expand1 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack0, pack1phi, expand_3_4_shuffle[1]));
    223223    iBuilder->CreateAlignedStore(expand1, outPack1_ptr, packAlign);
     
    229229    iBuilder->CreateCondBr(condition_e, step3store, step3load);
    230230    iBuilder->SetInsertPoint(step3load);
    231     inPack2_ptr = iBuilder->CreateGEP(loopExitInput_ptr, {iBuilder->getInt32(2)});
     231    inPack2_ptr = iBuilder->CreateGEP(loopExitInput_ptr, iBuilder->getInt32(2));
    232232    pack2 = iBuilder->fwCast(8, iBuilder->CreateAlignedLoad(inPack2_ptr, packAlign));
    233233    iBuilder->CreateBr(step3store);
     
    236236    pack2phi->addIncoming(undefPack, finalStep3);
    237237    pack2phi->addIncoming(pack2, step3load);
    238     outPack2_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, {iBuilder->getInt32(2)});
     238    outPack2_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, iBuilder->getInt32(2));
    239239    expand2 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack1phi, pack2phi, expand_3_4_shuffle[2]));
    240240    iBuilder->CreateAlignedStore(expand2, outPack2_ptr, packAlign);
     
    242242    iBuilder->CreateCondBr(condition_f, itemsDone, step3store2);
    243243    iBuilder->SetInsertPoint(step3store2);
    244     outPack3_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, {iBuilder->getInt32(3)});
     244    outPack3_ptr = iBuilder->CreateGEP(loopExitOutput_ptr, iBuilder->getInt32(3));
    245245    expand3 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack2phi, undefPack, expand_3_4_shuffle[3]));
    246246    iBuilder->CreateAlignedStore(expand3, outPack3_ptr, packAlign);
     
    419419    Value * remainOutputStart = iBuilder->CreateSub(remainingBytes, remainMod4);
    420420
    421     Value * firstRemainByte = iBuilder->CreateLoad(iBuilder->CreateGEP(i8input_ptr, {iBuilder->getInt32(0)}));
     421    Value * firstRemainByte = iBuilder->CreateLoad(iBuilder->CreateGEP(i8input_ptr, iBuilder->getInt32(0)));
    422422
    423423    Value * first_move_right_2_mask = ConstantInt::get(iBuilder->getInt8Ty(), 0xFC);
     
    427427    Value * first_move_left_4_byte = iBuilder->CreateShl(iBuilder->CreateAnd(firstRemainByte, first_move_left_4_mask), 4);
    428428
    429     iBuilder->CreateStore(first_output_byte, iBuilder->CreateGEP(i8output_ptr, {iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(0))}));
     429    iBuilder->CreateStore(first_output_byte, iBuilder->CreateGEP(i8output_ptr, iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(0))));
    430430
    431431
     
    433433    iBuilder->SetInsertPoint(handleRemainSecondByte);
    434434
    435     Value * secondRemainByte = iBuilder->CreateLoad(iBuilder->CreateGEP(i8input_ptr, {iBuilder->getInt32(1)}));
     435    Value * secondRemainByte = iBuilder->CreateLoad(iBuilder->CreateGEP(i8input_ptr, iBuilder->getInt32(1)));
    436436    Value * second_move_right_4_mask = ConstantInt::get(iBuilder->getInt8Ty(), 0xF0);
    437437    Value * second_move_right_4_byte = iBuilder->CreateLShr(iBuilder->CreateAnd(secondRemainByte, second_move_right_4_mask), 4);
    438438    Value * second_output_byte = iBuilder->CreateOr(first_move_left_4_byte, second_move_right_4_byte);
    439     iBuilder->CreateStore(second_output_byte, iBuilder->CreateGEP(i8output_ptr, {iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(1))}));
     439    iBuilder->CreateStore(second_output_byte, iBuilder->CreateGEP(i8output_ptr, iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(1))));
    440440
    441441    Value * second_move_left_2_mask = ConstantInt::get(iBuilder->getInt8Ty(), 0x0F);
    442442    Value * second_move_left_2_byte = iBuilder->CreateShl(iBuilder->CreateAnd(secondRemainByte, second_move_left_2_mask), 2);
    443     iBuilder->CreateStore(second_move_left_2_byte, iBuilder->CreateGEP(i8output_ptr, {iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(2))}));
     443    iBuilder->CreateStore(second_move_left_2_byte, iBuilder->CreateGEP(i8output_ptr, iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(2))));
    444444    iBuilder->CreateBr(fbExit);
    445445
    446446    iBuilder->SetInsertPoint(handleNoRemainSecondByte);
    447     iBuilder->CreateStore(first_move_left_4_byte, iBuilder->CreateGEP(i8output_ptr, {iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(1))}));
     447    iBuilder->CreateStore(first_move_left_4_byte, iBuilder->CreateGEP(i8output_ptr, iBuilder->CreateAdd(remainOutputStart, iBuilder->getInt64(1))));
    448448    iBuilder->CreateBr(fbExit);
    449449
     
    559559    iBuilder->SetInsertPoint(doPadding);
    560560    Value * i8output_ptr = iBuilder->CreatePointerCast(base64stream_ptr, iBuilder->getInt8PtrTy());
    561     iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {remainingBytes}));
     561    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, remainingBytes));
    562562    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(3)), fbExit, doPadding2);
    563563    iBuilder->SetInsertPoint(doPadding2);
    564564    Value * finalPadPos = iBuilder->CreateAdd(remainingBytes, iBuilder->getSize(1));
    565     iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {finalPadPos}));
     565    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, finalPadPos));
    566566    iBuilder->CreateBr(fbExit);
    567567    iBuilder->SetInsertPoint(fbExit);
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5238 r5240  
    124124    Value * handle = iBuilder->CreateGEP(bufferStructPtr, {iBuilder->getInt32(0), iBuilder->getInt32(iBuffer_ptr)});
    125125    Value * bufPtr = iBuilder->CreateLoad(handle);
    126     return iBuilder->CreateGEP(bufPtr, {iBuilder->CreateSub(blockNo, consumerBlock)});
     126    return iBuilder->CreateGEP(bufPtr, iBuilder->CreateSub(blockNo, consumerBlock));
    127127}
    128128
     
    174174    Value * bufferPtr = iBuilder->CreateLoad(handle);
    175175    Value * const consumerBlock = iBuilder->CreateUDiv(consumerPos, blockWidth);
    176     Value * copyFrom = iBuilder->CreateGEP(bufferPtr, {iBuilder->CreateSub(new_consumer_block, consumerBlock)});
     176    Value * copyFrom = iBuilder->CreateGEP(bufferPtr, iBuilder->CreateSub(new_consumer_block, consumerBlock));
    177177    Value * alignment = ConstantInt::get(iBuilder->getInt32Ty(), iBuilder->getBitBlockWidth() / 8);
    178178   
  • icGREP/icgrep-devel/icgrep/kernels/symboltablepipeline.cpp

    r5234 r5240  
    729729    remainingBytes3->addIncoming(bufferSize, partialLeadingCond);
    730730    remainingBytes3->addIncoming(remainingBytes2, regularCondBlock);
    731     Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, iBuilder->getSize(0);
     731    Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, iBuilder->getSize(0));
    732732    iBuilder->CreateCondBr(partialBlockCond, partialBodyBlock, flushLengthGroupsBlock);
    733733
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/booleanreassociationpass.cpp

    r5233 r5240  
    164164 * @brief printGraph
    165165 ** ------------------------------------------------------------------------------------------------------------- */
    166 static void printGraph(const Graph & G, const std::string name) {
     166static void printGraph(const Graph & G, const std::string & name) {
    167167    raw_os_ostream out(std::cerr);
    168168
     
    17491749 ** ------------------------------------------------------------------------------------------------------------- */
    17501750inline BooleanReassociationPass::BooleanReassociationPass(Z3_context ctx, Z3_params params, Z3_tactic tactic, PabloFunction & f)
    1751 : mContext(ctx)
     1751: mBlock(nullptr)
     1752, mContext(ctx)
    17521753, mParams(params)
    17531754, mTactic(tactic)
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r5238 r5240  
    3939
    4040    using Allocator = SlabAllocator<PabloAST *>;
    41     using Users = std::vector<PabloAST *, Allocator>;
     41    using UserAllocator = ProxyAllocator<PabloAST *>;
     42    using Users = std::vector<PabloAST *, UserAllocator>;
    4243    using user_iterator = Users::iterator;
    4344    using const_user_iterator = Users::const_iterator;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5238 r5240  
    141141PabloKernel::~PabloKernel() {
    142142    delete mPabloCompiler;
    143     delete mSymbolTable;
     143    delete mSymbolTable; 
    144144}
    145145
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5233 r5240  
    3535public:
    3636
    37     using Allocator = PabloAST::Allocator;
     37    using Allocator = SlabAllocator<PabloAST *>;
    3838
    3939    PabloKernel(IDISA::IDISA_Builder * builder, const std::string & kernelName);
  • icGREP/icgrep-devel/icgrep/re/re_re.cpp

    r5037 r5240  
    33namespace re {
    44RE::Allocator RE::mAllocator;
    5 RE::VectorAllocator RE::mVectorAllocator;
    65}
  • icGREP/icgrep-devel/icgrep/re/re_re.h

    r5091 r5240  
    3737class RE {
    3838public:
    39     using Allocator = SlabAllocator<u_int8_t>;
    40     using VectorAllocator = SlabAllocator<RE *>;
     39    using Allocator = SlabAllocator<RE *>;
     40    using VectorAllocator = ProxyAllocator<RE *>;
    4141    enum class ClassTypeId : unsigned {
    4242        Alt
     
    6565    }
    6666    void* operator new (std::size_t size) noexcept {
    67         return mAllocator.allocate(size);
     67        return mAllocator.allocate<uint8_t>(size);
    6868    }
    6969    const ClassTypeId mClassTypeId;
    7070
    7171    static Allocator mAllocator;
    72     static VectorAllocator mVectorAllocator;
    7372};
    7473
    7574class Vector : public RE, public std::vector<RE*, RE::VectorAllocator> {
    7675public:
    77 
    78     virtual ~Vector() {
    79     }
     76    virtual ~Vector() {}
    8077protected:
    8178    inline Vector(const ClassTypeId id)
    8279    : RE(id)
    83     , std::vector<RE*, RE::VectorAllocator>(mVectorAllocator)
     80    , std::vector<RE*, RE::VectorAllocator>(mAllocator)
    8481    {
    8582
     
    8784    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
    8885    : RE(id)
    89     , std::vector<RE*, RE::VectorAllocator>(begin, end, mVectorAllocator) {
     86    , std::vector<RE*, RE::VectorAllocator>(begin, end, mAllocator) {
    9087
    9188    }
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5238 r5240  
    386386   
    387387    verifyModule(*M, &dbgs());
    388     //std::cerr << "ExecuteKernels(); done\n";
    389     u8u16Engine = JIT_to_ExecutionEngine(M);
    390    
     388    u8u16Engine = JIT_to_ExecutionEngine(M);   
    391389    u8u16Engine->finalizeObject();
    392     //std::cerr << "finalizeObject(); done\n";
    393390
    394391    delete idb;
  • icGREP/icgrep-devel/icgrep/util/slab_allocator.h

    r5230 r5240  
    44#include <llvm/Support/Allocator.h>
    55
    6 template <typename T>
     6template <typename T = uint8_t>
    77class SlabAllocator {
    8     using LLVMAllocator = llvm::BumpPtrAllocator;
     8    template <typename U> friend class ProxyAllocator;
     9    using LLVMAllocator = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 16 * 1024>;
    910public:
    1011
     
    3233
    3334    template<typename Type = T>
    34     inline void deallocate(Type * p, size_type = 0) noexcept {
    35         mAllocator.Deallocate(p);
     35    inline void deallocate(Type * p, size_type size = 0) noexcept {
     36        mAllocator.Deallocate(p, size);
    3637    }
    3738
     
    4041    }
    4142
    42     inline LLVMAllocator & get_allocator() {
    43         return mAllocator;
    44     }
    45 
    46     void reset() {
    47         mAllocator.Reset();
    48     }
    49 
    5043    template<typename Type = T>
    5144    inline bool operator==(SlabAllocator<Type> const & other) {
    52         return &mAllocator == &other.mAllocator;
     45        return this == &other;
    5346    }
    5447
    5548    template<typename Type = T>
    5649    inline bool operator!=(SlabAllocator<Type> const & other) {
    57         return &mAllocator != &other.mAllocator;
     50        return this != &other;
    5851    }
    5952
    6053    inline SlabAllocator() noexcept {}
    61     inline SlabAllocator(const SlabAllocator &) noexcept {}
    62     template <class U> inline SlabAllocator (const std::allocator<U>&) noexcept {}
    63     inline ~SlabAllocator() { reset(); }
     54    inline SlabAllocator(const SlabAllocator &) noexcept { assert (false); }
     55    template <class U> inline SlabAllocator (const SlabAllocator<U> &) noexcept { assert (false); }
    6456private:
    6557    LLVMAllocator mAllocator;
    6658};
    6759
     60template <typename T = uint8_t>
     61class ProxyAllocator {
     62    using LLVMAllocator = typename SlabAllocator<T>::LLVMAllocator;
     63public:
     64    using value_type = T;
     65    using pointer = value_type*;
     66    using const_pointer = const value_type*;
     67    using reference = value_type&;
     68    using const_reference = const value_type&;
     69    using size_type = std::size_t;
     70    using difference_type = std::ptrdiff_t;
     71
     72    template<class U>
     73    struct rebind {
     74        typedef ProxyAllocator<U> other;
     75    };
     76
     77    template<typename Type = T>
     78    inline Type * allocate(size_type n, const_pointer = nullptr) noexcept {
     79        static_assert(sizeof(Type) > 0, "Cannot allocate a zero-length type.");
     80        assert ("Cannot allocate 0 items." && n > 0);
     81        auto ptr = static_cast<Type *>(mAllocator->Allocate(n * sizeof(Type), sizeof(void*)));
     82        assert ("Allocating returned a null pointer. Function was likely called before Allocator creation!" && ptr);
     83        return ptr;
     84    }
     85
     86    template<typename Type = T>
     87    inline void deallocate(Type * p, size_type size = 0) noexcept {
     88        mAllocator->Deallocate(p, size);
     89    }
     90
     91    inline size_type max_size() const {
     92        return std::numeric_limits<size_type>::max();
     93    }
     94
     95    template<typename Type = T>
     96    inline bool operator==(ProxyAllocator<Type> const & other) {
     97        return mAllocator == other.mAllocator;
     98    }
     99
     100    template<typename Type = T>
     101    inline bool operator!=(ProxyAllocator<Type> const & other) {
     102        return mAllocator != other.mAllocator;
     103    }
     104
     105    inline ProxyAllocator() noexcept { assert (false); }
     106    inline ProxyAllocator(ProxyAllocator const & a) noexcept : mAllocator(const_cast<LLVMAllocator *>(a.mAllocator)) {}
     107    template <class U> inline ProxyAllocator (const SlabAllocator<U> & a) noexcept : mAllocator(const_cast<LLVMAllocator *>(&a.mAllocator)) {}
     108private:
     109    LLVMAllocator * const mAllocator;
     110};
     111
    68112#endif // SLAB_ALLOCATOR_H
Note: See TracChangeset for help on using the changeset viewer.