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

Last change on this file since 6004 was 6004, checked in by cameron, 17 months ago

Restructuring step for DeletionKernel?: move partial sum popcount in p2sWithCompress

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
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
37/*
38Input: a set of bitstreams
39Output: swizzles containing the input bitstreams with the specified bits deleted
40*/
41class SwizzledDeleteByPEXTkernel final : public BlockOrientedKernel {
42public:
43    SwizzledDeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned streamCount, unsigned PEXT_width = 64);
44    bool isCachable() const override { return true; }
45    bool hasSignature() const override { return false; }
46protected:
47    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) override;
48    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & b, llvm::Value * remainingBytes) override;
49private:
50    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask, const bool flush);
51    std::vector<std::vector<llvm::Value *>> makeSwizzleSets(const std::unique_ptr<KernelBuilder> & b, llvm::Value * delMask);
52private:
53    const unsigned mStreamCount;
54    const unsigned mSwizzleFactor;
55    const unsigned mSwizzleSetCount;
56    const unsigned mPEXTWidth;
57};
58
59class DeleteByPEXTkernel final : public BlockOrientedKernel {
60public:
61    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, unsigned PEXT_width = 64);
62    bool isCachable() const override { return true; }
63    bool hasSignature() const override { return false; }
64protected:
65    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
66    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
67    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * delMask);
68private:
69    const unsigned mDelCountFieldWidth;
70    const unsigned mStreamCount;
71    const unsigned mSwizzleFactor;
72    const unsigned mPEXTWidth;
73};
74   
75class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
76public:
77    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
78    bool isCachable() const override { return true; }
79    bool hasSignature() const override { return false; }
80protected:
81    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
82    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
83private:
84    const unsigned mBitStreamCount;
85    const unsigned mFieldWidth;
86    const unsigned mSwizzleFactor;
87    const unsigned mSwizzleSetCount;
88};
89
90   
91}
92   
93#endif
94
Note: See TracBrowser for help on using the repository browser.