diff --git a/paddle/CMakeLists.txt b/paddle/CMakeLists.txt index 895bd9db9cf64ec78c49bf97c96b9c232d6f2343..80f4c6bb542d72327a6209c06e341fb4985ef2f4 100644 --- a/paddle/CMakeLists.txt +++ b/paddle/CMakeLists.txt @@ -49,18 +49,15 @@ endif() list(LENGTH test_names len) if(${len} GREATER_EQUAL 1) - message("Total tests: ${len}") + message("Total cpp tests using dynamic link: ${len}") math(EXPR stop "${len} - 1") foreach(idx RANGE ${stop}) if(WITH_TESTING) list(GET test_srcs ${idx} test_src) list(GET test_names ${idx} test_name) get_property(test_arg GLOBAL PROPERTY "${test_name}_ARGS") - message("add test ${test_name}") + # message("add test ${test_name}") add_executable(${test_name} ${test_src}) - # target_link_libraries( - # ${test_name} - # ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/libpaddle${POSTFIX}) target_link_libraries(${test_name} $) target_link_libraries(${test_name} paddle_gtest_main_new) add_dependencies(${test_name} ${paddle_lib} paddle_gtest_main_new) @@ -75,6 +72,9 @@ if(${len} GREATER_EQUAL 1) target_link_libraries(${test_name} "-Wl,-rpath,$") endif() + if(WITH_XPU) + target_link_libraries(${test_name} xpulib) + endif() if(NOT ("${test_name}" STREQUAL "c_broadcast_op_npu_test" OR "${test_name}" STREQUAL "c_allreduce_sum_op_npu_test" diff --git a/paddle/fluid/operators/collective/c_comm_init_op.cc b/paddle/fluid/operators/collective/c_comm_init_op.cc index 59fbd02b5c0864608980ff808c684a25605e8a74..26e700262f8dda4555836dca2685eb182e08206b 100644 --- a/paddle/fluid/operators/collective/c_comm_init_op.cc +++ b/paddle/fluid/operators/collective/c_comm_init_op.cc @@ -57,11 +57,9 @@ class CCommInitOp : public framework::OperatorBase { using CommContext = platform::NCCLCommContext; #elif defined(PADDLE_WITH_XPU_BKCL) using UniqueId = BKCLUniqueId; - using Place = platform::XPUPlace; using CommContext = platform::BKCLCommContext; #elif defined(PADDLE_WITH_CNCL) using UniqueId = cnclCliqueId; - using Place = platform::MLUPlace; using CommContext = platform::CNCLCommContext; #else PADDLE_THROW(platform::errors::PreconditionNotMet( diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index b7d8eb1dcbc594c931a6a7e2b949aa0ff9bae54e..3a3c98a9e99562fba3c9e0d467ceac6c3a106e8f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -48,6 +48,16 @@ set(FLUID_CORE_DEPS ${FLUID_CORE}) add_custom_target(copy_libpaddle ALL DEPENDS ${FLUID_CORE_DEPS}) +# NOTE(zhiqiu): WHY? +# In `setup.py.in`, some dynamic libraries (eg, libxpuapi.so) are modified using +# patchelf. In rare cases, if the a linker is linking that dynamic library for +# some executables at the same time, a `file not recognized, file truncated` +# error may occur, result in the compilation error. +# So, add dependency to force the cpp tests built before running `setup.py.in`. +if(WITH_TESTING) + add_dependencies(copy_libpaddle build_tests) +endif() + if(WIN32) add_custom_command( OUTPUT ${PADDLE_PYTHON_BUILD_DIR}/.timestamp