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

Last change on this file since 5445 was 5440, checked in by nmedfort, 2 years ago

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File size: 3.2 KB
RevLine 
[4981]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
[5071]8#include "kernel.h"
[5362]9#include <llvm/IR/Value.h>
[5002]10namespace IDISA { class IDISA_Builder; }
11
[4981]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
[5202]23namespace kernel {
24
[5431]25class DeletionKernel final : public BlockOrientedKernel {
[5071]26public:
[5436]27    DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount);
[5431]28    bool isCachable() const override { return true; }
29    bool moduleIDisSignature() const override { return true; }
[5260]30protected:
[5440]31    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
32    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
[5260]33private:
[5267]34    const unsigned mDeletionFieldWidth;
35    const unsigned mStreamCount;
[5071]36};
[5202]37
[5431]38class DeleteByPEXTkernel final : public BlockOrientedKernel {
[5313]39public:
[5436]40    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
[5431]41    bool isCachable() const override { return true; }
42    bool moduleIDisSignature() const override { return true; }
[5313]43protected:
[5440]44    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
45    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
46    void generatePEXTAndSwizzleLoop(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<llvm::Value *> & masks);
47    void generatePEXTLoop(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<llvm::Value *> & masks);
48    void generateProcessingLoop(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<llvm::Value *> & masks, llvm::Value * delMask);
[5313]49private:
50    const unsigned mDelCountFieldWidth;
51    const unsigned mStreamCount;
[5362]52    const unsigned mSwizzleFactor;
53    const bool mShouldSwizzle;
54    static constexpr const char* mOutputSwizzleNameBase = "outputStreamSet";
[5313]55};
[5355]56   
[5431]57class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
[5355]58public:
[5436]59    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
[5431]60    bool isCachable() const override { return true; }
61    bool moduleIDisSignature() const override { return true; }
[5355]62protected:
[5440]63    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
64    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
[5355]65private:
66    const unsigned mBitStreamCount;
67    const unsigned mFieldWidth;
68    const unsigned mSwizzleFactor;
69    const unsigned mSwizzleSetCount;
70};
71
72   
[5202]73}
[5071]74   
[4981]75#endif
76
Note: See TracBrowser for help on using the repository browser.