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

Last change on this file since 5404 was 5392, checked in by cameron, 2 years ago

Kernel signatures for object cache

File size: 2.5 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
25class DeletionKernel : public BlockOrientedKernel {
26public:
27
28    DeletionKernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount);
29    bool moduleIDisSignature() override {return true;}
30
31protected:
32    void generateDoBlockMethod() override;
33
34    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
35
36private:
37    const unsigned mDeletionFieldWidth;
38    const unsigned mStreamCount;
39};
40
41class DeleteByPEXTkernel : public BlockOrientedKernel {
42public:
43
44    DeleteByPEXTkernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
45    bool moduleIDisSignature() override {return true;}
46   
47protected:
48    void generateDoBlockMethod() override;
49   
50    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
51
52    void generatePEXTAndSwizzleLoop(const std::vector<llvm::Value *> & masks);
53
54    void generatePEXTLoop(const std::vector<llvm::Value *> & masks);
55
56    void generateProcessingLoop(const std::vector<llvm::Value *> & masks, llvm::Value * delMask);
57   
58private:
59    const unsigned mDelCountFieldWidth;
60    const unsigned mStreamCount;
61    const unsigned mSwizzleFactor;
62    const bool mShouldSwizzle;
63    static constexpr const char* mOutputSwizzleNameBase = "outputStreamSet";
64};
65   
66class SwizzledBitstreamCompressByCount : public BlockOrientedKernel {
67public:
68   
69    SwizzledBitstreamCompressByCount(IDISA::IDISA_Builder * iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
70    bool moduleIDisSignature() override {return true;}
71   
72protected:
73    void generateDoBlockMethod() override;
74   
75    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
76   
77private:
78    const unsigned mBitStreamCount;
79    const unsigned mFieldWidth;
80    const unsigned mSwizzleFactor;
81    const unsigned mSwizzleSetCount;
82};
83
84   
85}
86   
87#endif
88
Note: See TracBrowser for help on using the repository browser.