Changeset 6187


Ignore:
Timestamp:
Nov 3, 2018, 3:39:55 PM (7 months ago)
Author:
nmedfort
Message:

Potential bug fix for u32u8. CPUDriver only constructs the pass manager if uncached kernels exist.

Location:
icGREP/icgrep-devel/icgrep
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/icgrep.files

    r6184 r6187  
    117117re/re_minimizer.h
    118118re/re_minimizer.cpp
    119 re/re_memoizer.cpp
    120119re/re_local.h
    121120re/re_local.cpp
  • icGREP/icgrep-devel/icgrep/kernels/block_kernel.cpp

    r6184 r6187  
    353353
    354354using PopCountRateGraph = adjacency_list<hash_setS, vecS, directedS>;
    355 using Key = std::reference_wrapper<const std::string>;
    356 using PopCountRateMap = boost::container::flat_map<Key, PopCountRateGraph::vertex_descriptor, std::less<std::string>>;
     355using PopCountRateMap = llvm::StringMap<PopCountRateGraph::vertex_descriptor>;
    357356
    358357#define POP_COUNT 0
     
    373372    PopCountRateGraph G(n);
    374373    PopCountRateMap M;
    375     M.reserve(n);
    376374    for (unsigned i = 0; i < n; ++i) {
    377         M.emplace(inputStreamSets[i].getName(), i);
     375        M.insert(std::make_pair(inputStreamSets[i].getName(), i));
    378376        checkPopCount(inputStreamSets[i], G, M);
    379377    }
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r6186 r6187  
    146146 * @brief addScalarToMap
    147147 ** ------------------------------------------------------------------------------------------------------------- */
    148 void Kernel::addScalarToMap(const std::string & name, const ScalarType scalarType, const unsigned index) {
    149     const auto r = mScalarMap.emplace(name, ScalarField{scalarType, index});
     148void Kernel::addScalarToMap(const llvm::StringRef name, const ScalarType scalarType, const unsigned index) {
     149    const auto r = mScalarMap.insert(std::make_pair(name, ScalarField{scalarType, index}));
    150150    if (LLVM_UNLIKELY(!r.second)) {
    151151        const ScalarField & sf = r.first->second;
     
    159159 * @brief addScalarToMap
    160160 ** ------------------------------------------------------------------------------------------------------------- */
    161 void Kernel::addStreamToMap(const std::string & name, const Port port, const unsigned index) {
    162     const auto r = mStreamSetMap.emplace(name, std::make_pair(port, index));
     161void Kernel::addStreamToMap(const llvm::StringRef name, const Port port, const unsigned index) {
     162    const auto r = mStreamSetMap.insert(std::make_pair(name, std::make_pair(port, index)));
    163163    if (LLVM_UNLIKELY(!r.second)) {
    164164        const StreamPort & sf = r.first->second;
     
    613613 * @brief addInternalScalar
    614614 ** ------------------------------------------------------------------------------------------------------------- */
    615 void Kernel::addInternalScalar(llvm::Type * type, const std::string & name) {
     615void Kernel::addInternalScalar(llvm::Type * type, const llvm::StringRef name) {
    616616    const auto index = mInternalScalars.size();
    617617    mInternalScalars.emplace_back(type, name);
     
    622622 * @brief getScalarIndex
    623623 ** ------------------------------------------------------------------------------------------------------------- */
    624 unsigned Kernel::getScalarIndex(const std::string & fieldName) const {
     624unsigned Kernel::getScalarIndex(const llvm::StringRef fieldName) const {
    625625    const auto & field = getScalarField(fieldName);
    626626    assert (mKernelStateType);
     
    675675 * Create a fixed length string hash of the given str
    676676 ** ------------------------------------------------------------------------------------------------------------- */
    677 std::string Kernel::getStringHash(const std::string & str) {
     677std::string Kernel::getStringHash(const llvm::StringRef str) {
    678678
    679679    uint32_t digest[5]; // 160 bits in total
    680680    boost::uuids::detail::sha1 sha1;
    681     sha1.process_bytes(str.c_str(), str.size());
     681    sha1.process_bytes(str.data(), str.size());
    682682    sha1.get_digest(digest);
    683683
     
    756756 * @brief getScalarField
    757757 ** ------------------------------------------------------------------------------------------------------------- */
    758 const Kernel::ScalarField & Kernel::getScalarField(const std::string & name) const {
     758const Kernel::ScalarField & Kernel::getScalarField(const llvm::StringRef name) const {
    759759    assert (!mScalarMap.empty());
    760760    const auto f = mScalarMap.find(name);
     
    768768 * @brief getInputScalarBinding
    769769 ** ------------------------------------------------------------------------------------------------------------- */
    770 Binding & Kernel::getInputScalarBinding(const std::string & name) {
     770Binding & Kernel::getInputScalarBinding(const llvm::StringRef name) {
    771771    const ScalarField & field = getScalarField(name);
    772772    if (LLVM_UNLIKELY(field.type != ScalarType::Input)) {
     
    779779 * @brief getOutputScalarBinding
    780780 ** ------------------------------------------------------------------------------------------------------------- */
    781 Binding & Kernel::getOutputScalarBinding(const std::string & name) {
     781Binding & Kernel::getOutputScalarBinding(const llvm::StringRef name) {
    782782    const ScalarField & field = getScalarField(name);
    783783    if (LLVM_UNLIKELY(field.type != ScalarType::Output)) {
     
    790790 * @brief getStreamPort
    791791 ** ------------------------------------------------------------------------------------------------------------- */
    792 Kernel::StreamSetPort Kernel::getStreamPort(const std::string & name) const {
     792Kernel::StreamSetPort Kernel::getStreamPort(const llvm::StringRef name) const {
    793793    const auto f = mStreamSetMap.find(name);
    794794    if (LLVM_UNLIKELY(f == mStreamSetMap.end())) {
     
    802802 * @brief getBinding
    803803 ** ------------------------------------------------------------------------------------------------------------- */
    804 const Binding & Kernel::getStreamBinding(const std::string & name) const {
     804const Binding & Kernel::getStreamBinding(const llvm::StringRef name) const {
    805805    Port port; unsigned index;
    806806    std::tie(port, index) = getStreamPort(name);
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r6184 r6187  
    1313#include <llvm/ADT/StringRef.h>
    1414#include <llvm/Support/Compiler.h>
    15 #include <boost/container/flat_map.hpp>
     15#include <llvm/ADT/StringMap.h>
    1616#include <memory>
    1717#include <string>
     
    6767    };
    6868
    69     using StringRef = std::string; //std::reference_wrapper<const std::string>;
    70 
    71     template <typename Value>
    72     using StringRefMap = boost::container::flat_map<StringRef, Value, std::less<std::string>>;
    73 
    74     using ScalarFieldMap = StringRefMap<ScalarField>;
     69    using ScalarFieldMap = llvm::StringMap<ScalarField>;
    7570
    7671    enum class Port { Input, Output };
     
    7873    using StreamSetPort = std::pair<Port, unsigned>;
    7974
    80     using StreamSetMap = StringRefMap<StreamSetPort>;
     75    using StreamSetMap = llvm::StringMap<StreamSetPort>;
    8176
    8277    // Kernel Signatures and Module IDs
     
    148143    }
    149144
    150     LLVM_READNONE const Binding & getInputStreamSetBinding(const std::string & name) const {
     145    LLVM_READNONE const Binding & getInputStreamSetBinding(const llvm::StringRef name) const {
    151146        const auto port = getStreamPort(name);
    152147        assert (port.first == Port::Input);
     
    158153    }
    159154
    160     LLVM_READNONE StreamSet * getInputStreamSet(const std::string & name) const {
     155    LLVM_READNONE StreamSet * getInputStreamSet(const llvm::StringRef name) const {
    161156        return llvm::cast<StreamSet>(getInputStreamSetBinding(name).getRelationship());
    162157    }
    163158
    164     void setInputStreamSet(const std::string & name, StreamSet * value) {
     159    void setInputStreamSet(const llvm::StringRef name, StreamSet * value) {
    165160        const auto port = getStreamPort(name);
    166161        assert (port.first == Port::Input);
     
    182177    }
    183178
    184     LLVM_READNONE StreamSetBuffer * getInputStreamSetBuffer(const std::string & name) const {
     179    LLVM_READNONE StreamSetBuffer * getInputStreamSetBuffer(const llvm::StringRef name) const {
    185180        const auto port = getStreamPort(name);
    186181        assert (port.first == Port::Input);
     
    193188    }
    194189
    195     LLVM_READNONE const Binding & getOutputStreamSetBinding(const std::string & name) const {
     190    LLVM_READNONE const Binding & getOutputStreamSetBinding(const llvm::StringRef name) const {
    196191        const auto port = getStreamPort(name);
    197192        assert (port.first == Port::Output);
     
    203198    }
    204199
    205     LLVM_READNONE StreamSet * getOutputStreamSet(const std::string & name) const {
     200    LLVM_READNONE StreamSet * getOutputStreamSet(const llvm::StringRef name) const {
    206201        return llvm::cast<StreamSet>(getOutputStreamSetBinding(name).getRelationship());
    207202    }
    208203
    209     void setOutputStreamSet(const std::string & name, StreamSet * value) {
     204    void setOutputStreamSet(const llvm::StringRef name, StreamSet * value) {
    210205        const auto port = getStreamPort(name);
    211206        assert (port.first == Port::Output);
     
    231226    }
    232227
    233     LLVM_READNONE StreamSetBuffer * getOutputStreamSetBuffer(const std::string & name) const {
     228    LLVM_READNONE StreamSetBuffer * getOutputStreamSetBuffer(const llvm::StringRef name) const {
    234229        const auto port = getStreamPort(name);
    235230        assert (port.first == Port::Output);
     
    246241    }
    247242
    248     LLVM_READNONE Binding & getInputScalarBinding(const std::string & name);
     243    LLVM_READNONE Binding & getInputScalarBinding(const llvm::StringRef name);
    249244
    250245    LLVM_READNONE Scalar * getInputScalar(const unsigned i) {
     
    252247    }
    253248
    254     LLVM_READNONE Scalar * getInputScalar(const std::string & name) {
     249    LLVM_READNONE Scalar * getInputScalar(const llvm::StringRef name) {
    255250        return llvm::cast<Scalar>(getInputScalarBinding(name).getRelationship());
    256251    }
    257252
    258     void setInputScalar(const std::string & name, Scalar * value) {
     253    void setInputScalar(const llvm::StringRef name, Scalar * value) {
    259254        const auto & field = getScalarField(name);
    260255        assert(field.type == ScalarType::Input);
     
    275270    }
    276271
    277     LLVM_READNONE Binding & getOutputScalarBinding(const std::string & name);
    278 
    279     LLVM_READNONE Scalar * getOutputScalar(const std::string & name) {
     272    LLVM_READNONE Binding & getOutputScalarBinding(const llvm::StringRef name);
     273
     274    LLVM_READNONE Scalar * getOutputScalar(const llvm::StringRef name) {
    280275        return llvm::cast<Scalar>(getOutputScalarBinding(name).getRelationship());
    281276    }
     
    285280    }
    286281
    287     void setOutputScalar(const std::string & name, Scalar * value) {
     282    void setOutputScalar(const llvm::StringRef name, Scalar * value) {
    288283        const auto & field = getScalarField(name);
    289284        assert(field.type == ScalarType::Output);
     
    295290    }
    296291
    297     void addInternalScalar(llvm::Type * type, const std::string & name);
     292    void addInternalScalar(llvm::Type * type, const llvm::StringRef name);
    298293
    299294    llvm::Value * getHandle() const {
     
    313308    }
    314309
    315     LLVM_READNONE const StreamSetBuffer * getStreamSetBuffer(const std::string & name) const {
     310    LLVM_READNONE const StreamSetBuffer * getStreamSetBuffer(const llvm::StringRef name) const {
    316311        unsigned index; Port port;
    317312        std::tie(port, index) = getStreamPort(name);
     
    342337    LLVM_READNONE std::string getCacheName(const std::unique_ptr<KernelBuilder> & b) const;
    343338
    344     LLVM_READNONE StreamSetPort getStreamPort(const std::string & name) const;
    345 
    346     LLVM_READNONE const Binding & getStreamBinding(const std::string & name) const;
     339    LLVM_READNONE StreamSetPort getStreamPort(const llvm::StringRef name) const;
     340
     341    LLVM_READNONE const Binding & getStreamBinding(const llvm::StringRef name) const;
    347342
    348343    LLVM_READNONE ProcessingRate::RateValue getLowerBound(const Binding & binding) const;
     
    364359protected:
    365360
    366     static std::string getStringHash(const std::string & str);
     361    static std::string getStringHash(const llvm::StringRef str);
    367362
    368363    LLVM_READNONE std::string getDefaultFamilyName() const;
    369364
    370     LLVM_READNONE unsigned getScalarIndex(const std::string & name) const;
     365    LLVM_READNONE unsigned getScalarIndex(const llvm::StringRef name) const;
    371366
    372367    virtual void addInternalKernelProperties(const std::unique_ptr<KernelBuilder> &) { }
     
    400395    void setStride(unsigned stride) { mStride = stride; }
    401396
    402     llvm::Value * getAccessibleInputItems(const std::string & name) const {
     397    llvm::Value * getAccessibleInputItems(const llvm::StringRef name) const {
    403398        Port port; unsigned index;
    404399        std::tie(port, index) = getStreamPort(name);
     
    412407    }
    413408
    414     llvm::Value * getAvailableInputItems(const std::string & name) const {
     409    llvm::Value * getAvailableInputItems(const llvm::StringRef name) const {
    415410        Port port; unsigned index;
    416411        std::tie(port, index) = getStreamPort(name);
     
    440435    void callGenerateFinalizeMethod(const std::unique_ptr<KernelBuilder> & b);
    441436
    442     void addScalarToMap(const std::string & name, const ScalarType scalarType, const unsigned index);
    443 
    444     void addStreamToMap(const std::string & name, const Port port, const unsigned index);
    445 
    446     LLVM_READNONE const ScalarField & getScalarField(const std::string & name) const;
     437    void addScalarToMap(const llvm::StringRef name, const ScalarType scalarType, const unsigned index);
     438
     439    void addStreamToMap(const llvm::StringRef name, const Port port, const unsigned index);
     440
     441    LLVM_READNONE const ScalarField & getScalarField(const llvm::StringRef name) const;
    447442
    448443    void addBaseKernelProperties(const std::unique_ptr<KernelBuilder> & b);
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r6184 r6187  
    4444    }
    4545}
    46 
    47 
    48 
    49 
    5046               
    5147void P2SKernel::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) {
  • icGREP/icgrep-devel/icgrep/kernels/pipeline/buffer_management_logic.hpp

    r6184 r6187  
    133133
    134134            BufferNode & kn = G[i];
    135 
    136             const Kernel * const kernel = kn.kernel; assert(kernel);
     135            assert(kn.kernel);
    137136
    138137            for (const auto ce : make_iterator_range(in_edges(i, G))) {
     
    265264    for (unsigned i = 0; i < numOfKernels; ++i) {
    266265        const Kernel * const kernel = mPipeline[i]; assert(kernel);
    267         out << "v" << i << " [label=\"" << i << ": " <<  mPipeline[i]->getName()  << "\" shape=box];\n";
     266        out << "v" << i << " [label=\"" << i << ": " <<  kernel->getName()  << "\" shape=box];\n";
    268267    }
    269268
  • icGREP/icgrep-devel/icgrep/toolchain/cpudriver.cpp

    r6184 r6187  
    105105        throw std::runtime_error("Could not selectTarget");
    106106    }
    107     preparePassManager();
    108 
    109107    #ifdef ORCJIT
    110108    mCompileLayer = make_unique<CompileLayerT>(mObjectLayer, orc::SimpleCompiler(*mTarget));
     
    227225
    228226void CPUDriver::generateUncachedKernels() {
     227    if (mUncachedKernel.empty()) return;
     228    preparePassManager();
    229229    for (auto & kernel : mUncachedKernel) {
    230230        kernel->prepareKernel(iBuilder);
Note: See TracChangeset for help on using the changeset viewer.