source: icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp @ 6161

Last change on this file since 6161 was 5935, checked in by cameron, 19 months ago

Direct CC builder work

File size: 2.0 KB
Line 
1/*
2 *  Copyright (c) 2018 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#include "cc_kernel.h"
7#include <re/re_cc.h>
8#include <cc/cc_compiler.h>
9#include <kernels/kernel_builder.h>
10#include <llvm/Support/raw_ostream.h>
11
12using namespace cc;
13using namespace kernel;
14using namespace pablo;
15using namespace re;
16using namespace llvm;
17
18DirectCharacterClassKernelBuilder::DirectCharacterClassKernelBuilder(
19        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses)
20: PabloKernel(b, ccSetName +"_direct",
21              {Binding{b->getStreamSetTy(1, 8), "byteStream"}},
22              {Binding{b->getStreamSetTy(charClasses.size(), 1), "ccStream"}})
23, mCharClasses(charClasses) {
24}
25
26void DirectCharacterClassKernelBuilder::generatePabloMethod() {
27    PabloBuilder pb(getEntryScope());
28    cc::Direct_CC_Compiler ccc(getEntryScope(), getInputStreamSet("byteStream")[0]);
29    Var * outputVar = getOutputStreamVar("ccStream");
30    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
31        pb.createAssign(pb.createExtract(outputVar, i), ccc.compileCC(mCharClasses[i]));
32    }
33}
34
35
36ParabixCharacterClassKernelBuilder::ParabixCharacterClassKernelBuilder (
37        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, const std::vector<CC *> & charClasses, unsigned codeUnitWidth)
38: PabloKernel(b, ccSetName +"_kernel",
39// stream inputs
40{Binding{b->getStreamSetTy(codeUnitWidth), "basis"}}
41// stream outputs
42, {Binding(b->getStreamSetTy((unsigned int)charClasses.size()), "outputStream")}
43)
44, mCharClasses(charClasses) {
45
46}
47
48void ParabixCharacterClassKernelBuilder::generatePabloMethod() {
49    PabloBuilder pb(getEntryScope());
50    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
51    Var * outputVar = getOutputStreamVar("outputStream");
52    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
53        pb.createAssign(pb.createExtract(outputVar, i), ccc.compileCC(mCharClasses[i]));
54    }
55}
Note: See TracBrowser for help on using the repository browser.