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

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

Kernel/interface progress

File size: 2.6 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
16   
17struct ScalarBinding {
18    llvm::Type * scalarType;
19    std::string scalarName;
20};
21
22struct StreamSetBinding {
23    kernel::StreamSetType ssType;
24    std::string ssName;
25};
26   
27const std::string init_suffix = "_Init";
28const std::string doBlock_suffix = "_DoBlock";
29const std::string doSegment_suffix = "_DoSegment";
30const std::string finalBlock_suffix = "_FinalBlock";
31const std::string accumulator_infix = "_get_";
32
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,
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),
50    mDoBlockReturnType(nullptr),
51    mKernelStateType(nullptr) {}
52   
53   
54    // Add ExternalLinkage method declarations for the kernel to a given client module.
55    void addKernelDeclarations(Module * client);
56   
57    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
58    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters, std::vector<kernel::StreamSetBuffer *> inputs, std::vector<kernel::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   
64protected:
65   
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;
73    llvm::Type * mDoBlockReturnType;
74    llvm::Type * mKernelStateType;
75};
76#endif
Note: See TracBrowser for help on using the repository browser.