source: icGREP/icgrep-devel/icgrep/kernels/deletion.h @ 6013

Last change on this file since 6013 was 6013, checked in by cameron, 12 months ago

StreamCompressKernel? initial check-in

File size: 4.9 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#ifndef DELETION_H
6#define DELETION_H
7
8#include "kernel.h"
9#include <llvm/IR/Value.h>
10namespace IDISA { class IDISA_Builder; }
11
12namespace kernel {
13
14//
15// Parallel Prefix Deletion Kernel
16// see Parallel Prefix Compress in Henry S. Warren, Hacker's Delight, Chapter 7
17//
18// Given that we want to delete bits within fields of width fw, moving
19// nondeleted bits to the right, the parallel prefix compress method can
20// be applied.   This requires a preprocessing step to compute log2(fw)
21// masks that can be used to select bits to be moved in each step of the
22// algorithm.
23//
24class DeletionKernel final : public BlockOrientedKernel {
25public:
26    DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount);
27    bool isCachable() const override { return true; }
28    bool hasSignature() const override { return false; }
29protected:
30    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
31    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
32private:
33    const unsigned mDeletionFieldWidth;
34    const unsigned mStreamCount;
35};
36
37class FieldCompressKernel final : public MultiBlockKernel {
38public:
39    FieldCompressKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned fw, unsigned streamCount);
40    bool isCachable() const override { return true; }
41    bool hasSignature() const override { return false; }
42protected:
43    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & kb, llvm::Value * const numOfStrides) override;
44private:
45    const unsigned mCompressFieldWidth;
46    const unsigned mStreamCount;
47};
48
49//
50//  Given streams that are compreseed within fields, produced fully
51//  compressed streams.
52class StreamCompressKernel final : public MultiBlockKernel {
53public:
54    StreamCompressKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned fw, unsigned streamCount);
55    bool isCachable() const override { return true; }
56    bool hasSignature() const override { return false; }
57protected:
58    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & kb, llvm::Value * const numOfBlocks) override;
59private:
60    const unsigned mCompressedFieldWidth;
61    const unsigned mStreamCount;
62};
63
64/*
65Input: a set of bitstreams
66Output: swizzles containing the input bitstreams with the specified bits deleted
67*/
68class SwizzledDeleteByPEXTkernel final : public BlockOrientedKernel {
69public:
70    SwizzledDeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned streamCount, unsigned PEXT_width = 64);
71    bool isCachable() const override { return true; }
72    bool hasSignature() const override { return false; }
73protected:
74    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) override;
75    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & b, llvm::Value * remainingBytes) override;
76private:
77    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask, const bool flush);
78    std::vector<std::vector<llvm::Value *>> makeSwizzleSets(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask);
79private:
80    const unsigned mStreamCount;
81    const unsigned mSwizzleFactor;
82    const unsigned mSwizzleSetCount;
83    const unsigned mPEXTWidth;
84};
85
86class DeleteByPEXTkernel final : public BlockOrientedKernel {
87public:
88    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, unsigned PEXT_width = 64);
89    bool isCachable() const override { return true; }
90    bool hasSignature() const override { return false; }
91protected:
92    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
93    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
94    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * delMask);
95private:
96    const unsigned mDelCountFieldWidth;
97    const unsigned mStreamCount;
98    const unsigned mSwizzleFactor;
99    const unsigned mPEXTWidth;
100};
101   
102class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
103public:
104    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
105    bool isCachable() const override { return true; }
106    bool hasSignature() const override { return false; }
107protected:
108    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
109    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
110private:
111    const unsigned mBitStreamCount;
112    const unsigned mFieldWidth;
113    const unsigned mSwizzleFactor;
114    const unsigned mSwizzleSetCount;
115};
116
117   
118}
119   
120#endif
121
Note: See TracBrowser for help on using the repository browser.