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

Last change on this file since 5699 was 5693, checked in by cameron, 20 months ago

Unified FDsource kernel; filename - now interpreted as stdin

File size: 3.2 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; }
18    void linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
19    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
20    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
21    void generateFinalizeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
22protected:
23    const unsigned          mSegmentBlocks;
24    const unsigned          mCodeUnitWidth;
25    llvm::Function *        mFileSizeFunction;
26};
27
28class ReadSourceKernel final : public SegmentOrientedKernel {
29public:
30    ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
31    bool isCachable() const override { return true; }
32    bool hasSignature() const override { return false; }
33    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
34    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
35    void generateFinalizeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
36private:
37    unsigned mSegmentBlocks;
38    unsigned mCodeUnitWidth;
39};
40
41class FDSourceKernel final : public SegmentOrientedKernel {
42public:
43    FDSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
44    bool isCachable() const override { return true; }
45    bool hasSignature() const override { return false; }
46    void linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
47    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
48    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
49    void generateFinalizeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
50protected:
51    const unsigned          mSegmentBlocks;
52    const unsigned          mCodeUnitWidth;
53    llvm::Function *        mFileSizeFunction;
54};
55   
56class MemorySourceKernel final : public SegmentOrientedKernel {
57public:
58    MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, llvm::Type * type, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
59    bool hasSignature() const override { return false; }
60protected:
61    void generateInitializeMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
62    void generateDoSegmentMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
63private:
64    unsigned mSegmentBlocks;
65    unsigned mCodeUnitWidth;
66};
67
68}
69
70#endif // SOURCE_KERNEL_H
Note: See TracBrowser for help on using the repository browser.