Browse Source

x86cpu_info r1.7

r1.7
greatpan 3 years ago
parent
commit
1b4efdfc2e
4 changed files with 36 additions and 12 deletions
  1. +6
    -6
      mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c
  2. +10
    -1
      mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h
  3. +16
    -5
      mindspore/lite/src/cpu_info.h
  4. +4
    -0
      mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc

+ 6
- 6
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c View File

@@ -92,26 +92,26 @@ int IntelX86CpuInfoInit(void) {
return NNACL_OK;
}

bool IntelX86InstructionSetSupportCheck(void) {
X86CpuInfoErrorCodeEnum IntelX86InstructionSetSupportCheck(void) {
if (IntelX86CpuInfoInit() != NNACL_OK) {
return false;
return X86CPUINFO_PLATFORM_ERR;
}
#ifdef ENABLE_AVX512
if (!X86_Avx512_Support()) {
return false;
return X86CPUINFO_AVX512_ERR;
}
#endif

#ifdef ENABLE_AVX
if (!X86_Avx_Support()) {
return false;
return X86CPUINFO_AVX_ERR;
}
#endif

#ifdef ENABLE_SSE
if (!X86_Sse_Support()) {
return false;
return X86CPUINFO_SSE_ERR;
}
#endif
return true;
return X86CPUINFO_OK;
}

+ 10
- 1
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h View File

@@ -23,13 +23,22 @@
extern "C" {
#endif

typedef enum X86CpuInfoErrorCodeEnum {
X86CPUINFO_OK = 0,
X86CPUINFO_PLATFORM_ERR = 1,
X86CPUINFO_AVX512_ERR,
X86CPUINFO_AVX_ERR,
X86CPUINFO_SSE_ERR,
X86CPUINFO_END = 9999
} X86CpuInfoErrorCodeEnum;

const bool X86_Fma_Support(void);
const bool X86_Sse_Support(void);
const bool X86_Avx_Support(void);
const bool X86_Avx512_Support(void);

bool IsIntelX86Platform(void);
bool IntelX86InstructionSetSupportCheck(void);
X86CpuInfoErrorCodeEnum IntelX86InstructionSetSupportCheck(void);

int IntelX86CpuInfoInit(void);



+ 16
- 5
mindspore/lite/src/cpu_info.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* Copyright 2021-2022 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,24 @@
#endif

inline bool PlatformInstructionSetSupportCheck() {
bool flag = true;

#if defined(ENABLE_AVX512) || defined(ENABLE_AVX)
flag = IntelX86InstructionSetSupportCheck();
auto ret = IntelX86InstructionSetSupportCheck();
if (ret == X86CPUINFO_PLATFORM_ERR) {
MS_LOG(WARNING) << "This is not intel platform.";
return true;
} else if (ret == X86CPUINFO_AVX512_ERR) {
MS_LOG(ERROR) << "This is avx512 version, but the platform don't support avx512 instruction.";
return false;
} else if (ret == X86CPUINFO_AVX_ERR) {
MS_LOG(ERROR) << "This is avx version, but the platform don't support avx instruction.";
return false;
} else if (ret == X86CPUINFO_SSE_ERR) {
MS_LOG(ERROR) << "This is sse version, but the platform don't support sse instruction.";
return false;
}
#endif

return flag;
return true;
}

#ifdef ENABLE_ARM


+ 4
- 0
mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc View File

@@ -16,9 +16,13 @@
#include "include/api/model_parallel_runner.h"
#include "src/cxx_api/model_pool/model_pool.h"
#include "src/common/log_adapter.h"
#include "src/cpu_info.h"

namespace mindspore {
Status ModelParallelRunner::Init(const std::string &model_path, const std::shared_ptr<RunnerConfig> &runner_config) {
if (!PlatformInstructionSetSupportCheck()) {
return kLiteNotSupport;
}
model_pool_ = std::make_shared<ModelPool>();
if (model_pool_ == nullptr) {
MS_LOG(ERROR) << "model pool is nullptr.";


Loading…
Cancel
Save