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

AVX 512 detection and IDISA builder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.