source: icGREP/icgrep-devel/icgrep/IDISA/idisa_target.cpp @ 5108

Last change on this file since 5108 was 5108, checked in by cameron, 3 years ago

AVX2 checking via getHostCPUFeatures

File size: 1.2 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
6#include <toolchain.h>
7#include <IDISA/idisa_avx_builder.h>
8#include <IDISA/idisa_sse_builder.h>
9#include <IDISA/idisa_i64_builder.h>
10
11namespace IDISA {
12   
13
14
15IDISA_Builder * GetIDISA_Builder(Module * mod) {
16    bool hasAVX2 = AVX2_available();
17    unsigned theBlockSize = codegen::BlockSize;  // from command line
18   
19    if (theBlockSize == 0) {  // No BlockSize override: use processor SIMD width
20        theBlockSize = hasAVX2 ? 256 : 128;
21    }
22    Type * bitBlockType = VectorType::get(IntegerType::get(getGlobalContext(), 64), theBlockSize/64);
23   
24    int blockSize = bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth();
25    if (blockSize >= 256) {
26        if (hasAVX2) {
27            return new IDISA_AVX2_Builder(mod, bitBlockType);
28        }
29        else{
30            return new IDISA_SSE2_Builder(mod, bitBlockType);
31        }
32    }
33    else if (blockSize == 64)
34        return new IDISA_I64_Builder(mod, bitBlockType);
35    return new IDISA_SSE2_Builder(mod, bitBlockType);
36}
37
38}
Note: See TracBrowser for help on using the repository browser.