From 0d7018693105c0ca2a41042c063954ab10986de8 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Thu, 27 May 2021 18:44:52 +0800 Subject: [PATCH 1/2] allow to config codegen opt level Signed-off-by: Yuan Zhou --- .../codegen/arrow_compute/ext/codegen_common.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc index 702628509..adb769bde 100644 --- a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc +++ b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc @@ -548,6 +548,13 @@ arrow::Status CompileCodes(std::string codes, std::string signature) { } std::string env_gcc = std::string(env_gcc_); + char* env_codegen_option_ = std::getenv("CODEGEN_OPTION"); + + if (env_codegen_option_ == nullptr) { + env_codegen_option_ = " -O3 -march=native "; + } + std::string env_codegen_option = std::string(env_codegen_option_); + const char* env_arrow_dir = std::getenv("LIBARROW_DIR"); std::string arrow_header; std::string arrow_lib, arrow_lib2; @@ -563,8 +570,8 @@ arrow::Status CompileCodes(std::string codes, std::string signature) { // compile the code std::string cmd = env_gcc + " -std=c++14 -Wno-deprecated-declarations " + arrow_header + arrow_lib + arrow_lib2 + nativesql_header + nativesql_header_2 + - nativesql_lib + cppfile + " -o " + libfile + - " -O3 -march=native -shared -fPIC -lspark_columnar_jni 2> " + logfile; + nativesql_lib + cppfile + " -o " + libfile + env_codegen_option + + " -shared -fPIC -lspark_columnar_jni 2> " + logfile; #ifdef DEBUG std::cout << cmd << std::endl; #endif @@ -577,10 +584,7 @@ arrow::Status CompileCodes(std::string codes, std::string signature) { if (WEXITSTATUS(ret) != EXIT_SUCCESS) { std::cout << "compilation failed, see " << logfile << std::endl; std::cout << cmd << std::endl; - /*cmd = "ls -R -l " + GetTempPath() + "; cat " + logfile; - system(cmd.c_str());*/ return arrow::Status::Invalid("compilation failed, see ", logfile); - // exit(EXIT_FAILURE); } cmd = "cd " + outpath + "; jar -cf spark-columnar-plugin-codegen-precompile-" + signature + ".jar spark-columnar-plugin-codegen-" + signature + ".so"; From 809fb5cbd736c7bdca588f31e9353a40ec7b8d4d Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Mon, 31 May 2021 08:22:42 +0800 Subject: [PATCH 2/2] fix format Signed-off-by: Yuan Zhou --- .../cpp/src/codegen/arrow_compute/ext/codegen_common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc index adb769bde..f09f37871 100644 --- a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc +++ b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc @@ -553,7 +553,7 @@ arrow::Status CompileCodes(std::string codes, std::string signature) { if (env_codegen_option_ == nullptr) { env_codegen_option_ = " -O3 -march=native "; } - std::string env_codegen_option = std::string(env_codegen_option_); + std::string env_codegen_option = std::string(env_codegen_option_); const char* env_arrow_dir = std::getenv("LIBARROW_DIR"); std::string arrow_header;