Skip to content

Commit

Permalink
[XPU] Support GCC4.8.5 for x86+XPU (#10379)
Browse files Browse the repository at this point in the history
* Support GCC4.8.5 for x86
Co-authored-by: hong19860320 <9973393+hong19860320@users.noreply.github.com>
  • Loading branch information
Travis-Lee authored Sep 20, 2023
1 parent d77658b commit edea477
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @mjp9527 @zhupengyang @hong19860320
* @zhupengyang @hong19860320
64 changes: 22 additions & 42 deletions cmake/backends/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ macro (prepare_xpu_sdk sdk sdk_url)
set (xpu_${sdk}_root "${XPU_INSTALL_DIR}/xpu/${sdk}" CACHE PATH "xpu ${sdk} include directory" FORCE)
set (xpu_${sdk}_include_dir "${xpu_${sdk}_root}/include" CACHE PATH "xpu ${sdk} include directory" FORCE)
include_directories (${xpu_${sdk}_include_dir})

foreach (lib ${ARGN})
add_library (${lib} SHARED IMPORTED GLOBAL)
set_property (TARGET ${lib} PROPERTY IMPORTED_LOCATION "${xpu_${sdk}_root}/so/lib${lib}.so")
Expand All @@ -72,6 +71,28 @@ macro (prepare_xpu_sdk sdk sdk_url)
endforeach ()
endmacro ()

if (XPU_SDK_ROOT)
include_directories(
${XPU_SDK_ROOT}/xpu/xre/include/
${XPU_SDK_ROOT}/xpu/xdnn/include/
)
add_library (xpuapi SHARED IMPORTED GLOBAL)
add_library (xpurt SHARED IMPORTED GLOBAL)
set_property (TARGET xpuapi PROPERTY IMPORTED_LOCATION "${XPU_SDK_ROOT}/xpu/xdnn/so/libxpuapi.so")
set_property (TARGET xpurt PROPERTY IMPORTED_LOCATION "${XPU_SDK_ROOT}/xpu/xre/so/libxpurt.so")
link_libraries (xpuapi xpurt)
set (XPUAPI_LIB "${XPU_SDK_ROOT}/xpu/xdnn/so/libxpuapi.so" CACHE FILEPATH "libxpuapi.so" FORCE)
set (XPURT_LIB "${XPU_SDK_ROOT}/xpu/xre/so/libxpurt.so" CACHE FILEPATH "libxpurt.so" FORCE)
else()
prepare_xpu_sdk (xdnn ${XPU_XDNN_URL} xpuapi)
prepare_xpu_sdk (xre ${XPU_XRE_URL} xpurt)
set (XPUAPI_LIB "${XPU_INSTALL_DIR}/xpu/xdnn/so/libxpuapi.so" CACHE FILEPATH "libxpuapi.so" FORCE)
set (XPURT_LIB "${XPU_INSTALL_DIR}/xpu/xre/so/libxpurt.so" CACHE FILEPATH "libxpurt.so" FORCE)
endif ()
set (xpu_builder_libs xpuapi CACHE INTERNAL "xpu builder libs")
set (xpu_runtime_libs xpurt CACHE INTERNAL "xpu runtime libs")


if(XPU_WITH_XFT)
if(XPU_XFT_ROOT)
set (xpu_xft_root "${XPU_XFT_ROOT}" CACHE PATH "xpu xft include directory" FORCE)
Expand Down Expand Up @@ -111,44 +132,3 @@ if(XPU_WITH_XFT)
endif(XPU_XFT_ROOT)
endif(XPU_WITH_XFT)

if (NOT XPU_SDK_ROOT)
prepare_xpu_sdk (xdnn ${XPU_XDNN_URL} xpuapi)
prepare_xpu_sdk (xre ${XPU_XRE_URL} xpurt)
set (XPUAPI_LIB "${XPU_INSTALL_DIR}/xpu/xdnn/so/libxpuapi.so" CACHE FILEPATH "libxpuapi.so" FORCE)
set (XPURT_LIB "${XPU_INSTALL_DIR}/xpu/xre/so/libxpurt.so" CACHE FILEPATH "libxpurt.so" FORCE)
set (xpu_builder_libs xpuapi CACHE INTERNAL "xpu builder libs")
set (xpu_runtime_libs xpurt CACHE INTERNAL "xpu runtime libs")
return ()
endif ()

# **DEPRECATED**, use XPU_SDK_URL/XPU_SDK_ENV in the future
message (STATUS "XPU_SDK_ROOT: ${XPU_SDK_ROOT}")

if (MSVC)
set (XPU_INCLUDE_DIR "${XPU_SDK_ROOT}/XTCL/include" CACHE PATH "xpu include directory" FORCE)
set (XPUAPI_LIB "${XPU_SDK_ROOT}/XTCL/lib/libxpuapi.lib" CACHE FILEPATH "libxpuapi.lib" FORCE)
set (XPURT_LIB "${XPU_SDK_ROOT}/XTCL/runtime/lib/libxpurt.lib" CACHE FILEPATH "libxpurt.lib" FORCE)
else ()
set (XPU_INCLUDE_DIR "${XPU_SDK_ROOT}/XTCL/include" CACHE PATH "xpu include directory" FORCE)
set (XPUAPI_LIB "${XPU_SDK_ROOT}/XTCL/shlib/libxpuapi.so" CACHE FILEPATH "libxpuapi.so" FORCE)
set (XPURT_LIB "${XPU_SDK_ROOT}/XTCL/runtime/shlib/libxpurt.so" CACHE FILEPATH "libxpurt.so" FORCE)
endif ()
include_directories (${XPU_INCLUDE_DIR})


if (MSVC)
add_library (xpuapi STATIC IMPORTED GLOBAL)
else ()
add_library (xpuapi SHARED IMPORTED GLOBAL)
endif ()
set_property (TARGET xpuapi PROPERTY IMPORTED_LOCATION ${XPUAPI_LIB})

if (MSVC)
add_library (xpurt STATIC IMPORTED GLOBAL)
else ()
add_library (xpurt SHARED IMPORTED GLOBAL)
endif ()
set_property (TARGET xpurt PROPERTY IMPORTED_LOCATION ${XPURT_LIB})

set (xpu_runtime_libs xpuapi xpurt CACHE INTERNAL "xpu runtime libs")
set (xpu_builder_libs xpuapi xpurt CACHE INTERNAL "xpu builder libs")
Loading

0 comments on commit edea477

Please sign in to comment.