Skip to content

Commit

Permalink
Merge pull request #13 from HuangShiqing/paddlebox
Browse files Browse the repository at this point in the history
abacus-aibox-841 update the xtdk version
  • Loading branch information
HuangShiqing authored Oct 31, 2023
2 parents a5a42d2 + 92c657f commit b511644
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 36 deletions.
6 changes: 5 additions & 1 deletion cmake/external/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ if (WITH_BOX_PS OR WITH_XPU_KP)
set(SCALOPUS_URL
"https://klx-sdk-release-public.su.bcebos.com/xdnn_train/dev/paddlebox/20230306/scalopus.tar.gz"
CACHE STRING "" FORCE)
set(XPU_XTDK_URL
"https://klx-sdk-release-public.su.bcebos.com/xdnn_train/dev/paddlebox/xtdk/20230914/output.tar.gz"
CACHE STRING "" FORCE)
endif()

set(SNAPPY_PREFIX_DIR "${THIRD_PARTY_PATH}/xpu")
Expand Down Expand Up @@ -141,7 +144,8 @@ ExternalProject_Add(
wget --no-check-certificate ${XPU_PACK_DEPENCE_URL} -O pack_paddle_box_depence.sh && bash pack_paddle_box_depence.sh ${XPU_XRE_URL}
${XPU_XRE_DIR_NAME} ${XPU_XDNN_URL} ${XPU_XDNN_DIR_NAME} ${XPU_XCCL_URL}
${XPU_XCCL_DIR_NAME} ${XPU_XCTR_URL} ${XPU_XCTR_DIR_NAME} &&
wget --no-check-certificate ${SCALOPUS_URL} && tar zxvf scalopus.tar.gz
wget --no-check-certificate ${SCALOPUS_URL} && tar zxvf scalopus.tar.gz &&
wget --no-check-certificate ${XPU_XTDK_URL} && tar zxvf output.tar.gz
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XPU_INSTALL_ROOT}
Expand Down
14 changes: 8 additions & 6 deletions cmake/xpu_kp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ set(CMAKE_SHARED_LINKER_FLAGS "${LINK_FLAGS}")

if(NOT XPU_TOOLCHAIN)
#set(XPU_TOOLCHAIN /workspace/output/XTDK-ubuntu_x86_64)
set(XPU_TOOLCHAIN /home/work/xtdk/XTDK-centos7_GCC8u3)
set(XPU_TOOLCHAIN ${PROJECT_BINARY_DIR}/third_party/xpu/src/extern_xpu/output/xtdk-centos7_x86_64_gcc8u3)
# set(XPU_TOOLCHAIN /home/work/xtdk/XTDK-centos7_GCC8u3)
#set(XPU_TOOLCHAIN /home/work/xtdk/XTDK-bdcentos_x86_64)
#set(XPU_TOOLCHAIN /home/work/xtdk/XTDK-centos_GCCABI1_x86_64)
get_filename_component(XPU_TOOLCHAIN ${XPU_TOOLCHAIN} REALPATH)
endif()
if(NOT IS_DIRECTORY ${XPU_TOOLCHAIN})
message(FATAL_ERROR "Directory ${XPU_TOOLCHAIN} not found!")
else()
if(NOT IS_DIRECTORY ${XPU_TOOLCHAIN})
message(FATAL_ERROR "Directory ${XPU_TOOLCHAIN} not found!")
endif()
endif()
message(STATUS "Build with XPU_TOOLCHAIN=" ${XPU_TOOLCHAIN})
set(XPU_CLANG ${XPU_TOOLCHAIN}/bin/clang++)
Expand Down Expand Up @@ -196,7 +198,7 @@ macro(compile_kernel COMPILE_ARGS)
COMMAND ${CMAKE_COMMAND} -E make_directory kernel_build
COMMAND
${XPU_CLANG} --sysroot=${CXX_DIR} -std=c++11 ${ABI_VERSION} ${OPT_LEVEL}
-fno-builtin -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS}
-fno-builtin --xpu-arch=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS}
${XPU_CXX_INCLUDES} -I. -o kernel_build/${kernel_name}.bin.o.sec
kernel_build/${kernel_name}.xpu --xpu-device-only -c -v
COMMAND ${XTDK_DIR}/bin/xpu2-elfconv kernel_build/${kernel_name}.bin.o.sec
Expand All @@ -212,7 +214,7 @@ macro(compile_kernel COMPILE_ARGS)
COMMAND ${CMAKE_COMMAND} -E make_directory kernel_build
COMMAND
${XPU_CLANG} --sysroot=${CXX_DIR} -std=c++11 ${ABI_VERSION} ${OPT_LEVEL}
-fno-builtin -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS}
-fno-builtin --xpu-arch=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS}
${XPU_CXX_INCLUDES} -I. -o kernel_build/${kernel_name}.host.o
kernel_build/${kernel_name}.xpu --xpu-host-only -c -v
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/data_feed.kps
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifdef PADDLE_WITH_XPU_KP
#include "paddle/fluid/framework/data_feed_xpu_kernel_helper.h"
#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/xtdk.h"
// #include "xpu/kernel/debug.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/xtdk_math.h"

