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

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

DoBlock/FinalBlock/DoSegment? Kernel functions always return void; clean-up

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    parabix::StreamSetBuffer & 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    mKernelStateType(nullptr) {}
51   
52   
53    // Add ExternalLinkage method declarations for the kernel to a given client module.
54    void addKernelDeclarations(Module * client);
55   
56    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
57    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters, std::vector<parabix::StreamSetBuffer *> inputs, std::vector<parabix::StreamSetBuffer *> outputBuffers);
58    llvm::Value * createDoBlockCall(llvm::Value * kernelInstance);
59    llvm::Value * createDoSegmentCall(llvm::Value * kernelInstance, llvm::Value * blkCount);
60    llvm::Value * createFinalBlockCall(llvm::Value * kernelInstance, llvm::Value * remainingBytes);
61    llvm::Value * createGetAccumulatorCall(llvm::Value * kernelInstance, std::string accumName);
62   
63protected:
64   
65    IDISA::IDISA_Builder * iBuilder;
66    std::string mKernelName;
67    std::vector<StreamSetBinding> mStreamSetInputs;
68    std::vector<StreamSetBinding> mStreamSetOutputs;
69    std::vector<ScalarBinding> mScalarInputs;
70    std::vector<ScalarBinding> mScalarOutputs;
71    std::vector<ScalarBinding> mInternalScalars;
72    llvm::Type * mKernelStateType;
73};
74#endif
Note: See TracBrowser for help on using the repository browser.