Ignore:
Timestamp:
Nov 2, 2018, 7:18:31 PM (10 months ago)
Author:
nmedfort
Message:

Initial version of PipelineKernel? + revised StreamSet? model.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r6140 r6184  
    1010#include <cc/cc_compiler.h>
    1111#include <re/re_name.h>
    12 #include <boost/uuid/sha1.hpp>
    1312#include <pablo/builder.hpp>
    1413#include <llvm/Support/ErrorHandling.h>
     
    2322using namespace llvm;
    2423using namespace UCD;
    25 
    26 inline static std::string sha1sum(const std::string & str) {
    27     char buffer[41];    // 40 hex-digits and the terminating null
    28     uint32_t digest[5]; // 160 bits in total
    29     boost::uuids::detail::sha1 sha1;
    30     sha1.process_bytes(str.c_str(), str.size());
    31     sha1.get_digest(digest);
    32     snprintf(buffer, sizeof(buffer), "%.8x%.8x%.8x%.8x%.8x",
    33              digest[0], digest[1], digest[2], digest[3], digest[4]);
    34     return std::string(buffer);
    35 }
    3624
    3725inline std::string signature(const std::vector<re::CC *> & ccs) {
     
    5846
    5947
    60 CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs, bool useDirectCC, cc::BitNumbering basisNumbering)
    61 : CharClassesSignature(ccs, useDirectCC, basisNumbering)
    62 , PabloKernel(iBuilder,
    63               "cc" + sha1sum(mSignature),
    64               {},
    65               {Binding{iBuilder->getStreamSetTy(ccs.size(), 1), "charclasses"}})
    66 , mCCs(std::move(ccs)), mBasisSetNumbering(basisNumbering) {
    67     if (useDirectCC) {
    68         mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(1, 8), "byteData"}});
    69     }
    70     else {
    71         mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(8), "basis"}});
    72     }
     48CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs, StreamSet * BasisBits, StreamSet * CharClasses, cc::BitNumbering basisNumbering)
     49: CharClassesSignature(ccs, BasisBits->getNumElements() == 1, basisNumbering)
     50, PabloKernel(iBuilder, "cc" + getStringHash(mSignature), {Binding{"basis", BasisBits}}, {Binding{"charclasses", CharClasses}})
     51, mCCs(std::move(ccs))
     52, mBasisSetNumbering(basisNumbering) {
     53
    7354}
    7455
     
    119100
    120101ByteClassesKernel::ByteClassesKernel(const std::unique_ptr<kernel::KernelBuilder> &iBuilder,
    121                                      std::vector<re::CC *> &&ccs, bool useDirectCC, BitNumbering basisNumbering):
    122         CharClassesSignature(ccs, useDirectCC, basisNumbering)
    123         , PabloKernel(iBuilder,
    124                       "ByteClassesKernel_" + sha1sum(mSignature),
    125                       {},
    126                       {Binding{iBuilder->getStreamSetTy(ccs.size(), 1), "charclasses"}})
    127         , mCCs(std::move(ccs)), mBasisSetNumbering(basisNumbering)
    128 {
    129     if (useDirectCC) {
    130         mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(1, 8), "byteData"}});
    131     }
    132     else {
    133         mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(8), "basis"}});
    134     }
     102                                     std::vector<re::CC *> && ccs,
     103                                     StreamSet * inputStream,
     104                                     StreamSet * CharClasses,
     105                                     BitNumbering basisNumbering):
     106CharClassesSignature(ccs, inputStream->getNumElements() == 1, basisNumbering)
     107, PabloKernel(iBuilder, "ByteClassesKernel_" + getStringHash(mSignature), {Binding{"basis", inputStream}}, {Binding{"charclasses", CharClasses}})
     108, mCCs(std::move(ccs))
     109, mBasisSetNumbering(basisNumbering) {
     110
    135111}
    136112
    137 std::string ByteClassesKernel::makeSignature(const std::unique_ptr<kernel::KernelBuilder> &iBuilder) {
     113std::string ByteClassesKernel::makeSignature(const std::unique_ptr<kernel::KernelBuilder> &) {
    138114    return mSignature;
    139115}
Note: See TracChangeset for help on using the changeset viewer.