namespace paddle {
namespace framework {
Expand Down
9 changes: 5 additions & 4 deletions paddle/fluid/framework/fleet/box_wrapper_kernel.kps
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ limitations under the License. */
#include "paddle/fluid/platform/device/xpu/enforce_xpu.h"
#include "paddle/fluid/framework/fleet/box_wrapper_kernel.h"
#include "paddle/fluid/platform/device_context.h"
#include "xpu/kernel/cluster_header.h" // NOLINT
//#include "xpu/kernel/debug.h" // NOLINT
#include "xpu/kernel/math.h" // NOLINT
#include "xpu/kernel/simd.h"

#include "xpu/kernel/xtdk.h" // NOLINT
// #include "xpu/kernel/debug.h" // NOLINT
#include "xpu/kernel/xtdk_math.h" // NOLINT
#include "xpu/kernel/xtdk_simd.h"

#ifdef TRACE_PROFILE
// The producer side.
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/framework/fleet/heter_ps/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ limitations under the License. */
#elif defined(__xpu__)
#include <xpu/runtime.h>

#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/simd.h"
#include "xpu/kernel/xtdk.h"
#include "xpu/kernel/xtdk_math.h"
#include "xpu/kernel/xtdk_simd.h"
#endif

#include "paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h"
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.kps
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License. */

#if defined(PADDLE_WITH_XPU_KP)
#include <xpu/runtime.h>
#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/xtdk.h"
//#include "xpu/kernel/debug.h" // NOLINT
#include "xpu/kernel/math.h"
#include "xpu/kernel/simd.h"
#include "xpu/kernel/xtdk_math.h"
#include "xpu/kernel/xtdk_simd.h"
#endif

namespace paddle {
Expand Down
8 changes: 4 additions & 4 deletions paddle/fluid/framework/fleet/ps_gpu_wrapper.kps
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ limitations under the License. */
#include <numeric>
#include "paddle/fluid/framework/fleet/ps_gpu_wrapper.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "xpu/kernel/cluster_header.h" // NOLINT
#include "xpu/kernel/debug.h" // NOLINT
#include "xpu/kernel/math.h" // NOLINT
#include "xpu/kernel/simd.h"
#include "xpu/kernel/xtdk.h" // NOLINT
// #include "xpu/kernel/debug.h" // NOLINT
#include "xpu/kernel/xtdk_math.h" // NOLINT
#include "xpu/kernel/xtdk_simd.h"

namespace paddle {
namespace framework {
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/core/hostdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#if defined(__xpu__)
#include <xpu/runtime.h>

#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/xtdk.h"
//#include "xpu/kernel/debug.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/xtdk_math.h"
#endif

#if (defined(__CUDACC__) || defined(__HIPCC__) || defined(__xpu__))
Expand Down
4 changes: 4 additions & 0 deletions paddle/phi/kernels/funcs/activation_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,11 @@ template <typename T>
struct CudaExpFunctor : public BaseActivationFunctor<T> {
// exp(x) = expf(x)
__device__ __forceinline__ T operator()(const T x) const {
#if defined(__xpu__)
return static_cast<T>(exp(static_cast<float>(x)));
#else
return static_cast<T>(expf(static_cast<float>(x)));
#endif
}
};

Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/elementwise_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License. */
#if defined(__xpu__)
#include <xpu/runtime.h>

#include "xpu/kernel/math_xpu2.h" //pow()
#include "xpu/kernel/xtdk_math.h" //pow()
#endif

namespace phi {
Expand Down
8 changes: 4 additions & 4 deletions paddle/phi/kernels/primitive/compute_primitives_xpu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#pragma once
#include "paddle/phi/common/float16.h"
#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/debug.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/simd_header.h"
#include "xpu/kernel/xtdk.h"
// #include "xpu/kernel/debug.h"
#include "xpu/kernel/xtdk_math.h"
#include "xpu/kernel/xtdk_simd.h"

namespace phi {
namespace kps {
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/primitive/datamover_primitives_xpu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

#pragma once
#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/debug.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/xtdk.h"
// #include "xpu/kernel/debug.h"
#include "xpu/kernel/xtdk_math.h"

namespace phi {
namespace kps {
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/primitive/functor_primitives_xpu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

#include "xpu/kernel/cluster_header.h"
#include "xpu/kernel/debug.h"
#include "xpu/kernel/math.h"
#include "xpu/kernel/xtdk.h"
// #include "xpu/kernel/debug.h"
#include "xpu/kernel/xtdk_math.h"

namespace phi {
namespace kps {
Expand Down

0 comments on commit b511644

Please sign in to comment.