source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h @ 6017

Last change on this file since 6017 was 6017, checked in by cameron, 13 months ago

mvmd_srl, mvmd_sll for AVX2 to improve StreamCompressKernel? performance

File size: 3.9 KB
Line 
1#ifndef IDISA_AVX_BUILDER_H
2#define IDISA_AVX_BUILDER_H
3
4/*
5 *  Copyright (c) 2015 International Characters.
6 *  This software is licensed to the public under the Open Software License 3.0.
7*/
8
9#include <IR_Gen/idisa_sse_builder.h>
10
11namespace IDISA {
12
13class IDISA_AVX_Builder : public IDISA_SSE2_Builder {
14public:
15
16    IDISA_AVX_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned stride)
17    : IDISA_Builder(C, vectorWidth, stride)
18    , IDISA_SSE2_Builder(C, vectorWidth, stride)
19    {
20
21    }
22
23    virtual std::string getBuilderUniqueName() override;
24
25    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
26
27    ~IDISA_AVX_Builder() {}
28
29};
30
31class IDISA_AVX2_Builder : public IDISA_AVX_Builder {
32public:
33
34    IDISA_AVX2_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned stride)
35    : IDISA_Builder(C, vectorWidth, stride)
36    , IDISA_AVX_Builder(C, vectorWidth, stride) {
37
38    }
39
40    virtual std::string getBuilderUniqueName() override;
41    llvm::Value * hsimd_packh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
42    llvm::Value * hsimd_packl(unsigned fw, llvm::Value * a, llvm::Value * b) override;
43    llvm::Value * esimd_mergeh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
44    llvm::Value * esimd_mergel(unsigned fw, llvm::Value * a, llvm::Value * b) override;
45    llvm::Value * hsimd_packh_in_lanes(unsigned lanes, unsigned fw, llvm::Value * a, llvm::Value * b) override;
46    llvm::Value * hsimd_packl_in_lanes(unsigned lanes, unsigned fw, llvm::Value * a, llvm::Value * b) override;
47    std::pair<llvm::Value *, llvm::Value *> bitblock_add_with_carry(llvm::Value * a, llvm::Value * b, llvm::Value * carryin) override;
48    std::pair<llvm::Value *, llvm::Value *> bitblock_indexed_advance(llvm::Value * a, llvm::Value * index_strm, llvm::Value * shiftin, unsigned shift) override;
49    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
50    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
51    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
52    llvm::Value * mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) override;
53    llvm::Value * simd_pext(unsigned fw, llvm::Value * v, llvm::Value * extract_mask) override;
54    llvm::Value * simd_pdep(unsigned fw, llvm::Value * v, llvm::Value * deposit_mask) override;
55   
56
57    ~IDISA_AVX2_Builder() {}
58};
59
60class IDISA_AVX512F_Builder : public IDISA_AVX2_Builder {
61public:
62
63    IDISA_AVX512F_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned stride)
64    : IDISA_Builder(C, vectorWidth, stride)
65    , IDISA_AVX2_Builder(C, vectorWidth, stride) {
66        getAVX512Features();
67    }
68
69    virtual std::string getBuilderUniqueName() override;
70    void getAVX512Features();
71    llvm::Value * hsimd_packh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
72    llvm::Value * hsimd_packl(unsigned fw, llvm::Value * a, llvm::Value * b) override;
73    llvm::Value * esimd_bitspread(unsigned fw, llvm::Value * bitmask) override;
74    llvm::Value * simd_popcount(unsigned fw, llvm::Value * a) override;
75    llvm::Value * mvmd_slli(unsigned fw, llvm::Value * a, unsigned shift) override;
76    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
77    llvm::Value * mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) override;
78    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
79    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
80
81    ~IDISA_AVX512F_Builder() {
82    }
83private:
84    struct Features {
85        //not an exhaustive list, can be extended if needed
86        bool hasAVX512CD = false;
87        bool hasAVX512BW = false;
88        bool hasAVX512DQ = false;
89        bool hasAVX512VL = false;
90        bool hasAVX512VBMI = false;
91        bool hasAVX512VBMI2 = false;
92        bool hasAVX512VPOPCNTDQ = false;
93    };
94    Features hostCPUFeatures;
95};
96
97
98}
99#endif // IDISA_AVX_BUILDER_H
Note: See TracBrowser for help on using the repository browser.