diff --git a/paddle/fluid/imperative/reducer.cc b/paddle/fluid/imperative/reducer.cc index 1c3165a4538a28ca8d8b92469638351378281c8e..623a44ed75d1dbbd2cb074c4f74c03c12ba561cb 100644 --- a/paddle/fluid/imperative/reducer.cc +++ b/paddle/fluid/imperative/reducer.cc @@ -21,7 +21,7 @@ #include "paddle/fluid/imperative/parallel_context.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/strided_memcpy.h" -#ifdef PADDLE_WITH_XPU_BKCL +#ifdef PADDLE_WITH_XPU #include "paddle/fluid/platform/device/xpu/enforce_xpu.h" #endif #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/platform/device/xpu/enforce_xpu.h b/paddle/fluid/platform/device/xpu/enforce_xpu.h index 77d14aa712e7018c51113c0a1eb957373fcc6689..4d88d7a96246de12ba4f001e0c86f2387fa7f0cf 100644 --- a/paddle/fluid/platform/device/xpu/enforce_xpu.h +++ b/paddle/fluid/platform/device/xpu/enforce_xpu.h @@ -25,10 +25,6 @@ inline const char* xpuGetErrorString(int stat) { return phi::backends::xpu::xpuGetErrorString(stat); } -inline const char* bkclGetErrorString(BKCLResult_t stat) { - return phi::backends::xpu::bkclGetErrorString(stat); -} - inline const char* xdnnGetErrorString(int stat) { return phi::backends::xpu::xdnnGetErrorString(stat); } @@ -37,10 +33,16 @@ inline std::string build_xpu_error_msg(int stat) { return phi::backends::xpu::build_xpu_error_msg(stat); } +#ifdef PADDLE_WITH_XPU_BKCL inline std::string build_xpu_error_msg(BKCLResult_t stat) { return phi::backends::xpu::build_xpu_error_msg(stat); } +inline const char* bkclGetErrorString(BKCLResult_t stat) { + return phi::backends::xpu::bkclGetErrorString(stat); +} +#endif + inline std::string build_xpu_xdnn_error_msg(int stat, std::string msg) { return phi::backends::xpu::build_xpu_xdnn_error_msg(stat, msg); } diff --git a/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc b/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc index 0b528c3999e0767376681da747b7ccc715635a83..b2fd80530feb7462ca34df08acd4651cfd9618c7 100644 --- a/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc +++ b/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc @@ -124,6 +124,7 @@ TEST(enforce, xpu_status) { "Execution interrupted by user")); } +#ifdef PADDLE_WITH_XPU_BKCL TEST(enforce, bkcl_status) { EXPECT_TRUE(CheckXPUStatusSuccess(BKCL_SUCCESS)); EXPECT_TRUE( @@ -133,6 +134,7 @@ TEST(enforce, bkcl_status) { EXPECT_TRUE( CheckXPUStatusFailure(BKCL_INTERNAL_ERROR, "BKCL_INTERNAL_ERROR")); } +#endif TEST(enforce, xdnn_status) { EXPECT_TRUE(CheckXDNNStatusSuccess(xpu::Error_t::SUCCESS)); diff --git a/paddle/phi/backends/xpu/enforce_xpu.h b/paddle/phi/backends/xpu/enforce_xpu.h index 30095e3a0074a18c41161ce41ba2b117a8874e02..44763d408f7d784d13ab8d7cb18f273f62f853d4 100644 --- a/paddle/phi/backends/xpu/enforce_xpu.h +++ b/paddle/phi/backends/xpu/enforce_xpu.h @@ -16,7 +16,9 @@ limitations under the License. */ #include "paddle/fluid/platform/enforce.h" #include "paddle/phi/backends/xpu/xpu_header.h" +#ifdef PADDLE_WITH_XPU_BKCL #include "xpu/bkcl.h" +#endif namespace phi { namespace backends { @@ -97,6 +99,7 @@ inline const char* xpuGetErrorString(int stat) { } } +#ifdef PADDLE_WITH_XPU_BKCL inline const char* bkclGetErrorString(BKCLResult_t stat) { switch (stat) { case BKCL_SUCCESS: @@ -113,6 +116,7 @@ inline const char* bkclGetErrorString(BKCLResult_t stat) { return "Unknown BKCL status"; } } +#endif inline const char* xdnnGetErrorString(int stat) { switch (stat) { @@ -136,10 +140,12 @@ inline std::string build_xpu_error_msg(int stat) { return msg + xpuGetErrorString(stat) + " "; } +#ifdef PADDLE_WITH_XPU_BKCL inline std::string build_xpu_error_msg(BKCLResult_t stat) { std::string msg("BKCL Error, "); return msg + bkclGetErrorString(stat) + " "; } +#endif inline std::string build_xpu_xdnn_error_msg(int stat, std::string msg) { return msg + " XDNN Error, " + xdnnGetErrorString(stat) + " "; @@ -158,7 +164,9 @@ struct ExternalApiType {}; } DEFINE_EXTERNAL_API_TYPE(int, XPU_SUCCESS); +#ifdef PADDLE_WITH_XPU_BKCL DEFINE_EXTERNAL_API_TYPE(BKCLResult_t, BKCL_SUCCESS); +#endif #undef DEFINE_EXTERNAL_API_TYPE