source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_target.cpp @ 5732

Last change on this file since 5732 was 5560, checked in by cameron, 2 years ago

BlockSize? check

File size: 1.5 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 "idisa_target.h"
7#include <toolchain/toolchain.h>
8#include <IR_Gen/idisa_sse_builder.h>
9#include <IR_Gen/idisa_avx_builder.h>
10#include <IR_Gen/idisa_i64_builder.h>
11#include <IR_Gen/idisa_nvptx_builder.h>
12#include <llvm/IR/Module.h>
13#include <llvm/ADT/Triple.h>
14#include <llvm/Support/ErrorHandling.h>
15#include <kernels/kernel_builder.h>
16
17using namespace kernel;
18
19namespace IDISA {
20   
21KernelBuilder * GetIDISA_Builder(llvm::LLVMContext & C) {
22    const bool hasAVX2 = AVX2_available();
23    if (LLVM_LIKELY(codegen::BlockSize == 0)) {  // No BlockSize override: use processor SIMD width
24        codegen::BlockSize = hasAVX2 ? 256 : 128;
25    }
26    else if (((codegen::BlockSize & (codegen::BlockSize - 1)) != 0) || (codegen::BlockSize < 64)) {
27        llvm::report_fatal_error("BlockSize must be a power of 2 and >=64");
28    }
29    if (codegen::BlockSize >= 256) {
30        if (hasAVX2) {
31            return new KernelBuilderImpl<IDISA_AVX2_Builder>(C, codegen::BlockSize, codegen::BlockSize);
32        }
33    } else if (codegen::BlockSize == 64) {
34        return new KernelBuilderImpl<IDISA_I64_Builder>(C, codegen::BlockSize, codegen::BlockSize);
35    }
36    return new KernelBuilderImpl<IDISA_SSE2_Builder>(C, codegen::BlockSize, codegen::BlockSize);
37}
38
39KernelBuilder * GetIDISA_GPU_Builder(llvm::LLVMContext & C) {
40    return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(C, 64, 64 * 64);
41}
42
43}
Note: See TracBrowser for help on using the repository browser.