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

Last change on this file since 5390 was 5362, checked in by cameron, 3 years ago

Adam's changes to add swizzling option to DeleteByPEXT kernel

File size: 2.4 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   
30protected:
31
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   
46protected:
47   
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   
71protected:
72   
73    void generateDoBlockMethod() override;
74    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
75   
76private:
77    const unsigned mBitStreamCount;
78    const unsigned mFieldWidth;
79    const unsigned mSwizzleFactor;
80    const unsigned mSwizzleSetCount;
81};
82
83   
84}
85   
86#endif
87
Note: See TracBrowser for help on using the repository browser.