From f2adc0109bf6d63ffb9844b01e1bbbac7c6109cb Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Wed, 9 Nov 2022 11:41:35 +0800 Subject: [PATCH] gpu/cpu use glibcxx_abi=0 Signed-off-by: zhoufeng --- CMakeLists.txt | 2 +- cmake/options.cmake | 2 +- mindspore/python/mindspore/ops/operations/custom_ops.py | 3 ++- tests/st/ops/graph_kernel/custom/test_custom_aot.py | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08866531539..1d49d7e5eb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/check_requirements.cmake) include(${CMAKE_SOURCE_DIR}/cmake/ascend_variables.cmake) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") -if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows") +if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(NOT ENABLE_GLIBCXX) add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index de396871a37..d382ebf0ce0 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -33,7 +33,7 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") set(USE_MS_THREADPOOL_FOR_DNNL OFF) endif() -if(NOT ENABLE_D AND NOT ENABLE_TESTCASES AND NOT ENABLE_ACL) +if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") set(ENABLE_GLIBCXX ON) endif() diff --git a/mindspore/python/mindspore/ops/operations/custom_ops.py b/mindspore/python/mindspore/ops/operations/custom_ops.py index b091a5e1f3e..3bf7916e922 100644 --- a/mindspore/python/mindspore/ops/operations/custom_ops.py +++ b/mindspore/python/mindspore/ops/operations/custom_ops.py @@ -97,12 +97,13 @@ def _compile_aot(file): Custom.compiled_bin.append(func_path) if file.endswith("cpp") or file.endswith("cc"): - cmd = ["g++", "-std=c++17", "--shared", "-fPIC"] + cmd = ["g++", "-std=c++17", "--shared", "-fPIC", "-D_GLIBCXX_USE_CXX11_ABI=0"] cmd += [include_file, "-o", func_path, file] elif file.endswith("cu"): cmd = ["nvcc"] cmd += ["--shared", "-Xcompiler", "-fPIC", "-O3", "-gencode", "arch=compute_70, code=sm_70"] cmd += ["--use_fast_math", "--expt-relaxed-constexpr", "--expt-extended-lambda"] + cmd += ["-D_GLIBCXX_USE_CXX11_ABI=0"] def _get_cuda_bare_metal_version(): raw_output = subprocess.check_output(["nvcc", "-V"], diff --git a/tests/st/ops/graph_kernel/custom/test_custom_aot.py b/tests/st/ops/graph_kernel/custom/test_custom_aot.py index 1bde22a9bdf..019274b46a1 100755 --- a/tests/st/ops/graph_kernel/custom/test_custom_aot.py +++ b/tests/st/ops/graph_kernel/custom/test_custom_aot.py @@ -46,16 +46,16 @@ class AOTSingleOutputWithAttrNet(Cell): def get_file_path_gpu(cuda, so): dir_path = os.path.dirname(os.path.abspath(__file__)) - cmd = "nvcc --shared -Xcompiler -fPIC -o " + dir_path + "/aot_test_files/" + so + " " + dir_path + \ - "/aot_test_files/" + cuda + cmd = "nvcc -D_GLIBCXX_USE_CXX11_ABI=0 --shared -Xcompiler -fPIC -o " + dir_path + "/aot_test_files/" + so + \ + " " + dir_path + "/aot_test_files/" + cuda func_path = dir_path + "/aot_test_files/" + so return cmd, func_path def get_file_path_cpu(cc, so): dir_path = os.path.dirname(os.path.abspath(__file__)) - cmd = "g++ -std=c++17 --shared -fPIC -o " + dir_path + "/aot_test_files/" + so + " " + dir_path + \ - "/aot_test_files/" + cc + cmd = "g++ -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17 --shared -fPIC -o " + dir_path + "/aot_test_files/" + so + " " + \ + dir_path + "/aot_test_files/" + cc func_path = dir_path + "/aot_test_files/" + so return cmd, func_path