From d90e24aca1377fd727f9e514ef8e9b7922928a47 Mon Sep 17 00:00:00 2001 From: QingshuChen Date: Thu, 5 May 2022 12:29:12 +0800 Subject: [PATCH] update xpu depends (#42365) * update xpu depends *test=kunlun * minor *test=kunlun Co-authored-by: root --- cmake/external/xpu.cmake | 2 +- paddle/fluid/platform/device/xpu/xpu_info.cc | 5 ++++- paddle/phi/backends/xpu/xpu_info.cc | 4 +++- paddle/phi/backends/xpu/xpu_info.h | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/external/xpu.cmake b/cmake/external/xpu.cmake index be911eb7ea..d5ccf12979 100644 --- a/cmake/external/xpu.cmake +++ b/cmake/external/xpu.cmake @@ -9,7 +9,7 @@ SET(XPU_RT_LIB_NAME "libxpurt.so") if(NOT DEFINED XPU_BASE_URL) SET(XPU_BASE_URL_WITHOUT_DATE "https://baidu-kunlun-product.cdn.bcebos.com/KL-SDK/klsdk-dev") - SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20220411") + SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20220425") else() SET(XPU_BASE_URL "${XPU_BASE_URL}") endif() diff --git a/paddle/fluid/platform/device/xpu/xpu_info.cc b/paddle/fluid/platform/device/xpu/xpu_info.cc index 6a58f7890f..2e960c1c0d 100644 --- a/paddle/fluid/platform/device/xpu/xpu_info.cc +++ b/paddle/fluid/platform/device/xpu/xpu_info.cc @@ -54,7 +54,10 @@ std::vector GetXPUSelectedDevices() { void MemcpySyncH2D(void* dst, const void* src, size_t count, const platform::XPUPlace& dst_place) { - phi::backends::xpu::MemcpySyncH2D(dst, src, count, dst_place); + platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); + auto* dev_ctx = pool.GetByPlace(dst_place); + dev_ctx->Wait(); + phi::backends::xpu::MemcpySyncH2D(dst, src, count, dst_place, *dev_ctx); } void MemcpySyncD2H(void* dst, const void* src, size_t count, diff --git a/paddle/phi/backends/xpu/xpu_info.cc b/paddle/phi/backends/xpu/xpu_info.cc index d454fc0734..4dba0ab94f 100644 --- a/paddle/phi/backends/xpu/xpu_info.cc +++ b/paddle/phi/backends/xpu/xpu_info.cc @@ -140,8 +140,10 @@ std::vector GetXPUSelectedDevices() { void MemcpySyncH2D(void* dst, const void* src, size_t count, - const phi::XPUPlace& dst_place) { + const phi::XPUPlace& dst_place, + const phi::XPUContext& dev_ctx) { XPUDeviceGuard guard(dst_place.device); + dev_ctx.Wait(); PADDLE_ENFORCE_XPU_SUCCESS( xpu_memcpy(dst, src, count, XPUMemcpyKind::XPU_HOST_TO_DEVICE)); } diff --git a/paddle/phi/backends/xpu/xpu_info.h b/paddle/phi/backends/xpu/xpu_info.h index fa7d1b5c18..b1056cdc4b 100644 --- a/paddle/phi/backends/xpu/xpu_info.h +++ b/paddle/phi/backends/xpu/xpu_info.h @@ -49,7 +49,8 @@ std::vector GetXPUSelectedDevices(); void MemcpySyncH2D(void *dst, const void *src, size_t count, - const phi::XPUPlace &dst_place); + const phi::XPUPlace &dst_place, + const phi::XPUContext &dev_ctx); void MemcpySyncD2H(void *dst, const void *src, size_t count, -- GitLab