未验证 提交 9d801855 编写于 作者: L Leo Chen 提交者: GitHub

fix dynamic link of xpu library (#47434)

* refine comments,test=kunlun

* link xpu lib, test=kunlun

* add sleep for test, test=kunlun

* merge develop, fix compile, test=kunlun

* remove debug code, test=kunlun

* add dependency to avoid potential concurrency error, test=kunlun
上级 f9134045
......@@ -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_LINKER_FILE:${paddle_lib}>)
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,$<TARGET_FILE_DIR:${paddle_lib}>")
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"
......
......@@ -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(
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册