Ignore:
Timestamp:
Jun 21, 2016, 9:10:13 PM (3 years ago)
Author:
cameron
Message:

Detect and set CPU features dependent on host machine and OS/VM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5066 r5067  
    5757}
    5858
     59
     60void setAllFeatures(EngineBuilder &builder) {
     61    llvm::StringMap<bool> HostCPUFeatures;
     62    if (llvm::sys::getHostCPUFeatures(HostCPUFeatures)) {
     63        std::vector<std::string> attrs;
     64        for (auto &flag : HostCPUFeatures) {
     65            auto enabled = flag.second ? "+" : "-";
     66            attrs.push_back(enabled + flag.first().str());
     67        }
     68        builder.setMAttrs(attrs);
     69    }
     70}
     71
     72
     73
    5974ExecutionEngine * JIT_to_ExecutionEngine (Module * m) {
    6075
     
    8398    builder.setOptLevel(optLevel);
    8499
    85     if ((strncmp(lGetSystemISA(), "avx2", 4) == 0)) {
    86         std::vector<std::string> attrs;
    87         attrs.push_back("avx2");
    88         builder.setMAttrs(attrs);
    89     }
    90     // builder.selectTarget();
     100    setAllFeatures(builder);
    91101
    92102    if (LLVM_UNLIKELY(codegen::DumpGeneratedIR)) {
Note: See TracChangeset for help on using the changeset viewer.