source: icGREP/icgrep-devel/icgrep/kernels/source_kernel.h @ 5540

Last change on this file since 5540 was 5464, checked in by nmedfort, 2 years ago

Restructuring work for the Driver classes. Start of work to eliminate the memory leaks with the ExecutionEngine?. Replaced custom AlignedMalloc? with backend call to std::aligned_malloc. Salvaged some work on DistributionPass? for reevaluation.

File size: 2.4 KB
Line 
1#ifndef SOURCE_KERNEL_H
2#define SOURCE_KERNEL_H
3
4#include "kernel.h"
5namespace kernel { class KernelBuilder; }
6
7namespace kernel {
8
9/* The MMapSourceKernel is a simple wrapper for an external MMap file buffer.
10   The doSegment method of this kernel feeds one segment at a time to a
11   pipeline. */
12
13class MMapSourceKernel final : public SegmentOrientedKernel {
14public:
15    MMapSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
16    bool isCachable() const override { return true; }
17    bool hasSignature() const override { return false; }
18protected:
19    void linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
20    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
21    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
22    void generateFinalizeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
23protected:
24    const unsigned          mSegmentBlocks;
25    const unsigned          mCodeUnitWidth;
26    llvm::Function *        mFileSizeFunction;
27};
28
29class ReadSourceKernel final : public SegmentOrientedKernel {
30public:
31    ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
32    bool isCachable() const override { return true; }
33    bool hasSignature() const override { return false; }
34protected:
35    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
36    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
37    void generateFinalizeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
38private:
39    unsigned mSegmentBlocks;
40    unsigned mCodeUnitWidth;
41};
42
43class MemorySourceKernel final : public SegmentOrientedKernel {
44public:
45    MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, llvm::Type * type, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
46    bool hasSignature() const override { return false; }
47protected:
48    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
49    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
50private:
51    unsigned mSegmentBlocks;
52    unsigned mCodeUnitWidth;
53};
54
55}
56
57#endif // SOURCE_KERNEL_H
Note: See TracBrowser for help on using the repository browser.