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

Last change on this file since 5985 was 5985, checked in by nmedfort, 18 months ago

Restructured MultiBlock? kernel. Removal of Swizzled buffers. Inclusion of PopCount? rates / non-linear access. Modifications to several kernels to better align them with the kernel and pipeline changes.

File size: 3.8 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
12//
13// Parallel Prefix Deletion
14// see Parallel Prefix Compress in Henry S. Warren, Hacker's Delight, Chapter 7
15//
16// Given that we want to delete bits within fields of width fw, moving
17// nondeleted bits to the right, the parallel prefix compress method can
18// be applied.   This requires a preprocessing step to compute log2(fw)
19// masks that can be used to select bits to be moved in each step of the
20// algorithm.
21//
22
23namespace kernel {
24
25/*
26Input: a set of bitstreams
27Output: swizzles containing the input bitstreams with the specified bits deleted
28*/
29class SwizzledDeleteByPEXTkernel final : public BlockOrientedKernel {
30public:
31    SwizzledDeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned streamCount, unsigned PEXT_width = 64);
32    bool isCachable() const override { return true; }
33    bool hasSignature() const override { return false; }
34protected:
35    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) override;
36    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & b, llvm::Value * remainingBytes) override;
37private:
38    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask, const bool flush);
39    std::vector<std::vector<llvm::Value *>> makeSwizzleSets(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask);
40private:
41    const unsigned mStreamCount;
42    const unsigned mSwizzleFactor;
43    const unsigned mSwizzleSetCount;
44    const unsigned mPEXTWidth;
45};
46
47class DeletionKernel final : public BlockOrientedKernel {
48public:
49    DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount);
50    bool isCachable() const override { return true; }
51    bool hasSignature() const override { return false; }
52protected:
53    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
54    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
55private:
56    const unsigned mDeletionFieldWidth;
57    const unsigned mStreamCount;
58};
59
60class DeleteByPEXTkernel final : public BlockOrientedKernel {
61public:
62    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, unsigned PEXT_width = 64);
63    bool isCachable() const override { return true; }
64    bool hasSignature() const override { return false; }
65protected:
66    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
67    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
68    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * delMask);
69private:
70    const unsigned mDelCountFieldWidth;
71    const unsigned mStreamCount;
72    const unsigned mSwizzleFactor;
73    const unsigned mPEXTWidth;
74};
75   
76class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
77public:
78    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
79    bool isCachable() const override { return true; }
80    bool hasSignature() const override { return false; }
81protected:
82    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
83    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
84private:
85    const unsigned mBitStreamCount;
86    const unsigned mFieldWidth;
87    const unsigned mSwizzleFactor;
88    const unsigned mSwizzleSetCount;
89};
90
91   
92}
93   
94#endif
95
Note: See TracBrowser for help on using the repository browser.