Changeset 5871


Ignore:
Timestamp:
Feb 15, 2018, 12:27:30 PM (9 months ago)
Author:
cameron
Message:

AVX 512 detection and IDISA builder

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5841 r5871  
    247247}
    248248
    249 }
     249std::string IDISA_AVX512BW_Builder::getBuilderUniqueName() {
     250    return mBitBlockWidth != 512 ? "AVX512BW_" + std::to_string(mBitBlockWidth) : "AVX512BW";
     251}
     252
     253
     254}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r5713 r5871  
    5050    ~IDISA_AVX2_Builder() {}
    5151};
     52 
     53class IDISA_AVX512BW_Builder : public virtual IDISA_Builder {
     54public:
     55   
     56    IDISA_AVX512BW_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned stride)
     57    : IDISA_Builder(C, vectorWidth, stride) {
     58    }
     59   
     60    virtual std::string getBuilderUniqueName() override;
     61
     62};
     63
    5264   
    5365}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_target.cpp

    r5756 r5871  
    2222    bool hasAVX;
    2323    bool hasAVX2;
    24     Features() : hasAVX(0), hasAVX2(0) { }
     24    bool hasAVX512BW;
     25    Features() : hasAVX(0), hasAVX2(0), hasAVX512BW(0) { }
    2526};
    2627
     
    3132        hostCPUFeatures.hasAVX = features.lookup("avx");
    3233        hostCPUFeatures.hasAVX2 = features.lookup("avx2");
     34        hostCPUFeatures.hasAVX512BW = features.lookup("avx512bw");
     35        //if (hostCPUFeatures.hasAVX512BW) errs() << "AVX512BW detected.\n";
    3336    }
    3437    return hostCPUFeatures;
     
    4346}
    4447
     48bool AVX512BW_available() {
     49    StringMap<bool> features;
     50    if (sys::getHostCPUFeatures(features)) {
     51        return features.lookup("avx512bw");
     52    }
     53    return false;
     54}
     55
    4556namespace IDISA {
    4657   
     
    4960    if (LLVM_LIKELY(codegen::BlockSize == 0)) {  // No BlockSize override: use processor SIMD width
    5061       
    51         codegen::BlockSize = hostCPUFeatures.hasAVX2 ? 256 : 128;
     62        if (hostCPUFeatures.hasAVX512BW) codegen::BlockSize = 512;
     63        else if (hostCPUFeatures.hasAVX2) codegen::BlockSize = 256;
     64        else codegen::BlockSize = 128;
    5265    }
    5366    else if (((codegen::BlockSize & (codegen::BlockSize - 1)) != 0) || (codegen::BlockSize < 64)) {
    5467        llvm::report_fatal_error("BlockSize must be a power of 2 and >=64");
     68    }
     69    if (codegen::BlockSize >= 512) {
     70        // AVX512BW builder can only be used for BlockSize multiples of 512
     71        if (hostCPUFeatures.hasAVX512BW) {
     72            return new KernelBuilderImpl<IDISA_AVX512BW_Builder>(C, codegen::BlockSize, codegen::BlockSize);
     73        }
    5574    }
    5675    if (codegen::BlockSize >= 256) {
Note: See TracChangeset for help on using the changeset viewer.