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

Last change on this file since 5247 was 5246, checked in by nmedfort, 2 years ago

Code clean up to enforce proper calling order of KernelBuilder? methods

File size: 1.9 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 "streamset.h"
9#include "interface.h"
10#include "kernel.h"
11
12
13namespace llvm { class Module; class Value;}
14
15namespace IDISA { class IDISA_Builder; }
16
17//
18// Parallel Prefix Deletion
19// see Parallel Prefix Compress in Henry S. Warren, Hacker's Delight, Chapter 7
20//
21// Given that we want to delete bits within fields of width fw, moving
22// nondeleted bits to the right, the parallel prefix compress method can
23// be applied.   This requires a preprocessing step to compute log2(fw)
24// masks that can be used to select bits to be moved in each step of the
25// algorithm.
26//
27// Deletion Mask Calculation
28
29std::vector<llvm::Value *> parallel_prefix_deletion_masks(IDISA::IDISA_Builder * iBuilder, unsigned fw, llvm::Value * del_mask);
30
31// Applying Deletion Masks to a Stream
32
33llvm::Value * apply_parallel_prefix_deletion(IDISA::IDISA_Builder * iBuilder, unsigned fw, llvm::Value * del_mask, std::vector<llvm::Value *> mv, llvm::Value * strm);
34
35using namespace parabix;
36
37namespace kernel {
38
39class DeletionKernel : public kernel::KernelBuilder {
40public:
41    DeletionKernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount) :
42    KernelBuilder(iBuilder, "del",
43                  {Binding{iBuilder->getStreamSetTy(streamCount), "inputStreamSet"},
44                   Binding{iBuilder->getStreamSetTy(), "delMaskSet"}},
45                  {Binding{iBuilder->getStreamSetTy(streamCount), "outputStreamSet"},
46                   Binding{iBuilder->getStreamSetTy(), "deletionCounts"}},
47                  {}, {}, {}),
48    mDeletionFieldWidth(fw),
49    mStreamCount(streamCount) {}
50   
51private:
52    void generateDoBlockMethod() const override;
53    void generateFinalBlockMethod() const override;
54    unsigned mDeletionFieldWidth;
55    unsigned mStreamCount;
56};
57
58}
59   
60#endif
61
Note: See TracBrowser for help on using the repository browser.