source: icGREP/icgrep-devel/icgrep/kernels/interface.h @ 5141

Last change on this file since 5141 was 5141, checked in by cameron, 3 years ago

pablo.Lookahead support updated for stream set access/kernel system

File size: 2.8 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#ifndef KERNEL_INTERFACE_H
7#define KERNEL_INTERFACE_H
8
9
10#include <string>
11#include <vector>
12#include <llvm/IR/Type.h>
13#include <IDISA/idisa_builder.h>
14#include "streamset.h"
15
16struct ScalarBinding {
17    llvm::Type * scalarType;
18    std::string scalarName;
19};
20
21struct StreamSetBinding {
22    parabix::StreamSetType ssType;
23    std::string ssName;
24};
25   
26const std::string init_suffix = "_Init";
27const std::string doBlock_suffix = "_DoBlock";
28const std::string doSegment_suffix = "_DoSegment";
29const std::string finalBlock_suffix = "_FinalBlock";
30const std::string accumulator_infix = "_get_";
31
32class KernelInterface {
33
34public:
35    KernelInterface(IDISA::IDISA_Builder * builder,
36                    std::string kernelName,
37                    std::vector<StreamSetBinding> stream_inputs,
38                    std::vector<StreamSetBinding> stream_outputs,
39                    std::vector<ScalarBinding> scalar_parameters,
40                    std::vector<ScalarBinding> scalar_outputs,
41                    std::vector<ScalarBinding> internal_scalars) :
42    iBuilder(builder),
43    mKernelName(kernelName),
44    mStreamSetInputs(stream_inputs),
45    mStreamSetOutputs(stream_outputs),
46    mScalarInputs(scalar_parameters),
47    mScalarOutputs(scalar_outputs),
48    mInternalScalars(internal_scalars),
49    mKernelStateType(nullptr),
50    mLookAheadPositions(0) {}
51   
52    unsigned getLookAhead() { return mLookAheadPositions; }
53   
54    // Add ExternalLinkage method declarations for the kernel to a given client module.
55    void addKernelDeclarations(Module * client);
56   
57    virtual llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
58    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters, std::vector<parabix::StreamSetBuffer *> inputs, std::vector<parabix::StreamSetBuffer *> outputBuffers);
59    llvm::Value * createDoBlockCall(llvm::Value * kernelInstance);
60    llvm::Value * createDoSegmentCall(llvm::Value * kernelInstance, llvm::Value * blkCount);
61    llvm::Value * createFinalBlockCall(llvm::Value * kernelInstance, llvm::Value * remainingBytes);
62    llvm::Value * createGetAccumulatorCall(llvm::Value * kernelInstance, std::string accumName);
63   
64   
65protected:
66   
67    IDISA::IDISA_Builder * iBuilder;
68    std::string mKernelName;
69    std::vector<StreamSetBinding> mStreamSetInputs;
70    std::vector<StreamSetBinding> mStreamSetOutputs;
71    std::vector<ScalarBinding> mScalarInputs;
72    std::vector<ScalarBinding> mScalarOutputs;
73    std::vector<ScalarBinding> mInternalScalars;
74    llvm::Type * mKernelStateType;
75    unsigned mLookAheadPositions;
76   
77    void setLookAhead(unsigned lookAheadPositions) {mLookAheadPositions = lookAheadPositions;}
78
79};
80#endif
Note: See TracBrowser for help on using the repository browser.