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

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

Initial doSegment support; pipeline generation

File size: 2.7 KB
RevLine 
[5047]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
[5086]16   
[5047]17struct ScalarBinding {
18    llvm::Type * scalarType;
19    std::string scalarName;
20};
21
22struct StreamSetBinding {
23    kernel::StreamSetType ssType;
24    std::string ssName;
25};
26   
[5060]27const std::string init_suffix = "_Init";
28const std::string doBlock_suffix = "_DoBlock";
[5086]29const std::string doSegment_suffix = "_DoSegment";
[5060]30const std::string finalBlock_suffix = "_FinalBlock";
31const std::string accumulator_infix = "_get_";
32
[5047]33class KernelInterface {
34
35public:
36    KernelInterface(IDISA::IDISA_Builder * builder,
37                    std::string kernelName,
38                    std::vector<StreamSetBinding> stream_inputs,
39                    std::vector<StreamSetBinding> stream_outputs,
40                    std::vector<ScalarBinding> scalar_parameters,
41                    std::vector<ScalarBinding> scalar_outputs,
[5060]42                    std::vector<ScalarBinding> internal_scalars) :
43    iBuilder(builder),
44    mKernelName(kernelName),
45    mStreamSetInputs(stream_inputs),
46    mStreamSetOutputs(stream_outputs),
47    mScalarInputs(scalar_parameters),
48    mScalarOutputs(scalar_outputs),
49    mInternalScalars(internal_scalars),
[5076]50    mDoBlockReturnType(nullptr),
[5060]51    mKernelStateType(nullptr) {}
[5047]52   
[5053]53   
[5047]54    // Add ExternalLinkage method declarations for the kernel to a given client module.
55    void addKernelDeclarations(Module * client);
56   
[5053]57    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
[5086]58    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters, std::vector<kernel::StreamSetBuffer *> inputs, std::vector<kernel::StreamSetBuffer *> outputBuffers);
[5053]59    llvm::Value * createDoBlockCall(llvm::Value * kernelInstance, std::vector<Value *> streamSets);
[5086]60    llvm::Value * createDoSegmentCall(llvm::Value * kernelInstance, llvm::Value * blkCount);
[5053]61    llvm::Value * createFinalBlockCall(llvm::Value * kernelInstance, llvm::Value * remainingBytes, std::vector<llvm::Value *> streamSets);
62    llvm::Value * createGetAccumulatorCall(llvm::Value * kernelInstance, std::string accumName);
63   
[5086]64//protected:
[5053]65   
[5047]66    IDISA::IDISA_Builder * iBuilder;
67    std::string mKernelName;
68    std::vector<StreamSetBinding> mStreamSetInputs;
69    std::vector<StreamSetBinding> mStreamSetOutputs;
70    std::vector<ScalarBinding> mScalarInputs;
71    std::vector<ScalarBinding> mScalarOutputs;
72    std::vector<ScalarBinding> mInternalScalars;
[5076]73    llvm::Type * mDoBlockReturnType;
[5060]74    llvm::Type * mKernelStateType;
[5047]75};
76#endif
Note: See TracBrowser for help on using the repository browser.