You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2020/08/27 11:50:27 UTC
[arrow] branch master updated: ARROW-9871: [C++] Add uppercase to
ARROW_USER_SIMD_LEVEL
This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 0f33e9e ARROW-9871: [C++] Add uppercase to ARROW_USER_SIMD_LEVEL
0f33e9e is described below
commit 0f33e9eceebfbe842f56e151a7a6aa328ee3973c
Author: Frank Du <fr...@intel.com>
AuthorDate: Thu Aug 27 13:50:03 2020 +0200
ARROW-9871: [C++] Add uppercase to ARROW_USER_SIMD_LEVEL
Follow the convention of ARROW_SIMD_LEVEL.
Signed-off-by: Frank Du <fr...@intel.com>
Closes #8060 from jianxind/ARROW-9871
Lead-authored-by: Frank Du <fr...@intel.com>
Co-authored-by: Antoine Pitrou <an...@python.org>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/util/cpu_info.cc | 22 +++++++++++++++-------
cpp/src/arrow/util/io_util.h | 1 +
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/cpp/src/arrow/util/cpu_info.cc b/cpp/src/arrow/util/cpu_info.cc
index 2fd1ad0..7af4fd1 100644
--- a/cpp/src/arrow/util/cpu_info.cc
+++ b/cpp/src/arrow/util/cpu_info.cc
@@ -39,6 +39,7 @@
#endif
#include <algorithm>
+#include <cctype>
#include <cerrno>
#include <cstdint>
#include <fstream>
@@ -46,6 +47,8 @@
#include <mutex>
#include <string>
+#include "arrow/result.h"
+#include "arrow/util/io_util.h"
#include "arrow/util/logging.h"
#include "arrow/util/string.h"
@@ -420,24 +423,29 @@ void CpuInfo::SetDefaultCacheSize() {
}
void CpuInfo::ParseUserSimdLevel() {
- const char* user = std::getenv("ARROW_USER_SIMD_LEVEL");
- if (!user) {
+ auto maybe_env_var = GetEnvVar("ARROW_USER_SIMD_LEVEL");
+ if (!maybe_env_var.ok()) {
// No user settings
return;
}
+ std::string s = *std::move(maybe_env_var);
+ std::transform(s.begin(), s.end(), s.begin(),
+ [](unsigned char c) { return std::toupper(c); });
int level = USER_SIMD_MAX;
// Parse the level
- if (0 == strcmp("avx512", user)) {
+ if (s == "AVX512") {
level = USER_SIMD_AVX512;
- } else if (0 == strcmp("avx2", user)) {
+ } else if (s == "AVX2") {
level = USER_SIMD_AVX2;
- } else if (0 == strcmp("avx", user)) {
+ } else if (s == "AVX") {
level = USER_SIMD_AVX;
- } else if (0 == strcmp("sse4_2", user)) {
+ } else if (s == "SSE4_2") {
level = USER_SIMD_SSE4_2;
- } else if (0 == strcmp("none", user)) {
+ } else if (s == "NONE") {
level = USER_SIMD_NONE;
+ } else if (!s.empty()) {
+ ARROW_LOG(WARNING) << "Invalid value for ARROW_USER_SIMD_LEVEL: " << s;
}
// Disable feature as the level
diff --git a/cpp/src/arrow/util/io_util.h b/cpp/src/arrow/util/io_util.h
index baa69a4..d012db7 100644
--- a/cpp/src/arrow/util/io_util.h
+++ b/cpp/src/arrow/util/io_util.h
@@ -31,6 +31,7 @@
#endif
#include "arrow/io/interfaces.h"
+#include "arrow/status.h"
#include "arrow/type_fwd.h"
#include "arrow/util/macros.h"
#include "arrow/util/windows_fixup.h"