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

Last change on this file since 5501 was 5464, checked in by nmedfort, 2 years ago

Restructuring work for the Driver classes. Start of work to eliminate the memory leaks with the ExecutionEngine?. Replaced custom AlignedMalloc? with backend call to std::aligned_malloc. Salvaged some work on DistributionPass? for reevaluation.

File size: 3.1 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 final : public BlockOrientedKernel {
26public:
27    DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount);
28    bool isCachable() const override { return true; }
29    bool hasSignature() const override { return false; }
30protected:
31    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
32    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
33private:
34    const unsigned mDeletionFieldWidth;
35    const unsigned mStreamCount;
36};
37
38class DeleteByPEXTkernel final : public BlockOrientedKernel {
39public:
40    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
41    bool isCachable() const override { return true; }
42    bool hasSignature() const override { return false; }
43protected:
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);
49private:
50    const unsigned mDelCountFieldWidth;
51    const unsigned mStreamCount;
52    const unsigned mSwizzleFactor;
53    const bool mShouldSwizzle;
54    static constexpr const char* mOutputSwizzleNameBase = "outputStreamSet";
55};
56   
57class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
58public:
59    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
60    bool isCachable() const override { return true; }
61    bool hasSignature() const override { return false; }
62protected:
63    void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) override;
64    void generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, llvm::Value * remainingBytes) override;
65private:
66    const unsigned mBitStreamCount;
67    const unsigned mFieldWidth;
68    const unsigned mSwizzleFactor;
69    const unsigned mSwizzleSetCount;
70};
71
72   
73}
74   
75#endif
76
Note: See TracBrowser for help on using the repository browser.